2020-12-31 07:32:16 -08:00
|
|
|
// Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
|
2012-09-15 17:59:15 -07:00
|
|
|
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
2012-09-12 04:38:30 -07:00
|
|
|
|
2020-10-16 01:13:22 -07:00
|
|
|
#include "graphics/Graphics.h"
|
2020-09-09 08:09:39 -07:00
|
|
|
#include "pigui/LuaPiGui.h"
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
|
2008-06-24 03:17:31 -07:00
|
|
|
#include "SystemView.h"
|
2019-08-21 09:34:40 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "AnimationCurves.h"
|
2020-12-10 14:56:22 -08:00
|
|
|
#include "Background.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "Game.h"
|
2019-01-13 12:11:57 -08:00
|
|
|
#include "GameLog.h"
|
2020-03-27 13:45:17 -07:00
|
|
|
#include "Input.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "Lang.h"
|
2008-06-24 03:17:31 -07:00
|
|
|
#include "Pi.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "Player.h"
|
2008-06-24 03:17:31 -07:00
|
|
|
#include "SectorView.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "Space.h"
|
|
|
|
#include "StringF.h"
|
2014-04-27 05:12:14 -07:00
|
|
|
#include "galaxy/Galaxy.h"
|
2012-04-04 18:53:58 -07:00
|
|
|
#include "galaxy/StarSystem.h"
|
2020-09-09 08:09:39 -07:00
|
|
|
#include "galaxy/SystemPath.h"
|
2012-02-21 02:04:06 -08:00
|
|
|
#include "graphics/Material.h"
|
|
|
|
#include "graphics/Renderer.h"
|
2014-08-18 05:53:10 -07:00
|
|
|
#include "graphics/TextureBuilder.h"
|
2020-01-20 15:13:45 -08:00
|
|
|
#include "lua/LuaObject.h"
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
#include "lua/LuaTable.h"
|
2015-07-19 05:43:11 -07:00
|
|
|
#include <iomanip>
|
2019-01-02 08:59:07 -08:00
|
|
|
#include <sstream>
|
2012-02-21 02:04:06 -08:00
|
|
|
|
|
|
|
using namespace Graphics;
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2011-10-18 13:19:29 -07:00
|
|
|
const double SystemView::PICK_OBJECT_RECT_SIZE = 12.0;
|
2015-09-28 14:08:48 -07:00
|
|
|
const Uint16 SystemView::N_VERTICES_MAX = 100;
|
2019-01-02 08:59:07 -08:00
|
|
|
static const float MIN_ZOOM = 1e-30f; // Just to avoid having 0
|
2012-04-10 09:06:48 -07:00
|
|
|
static const float MAX_ZOOM = 1e30f;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
static const float ZOOM_IN_SPEED = 3;
|
|
|
|
static const float ZOOM_OUT_SPEED = 3;
|
2019-01-02 08:59:07 -08:00
|
|
|
static const float WHEEL_SENSITIVITY = .1f; // Should be a variable in user settings.
|
2015-11-17 12:57:10 -08:00
|
|
|
static const double DEFAULT_VIEW_DISTANCE = 10.0;
|
2020-04-04 01:16:58 -07:00
|
|
|
static const int MAX_TRANSITION_FRAMES = 60;
|
2014-07-23 10:47:47 -07:00
|
|
|
|
Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.
Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.
Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.
Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().
The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.
I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.
Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-04-18 14:58:00 -07:00
|
|
|
void SystemView::InputBindings::RegisterBindings()
|
|
|
|
{
|
|
|
|
mapViewPitch = AddAxis("BindMapViewPitch");
|
|
|
|
mapViewYaw = AddAxis("BindMapViewYaw");
|
|
|
|
mapViewZoom = AddAxis("BindMapViewZoom");
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
SystemView::SystemView(Game *game) :
|
2020-11-22 16:15:30 -08:00
|
|
|
PiGuiView("system-view"),
|
Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.
Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.
Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.
Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().
The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.
I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.
Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-04-18 14:58:00 -07:00
|
|
|
m_input(Pi::input),
|
2019-08-21 09:34:40 -07:00
|
|
|
m_game(game),
|
2020-04-04 01:16:58 -07:00
|
|
|
m_showL4L5(LAG_OFF),
|
2020-04-24 15:33:07 -07:00
|
|
|
m_shipDrawing(OFF),
|
|
|
|
m_gridDrawing(GridDrawing::OFF),
|
2020-04-04 01:16:58 -07:00
|
|
|
m_trans(0.0),
|
|
|
|
m_transTo(0.0)
|
2008-06-24 03:17:31 -07:00
|
|
|
{
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_rot_y = 0;
|
|
|
|
m_rot_x = 50;
|
|
|
|
m_zoom = 1.0f / float(AU);
|
2008-06-24 03:17:31 -07:00
|
|
|
SetTransparency(true);
|
|
|
|
|
Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.
Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.
Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.
Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().
The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.
I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.
Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-04-18 14:58:00 -07:00
|
|
|
m_input.RegisterBindings();
|
|
|
|
|
2014-01-30 18:22:52 -08:00
|
|
|
Graphics::RenderStateDesc rsd;
|
|
|
|
m_lineState = Pi::renderer->CreateRenderState(rsd); //m_renderer not set yet
|
|
|
|
|
2013-02-22 22:47:08 -08:00
|
|
|
m_realtime = true;
|
2014-01-18 10:51:22 -08:00
|
|
|
m_unexplored = true;
|
2013-02-22 22:47:08 -08:00
|
|
|
|
2013-09-24 00:50:41 -07:00
|
|
|
m_onMouseWheelCon =
|
2020-03-25 21:32:52 -07:00
|
|
|
Pi::input->onMouseWheel.connect(sigc::mem_fun(this, &SystemView::MouseWheel));
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2008-06-24 03:17:31 -07:00
|
|
|
ResetViewpoint();
|
2014-07-23 10:47:47 -07:00
|
|
|
|
2014-08-07 00:36:04 -07:00
|
|
|
RefreshShips();
|
2014-07-23 10:47:47 -07:00
|
|
|
m_planner = Pi::planner;
|
2015-09-28 14:08:48 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
m_orbitVts.reset(new vector3f[N_VERTICES_MAX]);
|
|
|
|
m_orbitColors.reset(new Color[N_VERTICES_MAX]);
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
SystemView::~SystemView()
|
|
|
|
{
|
2014-08-07 00:36:04 -07:00
|
|
|
m_contacts.clear();
|
2013-09-24 00:50:41 -07:00
|
|
|
m_onMouseWheelCon.disconnect();
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
void SystemView::AccelerateTime(float step)
|
2008-06-24 03:17:31 -07:00
|
|
|
{
|
2013-02-22 22:47:08 -08:00
|
|
|
m_realtime = false;
|
2008-06-24 03:17:31 -07:00
|
|
|
m_timeStep = step;
|
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
void SystemView::SetRealTime()
|
2013-02-22 22:09:43 -08:00
|
|
|
{
|
2013-02-22 22:47:08 -08:00
|
|
|
m_realtime = true;
|
2013-02-22 22:09:43 -08:00
|
|
|
}
|
|
|
|
|
2008-06-24 03:17:31 -07:00
|
|
|
void SystemView::ResetViewpoint()
|
|
|
|
{
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_selectedObject.type = Projectable::NONE;
|
|
|
|
m_rot_y_to = 0;
|
|
|
|
m_rot_x_to = 50;
|
|
|
|
m_zoomTo = 1.0f / float(AU);
|
2008-06-24 03:17:31 -07:00
|
|
|
m_timeStep = 1.0f;
|
2014-09-15 11:12:15 -07:00
|
|
|
m_time = m_game->GetTime();
|
2021-01-19 12:00:24 -08:00
|
|
|
m_transTo *= 0.0;
|
2020-04-04 01:16:58 -07:00
|
|
|
m_animateTransition = MAX_TRANSITION_FRAMES;
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
template <typename RefType>
|
|
|
|
void SystemView::PutOrbit(Projectable::bases base, RefType *ref, const Orbit *orbit, const vector3d &offset, const Color &color, const double planetRadius, const bool showLagrange)
|
2008-06-24 03:17:31 -07:00
|
|
|
{
|
2020-04-04 01:16:58 -07:00
|
|
|
double ecc = orbit->GetEccentricity();
|
|
|
|
double timeshift = ecc > 0.6 ? 0.0 : 0.5;
|
2015-07-26 15:11:10 -07:00
|
|
|
double maxT = 1.;
|
|
|
|
unsigned short num_vertices = 0;
|
2015-09-28 14:08:48 -07:00
|
|
|
for (unsigned short i = 0; i < N_VERTICES_MAX; ++i) {
|
2020-04-04 01:16:58 -07:00
|
|
|
const double t = (double(i) + timeshift) / double(N_VERTICES_MAX);
|
2015-07-26 15:11:10 -07:00
|
|
|
const vector3d pos = orbit->EvenSpacedPosTrajectory(t);
|
2019-01-02 08:59:07 -08:00
|
|
|
if (pos.Length() < planetRadius) {
|
2015-07-26 15:11:10 -07:00
|
|
|
maxT = t;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-28 14:23:35 -07:00
|
|
|
static const float startTrailPercent = 0.85;
|
2018-01-10 08:58:08 -08:00
|
|
|
static const float fadedColorParameter = 0.8;
|
2015-09-20 04:22:16 -07:00
|
|
|
|
|
|
|
Uint16 fadingColors = 0;
|
2020-04-04 01:16:58 -07:00
|
|
|
const double tMinust0 = GetOrbitTime(m_time, ref);
|
2015-09-28 14:08:48 -07:00
|
|
|
for (unsigned short i = 0; i < N_VERTICES_MAX; ++i) {
|
2020-04-04 01:16:58 -07:00
|
|
|
const double t = (double(i) + timeshift) / double(N_VERTICES_MAX) * maxT;
|
2019-01-02 08:59:07 -08:00
|
|
|
if (fadingColors == 0 && t >= startTrailPercent * maxT)
|
2015-09-20 04:22:16 -07:00
|
|
|
fadingColors = i;
|
2015-11-17 12:57:10 -08:00
|
|
|
const vector3d pos = orbit->EvenSpacedPosTrajectory(t, tMinust0);
|
2020-05-05 05:49:05 -07:00
|
|
|
m_orbitVts[i] = vector3f(offset + pos);
|
2013-03-29 07:59:05 -07:00
|
|
|
++num_vertices;
|
|
|
|
if (pos.Length() < planetRadius)
|
|
|
|
break;
|
|
|
|
}
|
2013-02-14 06:37:54 -08:00
|
|
|
|
2015-11-17 12:57:10 -08:00
|
|
|
const Color fadedColor = color * fadedColorParameter;
|
2015-09-28 14:08:48 -07:00
|
|
|
std::fill_n(m_orbitColors.get(), num_vertices, fadedColor);
|
2015-09-28 14:23:35 -07:00
|
|
|
const Uint16 trailLength = num_vertices - fadingColors;
|
2015-09-20 04:22:16 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
for (Uint16 currentColor = 0; currentColor < trailLength; ++currentColor) {
|
2015-09-20 04:22:16 -07:00
|
|
|
float scalingParameter = fadedColorParameter + static_cast<float>(currentColor) / trailLength * (1.f - fadedColorParameter);
|
2015-09-28 14:08:48 -07:00
|
|
|
m_orbitColors[currentColor + fadingColors] = color * scalingParameter;
|
2015-09-20 04:22:16 -07:00
|
|
|
}
|
|
|
|
|
2013-03-29 07:59:05 -07:00
|
|
|
if (num_vertices > 1) {
|
2015-09-28 14:08:48 -07:00
|
|
|
m_orbits.SetData(num_vertices, m_orbitVts.get(), m_orbitColors.get());
|
2015-09-20 04:22:16 -07:00
|
|
|
|
2020-04-04 01:16:58 -07:00
|
|
|
//close the loop for thin ellipses
|
|
|
|
if (maxT < 1. || ecc > 1.0 || ecc < 0.6) {
|
2015-01-02 14:43:26 -08:00
|
|
|
m_orbits.Draw(m_renderer, m_lineState, LINE_STRIP);
|
|
|
|
} else {
|
|
|
|
m_orbits.Draw(m_renderer, m_lineState, LINE_LOOP);
|
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
2014-08-18 05:53:10 -07:00
|
|
|
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<RefType>(Projectable::PERIAPSIS, base, ref, offset + orbit->Perigeum());
|
|
|
|
AddProjected<RefType>(Projectable::APOAPSIS, base, ref, offset + orbit->Apogeum());
|
2015-11-17 12:57:10 -08:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
if (showLagrange && m_showL4L5 != LAG_OFF) {
|
2015-11-17 12:57:10 -08:00
|
|
|
const vector3d posL4 = orbit->EvenSpacedPosTrajectory((1.0 / 360.0) * 60.0, tMinust0);
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<RefType>(Projectable::L4, base, ref, offset + posL4);
|
2015-11-17 12:57:10 -08:00
|
|
|
|
|
|
|
const vector3d posL5 = orbit->EvenSpacedPosTrajectory((1.0 / 360.0) * 300.0, tMinust0);
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<RefType>(Projectable::L5, base, ref, offset + posL5);
|
2011-09-14 13:13:53 -07:00
|
|
|
}
|
2014-08-07 03:04:46 -07:00
|
|
|
}
|
|
|
|
|
2020-12-08 01:37:43 -08:00
|
|
|
// returns the position of the ground spaceport relative to the center of the planet at the specified time
|
|
|
|
static vector3d position_of_surface_starport_relative_to_parent(const SystemBody *starport, double time)
|
|
|
|
{
|
|
|
|
const SystemBody *parent = starport->GetParent();
|
|
|
|
// planet axis tilt
|
|
|
|
return matrix3x3d::RotateX(parent->GetAxialTilt()) *
|
|
|
|
// the angle the planet has turned since the beginning of time
|
|
|
|
matrix3x3d::RotateY(-2 * M_PI / parent->GetRotationPeriod() * time + parent->GetRotationPhaseAtStart()) *
|
|
|
|
// the original coordinates of the starport are saved as a 3x3 matrix,
|
|
|
|
starport->GetOrbit().GetPlane() *
|
|
|
|
// to get the direction to the station, you need to multiply them by 0.0, 1.0, 0.0
|
|
|
|
vector3d(0.0, 1.0, 0.0) *
|
|
|
|
// we need the distance to the center of the planet
|
|
|
|
(Pi::game->IsNormalSpace() && Pi::game->GetSpace()->GetStarSystem()->GetPath().IsSameSystem(Pi::game->GetSectorView()->GetSelected()) ?
|
|
|
|
// if we look at the current system, the relief is known, we take the height from the physical body
|
|
|
|
Pi::game->GetSpace()->FindBodyForPath(&(starport->GetPath()))->GetPosition().Length() :
|
|
|
|
// if the remote system - take the radius of the planet
|
|
|
|
parent->GetRadius());
|
|
|
|
}
|
|
|
|
|
2013-03-29 07:59:47 -07:00
|
|
|
void SystemView::PutBody(const SystemBody *b, const vector3d &offset, const matrix4x4f &trans)
|
2008-06-24 03:17:31 -07:00
|
|
|
{
|
2017-03-05 05:15:55 -08:00
|
|
|
if (b->GetType() == SystemBody::TYPE_STARPORT_SURFACE)
|
2015-11-15 13:22:56 -08:00
|
|
|
return;
|
2012-08-04 15:07:05 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
if (b->GetType() != SystemBody::TYPE_GRAVPOINT) {
|
|
|
|
if (!m_bodyIcon) {
|
2014-01-26 17:26:44 -08:00
|
|
|
Graphics::RenderStateDesc rsd;
|
|
|
|
auto solidState = m_renderer->CreateRenderState(rsd);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_bodyIcon.reset(new Graphics::Drawables::Disk(m_renderer, solidState, svColor[SYSTEMBODY], 1.0f));
|
2009-10-18 09:12:51 -07:00
|
|
|
}
|
2012-08-04 15:07:05 -07:00
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
const double radius = b->GetRadius();
|
2012-08-04 15:07:05 -07:00
|
|
|
|
|
|
|
matrix4x4f invRot = trans;
|
|
|
|
invRot.ClearToRotOnly();
|
2020-05-05 05:49:05 -07:00
|
|
|
invRot.Renormalize();
|
2014-10-07 06:04:18 -07:00
|
|
|
invRot = invRot.Inverse();
|
2012-08-04 15:07:05 -07:00
|
|
|
|
|
|
|
matrix4x4f bodyTrans = trans;
|
|
|
|
bodyTrans.Translate(vector3f(offset));
|
|
|
|
bodyTrans.Scale(radius);
|
|
|
|
m_renderer->SetTransform(bodyTrans * invRot);
|
|
|
|
m_bodyIcon->Draw(m_renderer);
|
|
|
|
|
|
|
|
m_renderer->SetTransform(trans);
|
2008-08-12 09:38:23 -07:00
|
|
|
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<const SystemBody>(Projectable::OBJECT, Projectable::SYSTEMBODY, b, offset);
|
2008-08-12 09:38:23 -07:00
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2015-11-17 12:57:10 -08:00
|
|
|
// display all child bodies and their orbits
|
2019-01-02 08:59:07 -08:00
|
|
|
if (b->HasChildren()) {
|
|
|
|
for (const SystemBody *kid : b->GetChildren()) {
|
2020-12-08 01:37:43 -08:00
|
|
|
if (kid->GetType() == SystemBody::TYPE_STARPORT_SURFACE) {
|
|
|
|
AddProjected<const SystemBody>(Projectable::OBJECT, Projectable::SYSTEMBODY, kid, position_of_surface_starport_relative_to_parent(kid, m_time) + offset);
|
2015-11-15 13:22:56 -08:00
|
|
|
continue;
|
2020-12-08 01:37:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_zero_general(kid->GetOrbit().GetSemiMajorAxis())) continue;
|
2015-11-15 13:22:56 -08:00
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
const double axisZoom = kid->GetOrbit().GetSemiMajorAxis();
|
2020-04-04 01:16:58 -07:00
|
|
|
//semimajor axis radius should be at least 1% of screen width to show the orbit
|
|
|
|
if (ProjectedSize(axisZoom, offset) > 0.01) {
|
2015-11-17 12:57:10 -08:00
|
|
|
const SystemBody::BodySuperType bst = kid->GetSuperType();
|
|
|
|
const bool showLagrange = (bst == SystemBody::SUPERTYPE_ROCKY_PLANET || bst == SystemBody::SUPERTYPE_GAS_GIANT);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
PutOrbit<const SystemBody>(Projectable::SYSTEMBODY, kid, &(kid->GetOrbit()), offset, svColor[SYSTEMBODY_ORBIT], 0.0, showLagrange);
|
2013-03-29 07:59:47 -07:00
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2013-03-29 07:59:47 -07:00
|
|
|
// not using current time yet
|
2020-05-05 05:49:05 -07:00
|
|
|
const vector3d pos = kid->GetOrbit().OrbitalPosAtTime(m_time);
|
2014-02-22 08:06:23 -08:00
|
|
|
PutBody(kid, offset + pos, trans);
|
2013-03-29 07:59:47 -07:00
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
void SystemView::GetTransformTo(const SystemBody *b, vector3d &pos)
|
2011-10-18 13:19:29 -07:00
|
|
|
{
|
2020-12-08 01:37:43 -08:00
|
|
|
const SystemBody *parent = b->GetParent();
|
|
|
|
if (parent) {
|
|
|
|
GetTransformTo(parent, pos);
|
|
|
|
if (b->GetType() == SystemBody::TYPE_STARPORT_SURFACE)
|
|
|
|
pos -= position_of_surface_starport_relative_to_parent(b, m_time);
|
|
|
|
else
|
|
|
|
pos -= b->GetOrbit().OrbitalPosAtTime(m_time);
|
2011-10-18 13:19:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
void SystemView::GetTransformTo(Projectable &p, vector3d &pos)
|
2011-10-18 13:19:29 -07:00
|
|
|
{
|
2021-01-19 12:00:24 -08:00
|
|
|
if (m_selectedObject.type == Projectable::NONE) {
|
|
|
|
// notning selected
|
|
|
|
pos *= 0.0;
|
|
|
|
return;
|
|
|
|
}
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
// accept only real objects (no orbit icons or lagrange points)
|
|
|
|
assert(p.type == Projectable::OBJECT);
|
|
|
|
pos = vector3d(0., 0., 0.);
|
|
|
|
if (p.base == Projectable::SYSTEMBODY)
|
|
|
|
GetTransformTo(p.ref.sbody, pos);
|
2020-11-11 16:33:04 -08:00
|
|
|
else if (p.ref.body->GetType() == ObjectType::SHIP || p.ref.body->GetType() == ObjectType::PLAYER) {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
const Ship *s = static_cast<const Ship *>(p.ref.body);
|
|
|
|
CalculateShipPositionAtTime(s, s->ComputeOrbit(), m_time, pos);
|
|
|
|
pos = -pos;
|
|
|
|
// sometimes ships can dissapear from world (i.e. docking / undocking)
|
|
|
|
if (std::isnan(pos.x)) { // failsafe: calculate parent systembody instead
|
|
|
|
pos = vector3d(0., 0., 0.);
|
|
|
|
GetTransformTo(Frame::GetFrame(Frame::GetFrame(Pi::player->GetFrame())->GetNonRotFrame())->GetSystemBody(), pos);
|
|
|
|
}
|
2011-10-18 13:19:29 -07:00
|
|
|
}
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
}
|
2011-10-18 13:19:29 -07:00
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
void SystemView::CalculateShipPositionAtTime(const Ship *s, Orbit o, double t, vector3d &pos)
|
|
|
|
{
|
|
|
|
pos = vector3d(0., 0., 0.);
|
|
|
|
FrameId shipFrameId = s->GetFrame();
|
|
|
|
FrameId shipNonRotFrameId = Frame::GetFrame(shipFrameId)->GetNonRotFrame();
|
2021-01-19 12:00:24 -08:00
|
|
|
// if the ship is in a rotating frame, we will rotate it with the frame
|
|
|
|
if (Frame::GetFrame(shipFrameId)->IsRotFrame()) {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
vector3d rpos(0.0);
|
2021-01-19 12:00:24 -08:00
|
|
|
Frame *rotframe = Frame::GetFrame(shipFrameId);
|
|
|
|
if (t == m_game->GetTime()) {
|
|
|
|
pos = s->GetPositionRelTo(m_game->GetSpace()->GetRootFrame());
|
|
|
|
return;
|
|
|
|
} else
|
|
|
|
rpos = s->GetPositionRelTo(shipNonRotFrameId) * rotframe->GetOrient() * matrix3x3d::RotateY(rotframe->GetAngSpeed() * (t - m_game->GetTime())) * rotframe->GetOrient().Transpose();
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
vector3d fpos(0.0);
|
|
|
|
CalculateFramePositionAtTime(shipNonRotFrameId, t, fpos);
|
|
|
|
pos += fpos + rpos;
|
|
|
|
} else {
|
|
|
|
vector3d fpos(0.0);
|
|
|
|
CalculateFramePositionAtTime(shipNonRotFrameId, t, fpos);
|
|
|
|
pos += (fpos + o.OrbitalPosAtTime(t - m_game->GetTime()));
|
|
|
|
}
|
2011-10-18 13:19:29 -07:00
|
|
|
}
|
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
//frame must be nonrotating
|
|
|
|
void SystemView::CalculateFramePositionAtTime(FrameId frameId, double t, vector3d &pos)
|
2008-06-24 03:17:31 -07:00
|
|
|
{
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
if (frameId == m_game->GetSpace()->GetRootFrame())
|
|
|
|
pos = vector3d(0., 0., 0.);
|
|
|
|
else {
|
|
|
|
Frame *frame = Frame::GetFrame(frameId);
|
|
|
|
CalculateFramePositionAtTime(frame->GetParent(), t, pos);
|
|
|
|
pos += frame->GetSystemBody()->GetOrbit().OrbitalPosAtTime(t);
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::Draw3D()
|
|
|
|
{
|
2013-11-10 03:26:50 -08:00
|
|
|
PROFILE_SCOPED()
|
2012-02-13 07:37:51 -08:00
|
|
|
m_renderer->ClearScreen();
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_projected.clear();
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2014-09-15 11:27:49 -07:00
|
|
|
SystemPath path = m_game->GetSectorView()->GetSelected().SystemOnly();
|
2008-06-24 03:17:31 -07:00
|
|
|
if (m_system) {
|
2014-01-18 10:51:22 -08:00
|
|
|
if (m_system->GetUnexplored() != m_unexplored || !m_system->GetPath().IsSameSystem(path)) {
|
2011-11-14 21:56:55 -08:00
|
|
|
m_system.Reset();
|
2008-06-24 03:17:31 -07:00
|
|
|
ResetViewpoint();
|
|
|
|
}
|
|
|
|
}
|
2013-04-01 13:27:00 -07:00
|
|
|
|
2013-02-22 22:47:08 -08:00
|
|
|
if (m_realtime) {
|
2014-09-15 11:12:15 -07:00
|
|
|
m_time = m_game->GetTime();
|
2019-01-02 08:59:07 -08:00
|
|
|
} else {
|
|
|
|
m_time += m_timeStep * Pi::GetFrameTime();
|
2013-02-22 22:47:08 -08:00
|
|
|
}
|
2019-01-02 08:59:07 -08:00
|
|
|
std::string t = Lang::TIME_POINT + format_date(m_time);
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2014-01-18 10:51:22 -08:00
|
|
|
if (!m_system) {
|
|
|
|
m_system = m_game->GetGalaxy()->GetStarSystem(path);
|
|
|
|
m_unexplored = m_system->GetUnexplored();
|
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2020-12-10 14:56:22 -08:00
|
|
|
// Set up the perspective projection for the background stars
|
|
|
|
m_renderer->SetPerspectiveProjection(CAMERA_FOV, m_renderer->GetDisplayAspect(), 1.f, 1500.f);
|
|
|
|
|
|
|
|
matrix4x4d trans2bg = matrix4x4d::Identity();
|
|
|
|
trans2bg.RotateX(DEG2RAD(-m_rot_x));
|
|
|
|
trans2bg.RotateY(DEG2RAD(-m_rot_y));
|
|
|
|
auto *background = m_game->GetSpace()->GetBackground();
|
|
|
|
// Background is rotated around (0,0,0) and drawn
|
|
|
|
background->SetIntensity(0.6);
|
2021-01-16 06:11:29 -08:00
|
|
|
if (!m_game->IsNormalSpace() || !m_game->GetSpace()->GetStarSystem()->GetPath().IsSameSystem(path)) {
|
2020-12-10 14:56:22 -08:00
|
|
|
Uint32 cachedFlags = background->GetDrawFlags();
|
|
|
|
background->SetDrawFlags(Background::Container::DRAW_SKYBOX);
|
|
|
|
background->Draw(trans2bg);
|
|
|
|
background->SetDrawFlags(cachedFlags);
|
|
|
|
} else {
|
|
|
|
background->Draw(trans2bg);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_renderer->ClearDepthBuffer();
|
|
|
|
|
|
|
|
// We need to adjust the "far" cutoff plane, so that at high magnifications you can see
|
|
|
|
// distant objects in the background.
|
|
|
|
m_renderer->SetPerspectiveProjection(CAMERA_FOV, m_renderer->GetDisplayAspect(), 1.f, 1000.f * m_zoom * float(AU) + DEFAULT_VIEW_DISTANCE * 2);
|
|
|
|
//TODO add reserve
|
|
|
|
|
2020-06-26 10:43:38 -07:00
|
|
|
// The matrix is shifted from the (0,0,0) by DEFAULT_VIEW_DISTANCE
|
|
|
|
// and then rotated (around 0,0,0) and scaled by m_zoom, shift doesn't scale.
|
|
|
|
// m_zoom default value is 1/AU.
|
|
|
|
// { src/gameconsts.h:static const double AU = 149598000000.0; // m }
|
|
|
|
// The coordinates of the objects are given in meters; they are multiplied by m_zoom,
|
|
|
|
// therefore dy default, 1.0 AU (in meters) in the coordinate turns into 1.0 in camera space.
|
|
|
|
// Since the *shift doesn't scale*, it always equals to DEFAULT_VIEW_DISTANCE,
|
|
|
|
// in camera space.
|
|
|
|
// So, the "apparent" view distance, is DEFAULT_VIEW_DISTANCE / m_zoom * AU (AU)
|
|
|
|
// Therefore the default "apparent" view distance is DEFAULT_VIEW_DISTANCE, in AU
|
|
|
|
// When we change m_zoom, we actually change the "apparent" view distance, because
|
|
|
|
// the coordinates of the objects are scaled, but the shift is not.
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_cameraSpace = matrix4x4f::Identity();
|
|
|
|
m_cameraSpace.Translate(0, 0, -DEFAULT_VIEW_DISTANCE);
|
|
|
|
m_cameraSpace.Rotate(DEG2RAD(m_rot_x), 1, 0, 0);
|
|
|
|
m_cameraSpace.Rotate(DEG2RAD(m_rot_y), 0, 1, 0);
|
2020-05-05 05:49:05 -07:00
|
|
|
m_cameraSpace.Scale(m_zoom);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_renderer->SetTransform(m_cameraSpace);
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2020-04-04 01:16:58 -07:00
|
|
|
// smooth transition animation
|
|
|
|
if (m_animateTransition) {
|
2021-01-19 12:00:24 -08:00
|
|
|
// since the object being approached can move, we need to compensate for its movement
|
|
|
|
// making an imprint of the old value (from previous frame)
|
|
|
|
m_trans -= m_transTo;
|
|
|
|
// calculate the new value
|
|
|
|
GetTransformTo(m_selectedObject, m_transTo);
|
|
|
|
// now the difference between the new and the old value is added to m_trans
|
|
|
|
m_trans += m_transTo;
|
2020-04-04 01:16:58 -07:00
|
|
|
const float ft = Pi::GetFrameTime();
|
|
|
|
m_animateTransition--;
|
|
|
|
AnimationCurves::Approach(m_trans.x, m_transTo.x, ft);
|
|
|
|
AnimationCurves::Approach(m_trans.y, m_transTo.y, ft);
|
|
|
|
AnimationCurves::Approach(m_trans.z, m_transTo.z, ft);
|
|
|
|
} else {
|
2021-01-19 12:00:24 -08:00
|
|
|
GetTransformTo(m_selectedObject, m_trans);
|
2020-04-04 01:16:58 -07:00
|
|
|
}
|
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
vector3d pos = m_trans;
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2014-10-14 12:43:09 -07:00
|
|
|
// glLineWidth(2);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
if (!m_system->GetUnexplored() && m_system->GetRootBody()) {
|
|
|
|
// all systembodies draws here
|
|
|
|
PutBody(m_system->GetRootBody().Get(), pos, m_cameraSpace);
|
2011-10-18 13:19:29 -07:00
|
|
|
}
|
2014-10-14 12:43:09 -07:00
|
|
|
// glLineWidth(1);
|
2013-01-08 22:13:14 -08:00
|
|
|
|
2020-09-06 01:05:23 -07:00
|
|
|
if (m_game->IsNormalSpace() && m_game->GetSpace()->GetStarSystem()->GetPath().IsSameSystem(m_game->GetSectorView()->GetSelected())) {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
// draw ships
|
|
|
|
if (m_shipDrawing != OFF) {
|
|
|
|
DrawShips(m_time, pos);
|
|
|
|
}
|
|
|
|
// draw player and planner
|
|
|
|
vector3d ppos(0.0);
|
|
|
|
Orbit playerOrbit = Pi::player->ComputeOrbit();
|
|
|
|
Body *PlayerBody = static_cast<Body *>(Pi::player);
|
|
|
|
FrameId playerNonRotFrameId = Frame::GetFrame(PlayerBody->GetFrame())->GetNonRotFrame();
|
|
|
|
Frame *playerNonRotFrame = Frame::GetFrame(playerNonRotFrameId);
|
|
|
|
SystemBody *playerAround = playerNonRotFrame->GetSystemBody();
|
|
|
|
CalculateShipPositionAtTime(static_cast<Ship *>(Pi::player), playerOrbit, m_time, ppos);
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<Body>(Projectable::OBJECT, Projectable::PLAYER, PlayerBody, ppos + pos);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
|
|
|
|
vector3d offset(0.0);
|
|
|
|
CalculateFramePositionAtTime(playerNonRotFrameId, m_time, offset);
|
2020-05-05 05:49:05 -07:00
|
|
|
offset = offset + pos;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
|
|
|
|
if (Pi::player->GetFlightState() == Ship::FlightState::FLYING) {
|
|
|
|
PutOrbit<Body>(Projectable::PLAYER, PlayerBody, &playerOrbit, offset, svColor[PLAYER_ORBIT], playerAround->GetRadius());
|
|
|
|
const double plannerStartTime = m_planner->GetStartTime();
|
|
|
|
if (!m_planner->GetPosition().ExactlyEqual(vector3d(0, 0, 0))) {
|
|
|
|
Orbit plannedOrbit = Orbit::FromBodyState(m_planner->GetPosition(),
|
|
|
|
m_planner->GetVel(),
|
|
|
|
playerAround->GetMass());
|
|
|
|
PutOrbit<Body>(Projectable::PLANNER, PlayerBody, &plannedOrbit, offset, svColor[PLANNER_ORBIT], playerAround->GetRadius());
|
|
|
|
if (std::fabs(m_time - m_game->GetTime()) > 1. && (m_time - plannerStartTime) > 0.)
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<Body>(Projectable::OBJECT, Projectable::PLANNER, PlayerBody, offset + plannedOrbit.OrbitalPosAtTime(m_time - plannerStartTime));
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
else
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<Body>(Projectable::OBJECT, Projectable::PLANNER, PlayerBody, offset + m_planner->GetPosition());
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
}
|
|
|
|
}
|
2014-08-07 00:36:04 -07:00
|
|
|
}
|
|
|
|
|
2019-08-21 09:34:40 -07:00
|
|
|
if (m_gridDrawing != GridDrawing::OFF) {
|
|
|
|
DrawGrid();
|
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::Update()
|
|
|
|
{
|
2008-06-28 13:00:50 -07:00
|
|
|
const float ft = Pi::GetFrameTime();
|
2012-04-10 09:06:48 -07:00
|
|
|
// TODO: add "true" lower/upper bounds to m_zoomTo / m_zoom
|
|
|
|
m_zoomTo = Clamp(m_zoomTo, MIN_ZOOM, MAX_ZOOM);
|
|
|
|
m_zoom = Clamp(m_zoom, MIN_ZOOM, MAX_ZOOM);
|
2018-10-20 08:18:06 -07:00
|
|
|
// Since m_zoom changes over multiple orders of magnitude, any fixed linear factor will not be appropriate
|
|
|
|
// at some of them.
|
|
|
|
AnimationCurves::Approach(m_zoom, m_zoomTo, ft, 10.f, m_zoomTo / 60.f);
|
|
|
|
|
|
|
|
AnimationCurves::Approach(m_rot_x, m_rot_x_to, ft);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
AnimationCurves::Approach(m_rot_y, m_rot_y_to, ft);
|
|
|
|
|
|
|
|
// to capture mouse when button was pressed and release when released
|
|
|
|
if (Pi::input->MouseButtonState(SDL_BUTTON_MIDDLE) != m_rotateWithMouseButton) {
|
|
|
|
m_rotateWithMouseButton = !m_rotateWithMouseButton;
|
|
|
|
Pi::input->SetCapturingMouse(m_rotateWithMouseButton);
|
|
|
|
}
|
2012-04-10 09:06:48 -07:00
|
|
|
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
if (m_rotateWithMouseButton || m_rotateView) {
|
2008-06-24 03:17:31 -07:00
|
|
|
int motion[2];
|
2020-03-25 21:32:52 -07:00
|
|
|
Pi::input->GetMouseMotion(motion);
|
2019-01-02 08:59:07 -08:00
|
|
|
m_rot_x_to += motion[1] * 20 * ft;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_rot_y_to += motion[0] * 20 * ft;
|
2020-05-05 05:49:05 -07:00
|
|
|
} else if (m_zoomView) {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
Pi::input->SetCapturingMouse(true);
|
|
|
|
int motion[2];
|
|
|
|
Pi::input->GetMouseMotion(motion);
|
|
|
|
m_zoomTo *= pow(ZOOM_IN_SPEED * 0.003 + 1, -motion[1]);
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
2013-01-08 22:13:14 -08:00
|
|
|
|
2020-04-06 12:37:53 -07:00
|
|
|
// camera control signals from devices, sent to the SectorView
|
Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.
Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.
Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.
Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().
The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.
I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.
Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-04-18 14:58:00 -07:00
|
|
|
if (m_input.mapViewZoom->IsActive())
|
|
|
|
m_zoomTo *= pow(ZOOM_IN_SPEED * 0.006 + 1, m_input.mapViewZoom->GetValue());
|
|
|
|
if (m_input.mapViewYaw->IsActive())
|
|
|
|
m_rot_y_to += m_input.mapViewYaw->GetValue() * ft * 60;
|
|
|
|
if (m_input.mapViewPitch->IsActive())
|
|
|
|
m_rot_x_to += m_input.mapViewPitch->GetValue() * ft * 60;
|
2020-04-06 12:37:53 -07:00
|
|
|
|
|
|
|
m_rot_x_to = Clamp(m_rot_x_to, -80.0f, 80.0f);
|
2020-12-03 12:36:47 -08:00
|
|
|
|
|
|
|
if (m_shipDrawing != OFF) {
|
|
|
|
RefreshShips();
|
|
|
|
// if we are attached to the ship, check if we not deleted it in the previous frame
|
|
|
|
if (m_selectedObject.type != Projectable::NONE && m_selectedObject.base == Projectable::SHIP) {
|
|
|
|
auto bs = m_game->GetSpace()->GetBodies();
|
|
|
|
if (std::find(bs.begin(), bs.end(), m_selectedObject.ref.body) == bs.end())
|
|
|
|
ResetViewpoint();
|
|
|
|
}
|
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
}
|
2010-03-13 10:33:15 -08:00
|
|
|
|
2013-09-24 00:50:41 -07:00
|
|
|
void SystemView::MouseWheel(bool up)
|
2010-03-13 10:33:15 -08:00
|
|
|
{
|
2012-01-19 18:43:29 -08:00
|
|
|
if (this == Pi::GetView()) {
|
2013-09-24 00:50:41 -07:00
|
|
|
if (!up)
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_zoomTo *= 1 / ((ZOOM_OUT_SPEED - 1) * WHEEL_SENSITIVITY + 1) / Pi::GetMoveSpeedShiftModifier();
|
2013-09-24 00:50:41 -07:00
|
|
|
else
|
2019-01-02 08:59:07 -08:00
|
|
|
m_zoomTo *= ((ZOOM_IN_SPEED - 1) * WHEEL_SENSITIVITY + 1) * Pi::GetMoveSpeedShiftModifier();
|
2012-01-19 18:43:29 -08:00
|
|
|
}
|
2010-03-13 10:33:15 -08:00
|
|
|
}
|
2014-08-07 00:36:04 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void SystemView::RefreshShips(void)
|
|
|
|
{
|
2014-08-07 00:36:04 -07:00
|
|
|
m_contacts.clear();
|
2014-09-15 11:12:15 -07:00
|
|
|
auto bs = m_game->GetSpace()->GetBodies();
|
2019-01-02 08:59:07 -08:00
|
|
|
for (auto s = bs.begin(); s != bs.end(); s++) {
|
|
|
|
if ((*s) != Pi::player &&
|
2020-11-11 16:33:04 -08:00
|
|
|
(*s)->GetType() == ObjectType::SHIP) {
|
2014-08-07 00:36:04 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
const auto c = static_cast<Ship *>(*s);
|
2014-08-07 00:36:04 -07:00
|
|
|
m_contacts.push_back(std::make_pair(c, c->ComputeOrbit()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void SystemView::DrawShips(const double t, const vector3d &offset)
|
|
|
|
{
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
// offset - translate vector to selected object, scaled to camera scale
|
2019-01-02 08:59:07 -08:00
|
|
|
for (auto s = m_contacts.begin(); s != m_contacts.end(); s++) {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
vector3d pos(0.0);
|
|
|
|
CalculateShipPositionAtTime((*s).first, (*s).second, t, pos);
|
2020-05-05 05:49:05 -07:00
|
|
|
pos = pos + offset;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
//draw highlighted orbit for selected ship
|
|
|
|
const bool isSelected = m_selectedObject.type == Projectable::OBJECT && m_selectedObject.base != Projectable::SYSTEMBODY && m_selectedObject.ref.body == (*s).first;
|
2020-10-16 01:13:22 -07:00
|
|
|
AddProjected<Body>(Projectable::OBJECT, Projectable::SHIP, static_cast<Body *>((*s).first), pos);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
if (m_shipDrawing == ORBITS && (*s).first->GetFlightState() == Ship::FlightState::FLYING) {
|
|
|
|
vector3d framepos(0.0);
|
2021-01-19 12:00:24 -08:00
|
|
|
CalculateFramePositionAtTime((*s).first->GetFrame(), m_time, framepos);
|
2020-05-05 05:49:05 -07:00
|
|
|
PutOrbit<Body>(Projectable::SHIP, static_cast<Body *>((*s).first), &(*s).second, offset + framepos, isSelected ? svColor[SELECTED_SHIP_ORBIT] : svColor[SHIP_ORBIT], 0);
|
2018-06-19 04:49:23 -07:00
|
|
|
}
|
2014-08-07 00:36:04 -07:00
|
|
|
}
|
|
|
|
}
|
2019-08-21 09:34:40 -07:00
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
void SystemView::DrawGrid()
|
2019-08-21 09:34:40 -07:00
|
|
|
{
|
2020-05-05 05:49:05 -07:00
|
|
|
|
2019-08-21 09:34:40 -07:00
|
|
|
// calculate lines for this system:
|
|
|
|
double diameter = std::floor(m_system->GetRootBody()->GetMaxChildOrbitalDistance() * 1.2 / AU);
|
|
|
|
m_grid_lines = int(diameter) + 1;
|
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
m_lineVerts.reset(new Graphics::VertexArray(Graphics::ATTRIB_POSITION, m_grid_lines * 4 + (m_gridDrawing == GridDrawing::GRID_AND_LEGS ? m_projected.size() * 2 : 0)));
|
2019-08-21 09:34:40 -07:00
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
float zoom = float(AU);
|
|
|
|
vector3d pos = m_trans;
|
2019-08-21 09:34:40 -07:00
|
|
|
|
|
|
|
for (int i = -m_grid_lines; i < m_grid_lines + 1; i++) {
|
|
|
|
float z = float(i) * zoom;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_lineVerts->Add(vector3f(-m_grid_lines * zoom, 0.0f, z) + vector3f(pos), svColor[GRID]);
|
|
|
|
m_lineVerts->Add(vector3f(+m_grid_lines * zoom, 0.0f, z) + vector3f(pos), svColor[GRID]);
|
2019-08-21 09:34:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = -m_grid_lines; i < m_grid_lines + 1; i++) {
|
|
|
|
float x = float(i) * zoom;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_lineVerts->Add(vector3f(x, 0.0f, -m_grid_lines * zoom) + vector3f(pos), svColor[GRID]);
|
|
|
|
m_lineVerts->Add(vector3f(x, 0.0f, +m_grid_lines * zoom) + vector3f(pos), svColor[GRID]);
|
2019-08-21 09:34:40 -07:00
|
|
|
}
|
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
if (m_gridDrawing == GridDrawing::GRID_AND_LEGS)
|
|
|
|
for (Projectable &p : m_projected) {
|
|
|
|
vector3d offset(p.worldpos);
|
|
|
|
offset.y = m_trans.y;
|
|
|
|
m_lineVerts->Add(vector3f(p.worldpos), svColor[GRID_LEG] * 0.5);
|
|
|
|
m_lineVerts->Add(vector3f(offset), svColor[GRID_LEG] * 0.5);
|
|
|
|
}
|
2019-08-21 09:34:40 -07:00
|
|
|
|
|
|
|
m_lines.SetData(m_lineVerts->GetNumVerts(), &m_lineVerts->position[0], &m_lineVerts->diffuse[0]);
|
|
|
|
m_lines.Draw(Pi::renderer, m_lineState);
|
|
|
|
}
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
|
|
|
|
template <typename T>
|
2020-10-16 01:13:22 -07:00
|
|
|
void SystemView::AddProjected(Projectable::types type, Projectable::bases base, T *ref, const vector3d &worldpos)
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
{
|
2020-10-16 01:13:22 -07:00
|
|
|
vector3d pos = Graphics::ProjectToScreen(m_renderer, worldpos);
|
|
|
|
if (pos.z > 0.0) return; // reject back-projected objects
|
|
|
|
pos.y = m_renderer->GetViewport().h - pos.y;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
|
|
|
|
Projectable p(type, base, ref);
|
2020-10-16 01:13:22 -07:00
|
|
|
p.screenpos = pos;
|
2020-05-05 05:49:05 -07:00
|
|
|
p.worldpos = worldpos;
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_projected.push_back(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::SetVisibility(std::string param)
|
|
|
|
{
|
|
|
|
if (param == "RESET_VIEW")
|
|
|
|
ResetViewpoint();
|
|
|
|
else if (param == "GRID_OFF")
|
|
|
|
m_gridDrawing = GridDrawing::OFF;
|
|
|
|
else if (param == "GRID_ON")
|
|
|
|
m_gridDrawing = GridDrawing::GRID;
|
|
|
|
else if (param == "GRID_AND_LEGS")
|
|
|
|
m_gridDrawing = GridDrawing::GRID_AND_LEGS;
|
|
|
|
else if (param == "LAG_OFF")
|
|
|
|
m_showL4L5 = LAG_OFF;
|
|
|
|
else if (param == "LAG_ICON")
|
|
|
|
m_showL4L5 = LAG_ICON;
|
|
|
|
else if (param == "LAG_ICONTEXT")
|
|
|
|
m_showL4L5 = LAG_ICONTEXT;
|
2020-12-03 12:36:47 -08:00
|
|
|
else if (param == "SHIPS_OFF") {
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_shipDrawing = OFF;
|
2020-12-03 12:36:47 -08:00
|
|
|
// if we are attached to the ship, reset view, since the ship was hidden
|
|
|
|
if (m_selectedObject.type != Projectable::NONE && m_selectedObject.base == Projectable::SHIP)
|
|
|
|
ResetViewpoint();
|
|
|
|
} else if (param == "SHIPS_ON")
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_shipDrawing = BOXES;
|
|
|
|
else if (param == "SHIPS_ORBITS")
|
|
|
|
m_shipDrawing = ORBITS;
|
|
|
|
else
|
|
|
|
Output("Unknown visibility: %s\n", param.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::SetZoomMode(bool enable)
|
|
|
|
{
|
|
|
|
if (enable != m_zoomView) {
|
|
|
|
Pi::input->SetCapturingMouse(enable);
|
|
|
|
m_zoomView = enable;
|
|
|
|
if (m_zoomView) m_rotateView = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-05 05:49:05 -07:00
|
|
|
void SystemView::SetRotateMode(bool enable)
|
|
|
|
{
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
if (enable != m_rotateView) {
|
|
|
|
Pi::input->SetCapturingMouse(enable);
|
|
|
|
m_rotateView = enable;
|
|
|
|
if (m_rotateView) m_zoomView = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Projectable *SystemView::GetSelectedObject()
|
|
|
|
{
|
|
|
|
return &m_selectedObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::SetSelectedObject(Projectable::types type, Projectable::bases base, SystemBody *sb)
|
|
|
|
{
|
|
|
|
m_selectedObject.type = type;
|
|
|
|
m_selectedObject.base = base;
|
|
|
|
m_selectedObject.ref.sbody = sb;
|
2021-01-19 12:00:24 -08:00
|
|
|
// we will immediately determine the coordinates of the selected body so that
|
|
|
|
// there is a correct starting point of the transition animation, otherwise
|
|
|
|
// there may be an unwanted shift in the next frame
|
|
|
|
GetTransformTo(m_selectedObject, m_transTo);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_animateTransition = MAX_TRANSITION_FRAMES;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::SetSelectedObject(Projectable::types type, Projectable::bases base, Body *b)
|
|
|
|
{
|
|
|
|
m_selectedObject.type = type;
|
|
|
|
m_selectedObject.base = base;
|
|
|
|
m_selectedObject.ref.body = b;
|
2021-01-19 12:00:24 -08:00
|
|
|
// we will immediately determine the coordinates of the selected body so that
|
|
|
|
// there is a correct starting point of the transition animation, otherwise
|
|
|
|
// there may be an unwanted shift in the next frame
|
|
|
|
GetTransformTo(m_selectedObject, m_transTo);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
m_animateTransition = MAX_TRANSITION_FRAMES;
|
|
|
|
}
|
|
|
|
|
|
|
|
double SystemView::ProjectedSize(double size, vector3d pos)
|
|
|
|
{
|
2020-08-28 15:31:00 -07:00
|
|
|
matrix4x4d dtrans = matrix4x4d(m_cameraSpace);
|
Move the System Map to PiGUI
The main idea of the interaction of lua side and C++ side is the same as
in the worldview - the C++ View Class builds three-dimensional objects,
some projected points are passed to the lua script, the lua script only
works with screen coordinates.
The difference between the system view and the world view is that not
all objects can have a physical body. If we examine a non-current star
system, we see only system bodies that do not have physical bodies.
Therefore, if for a world view you can simply create an array of
physical bodies, this will not work in a system view.
To solve this problem, struct "Projectable" was created, into which you
can write any point object, system body, ship, Lagrange point,
apocenter, pericenter, etc. Now all these objects can be processed in a
single array.
The names of the types of these objects are recorded in an enum, which
is exported to a enum_table.cpp and read by the script as integers at
the start. I thought it was better to avoid passing strings in such a
hot place in the code. (runs for every object in every frame) Therefore,
type names are written and transmitted as integers.
All colors are now imported from lua: color index names are listed in
the enum, which is exported to the enum_table.cpp. At event
"onGameStart" the lua script reads these names and sends color values to
the class. Now you can change colors at runtime.
* Improvements/fixes: *
- Fix zooming speeds.
- Fix ship's orbits in nonroot frame.
- Remove unused old gui objects.
- Landed ship are now spinning with the planet when rewinding time in a
planner.
- Now you can center the view on any object, including the player’s ship.
- Add right-click context menu to center or set object as target.
Therefore, to rotate the view, set the middle button.
- Add indicators for navigation target and combat target.
* Changes in the files explained *
SystemView.cpp, SystemView.h, system-view-ui.lua, lang/core/en.json
The whole thing, lots of changes. Now the system view draws only the
orbits and the grid. In those places where the icons were drawn, instead
of drawing, they are stored in an array, which is then requested from
the lua.
LuaEngine.cpp
Add a general function that returns the value of an any enum by name
from an enum_table.cpp (for calling from a lua)
Space.cpp
Added a notification for the systemview when the ship is removed from
space, because it can be centered at this time, and an segmentation
fault will occur.
LuaSystemBody.cpp
Added attributes to determine the shape of the icon and set the
navigation target.
enum_table.cpp, enum_table.h
Rescanned enums to pass color settings and object types between Lua and
C++.
LuaGame.cpp
The float does not have enough accuracy to display time up to seconds,
change to double.
icons.svg, themes/default.lua
Add rotate view icon
2020-04-04 00:47:51 -07:00
|
|
|
pos = dtrans * pos; //position in camera space to know distance
|
|
|
|
double result = size / pos.Length() / CAMERA_FOV_RADIANS;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
double SystemView::GetOrbitTime(double t, const SystemBody *b) { return t; }
|
|
|
|
double SystemView::GetOrbitTime(double t, const Body *b) { return t - m_game->GetTime(); }
|
2020-12-15 09:17:06 -08:00
|
|
|
void SystemView::OnSwitchFrom() { m_projected.clear(); } // because ships from the previous system may remain after last update
|