2019-12-31 05:05:16 -08:00
|
|
|
// Copyright © 2008-2020 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
|
|
|
|
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/LuaPiGui.h"
|
|
|
|
|
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"
|
|
|
|
#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"
|
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
|
|
|
|
2015-07-18 15:24:19 -07:00
|
|
|
TransferPlanner::TransferPlanner() :
|
2019-01-02 08:59:07 -08:00
|
|
|
m_position(0., 0., 0.),
|
|
|
|
m_velocity(0., 0., 0.)
|
2015-07-18 15:24:19 -07:00
|
|
|
{
|
2014-07-23 10:47:47 -07:00
|
|
|
m_dvPrograde = 0.0;
|
|
|
|
m_dvNormal = 0.0;
|
|
|
|
m_dvRadial = 0.0;
|
2015-07-19 05:43:11 -07:00
|
|
|
m_startTime = 0.0;
|
2014-07-24 09:54:03 -07:00
|
|
|
m_factor = 1;
|
2014-07-23 10:47:47 -07:00
|
|
|
}
|
|
|
|
|
2015-07-19 09:57:33 -07:00
|
|
|
vector3d TransferPlanner::GetVel() const { return m_velocity + GetOffsetVel(); }
|
2015-07-18 15:24:19 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
vector3d TransferPlanner::GetOffsetVel() const
|
|
|
|
{
|
|
|
|
if (m_position.ExactlyEqual(vector3d(0., 0., 0.)))
|
2015-07-18 15:24:19 -07:00
|
|
|
return vector3d(0., 0., 0.);
|
2014-07-24 23:37:48 -07:00
|
|
|
|
2015-07-19 09:57:33 -07:00
|
|
|
const vector3d pNormal = m_position.Cross(m_velocity);
|
2014-07-23 10:47:47 -07:00
|
|
|
|
2015-07-19 09:57:33 -07:00
|
|
|
return m_dvPrograde * m_velocity.Normalized() +
|
2019-01-02 08:59:07 -08:00
|
|
|
m_dvNormal * pNormal.Normalized() +
|
|
|
|
m_dvRadial * m_position.Normalized();
|
2014-07-23 10:47:47 -07:00
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::AddStartTime(double timeStep)
|
|
|
|
{
|
|
|
|
if (std::fabs(m_startTime) < 1.)
|
2017-03-05 05:15:55 -08:00
|
|
|
m_startTime = Pi::game->GetTime();
|
2015-07-19 09:57:33 -07:00
|
|
|
|
2015-07-27 00:19:48 -07:00
|
|
|
m_startTime += m_factor * timeStep;
|
|
|
|
double deltaT = m_startTime - Pi::game->GetTime();
|
2019-01-02 08:59:07 -08:00
|
|
|
if (deltaT > 0.) {
|
2019-10-07 09:12:28 -07:00
|
|
|
FrameId frameId = Frame::GetFrame(Pi::player->GetFrame())->GetNonRotFrame();
|
|
|
|
Frame *frame = Frame::GetFrame(frameId);
|
|
|
|
Orbit playerOrbit = Orbit::FromBodyState(Pi::player->GetPositionRelTo(frameId), Pi::player->GetVelocityRelTo(frameId), frame->GetSystemBody()->GetMass());
|
2015-07-27 00:19:48 -07:00
|
|
|
|
|
|
|
m_position = playerOrbit.OrbitalPosAtTime(deltaT);
|
|
|
|
m_velocity = playerOrbit.OrbitalVelocityAtTime(frame->GetSystemBody()->GetMass(), deltaT);
|
2019-01-02 08:59:07 -08:00
|
|
|
} else
|
2015-07-27 00:19:48 -07:00
|
|
|
ResetStartTime();
|
2015-07-19 05:43:11 -07:00
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::ResetStartTime()
|
|
|
|
{
|
2015-07-19 05:43:11 -07:00
|
|
|
m_startTime = 0;
|
2019-10-07 09:12:28 -07:00
|
|
|
Frame *frame = Frame::GetFrame(Pi::player->GetFrame());
|
2019-01-02 08:59:07 -08:00
|
|
|
if (!frame || GetOffsetVel().ExactlyEqual(vector3d(0., 0., 0.))) {
|
2015-07-19 05:43:11 -07:00
|
|
|
m_position = vector3d(0., 0., 0.);
|
2019-01-02 08:59:07 -08:00
|
|
|
m_velocity = vector3d(0., 0., 0.);
|
|
|
|
} else {
|
2019-10-07 09:12:28 -07:00
|
|
|
frame = Frame::GetFrame(frame->GetNonRotFrame());
|
|
|
|
m_position = Pi::player->GetPositionRelTo(frame->GetId());
|
|
|
|
m_velocity = Pi::player->GetVelocityRelTo(frame->GetId());
|
2015-07-19 05:43:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
double TransferPlanner::GetStartTime() const
|
|
|
|
{
|
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
|
|
|
return m_startTime < 0.0 ? 0.0 : m_startTime;
|
2015-07-19 05:43:11 -07:00
|
|
|
}
|
|
|
|
|
2015-07-27 00:19:48 -07:00
|
|
|
static std::string formatTime(double t)
|
|
|
|
{
|
|
|
|
std::stringstream formattedTime;
|
|
|
|
formattedTime << std::setprecision(1) << std::fixed;
|
2015-11-09 12:42:18 -08:00
|
|
|
double absT = fabs(t);
|
2019-01-02 08:59:07 -08:00
|
|
|
if (absT < 60.)
|
2015-07-27 00:19:48 -07:00
|
|
|
formattedTime << t << "s";
|
2019-01-02 08:59:07 -08:00
|
|
|
else if (absT < 3600)
|
2015-07-27 00:19:48 -07:00
|
|
|
formattedTime << t / 60. << "m";
|
2019-01-02 08:59:07 -08:00
|
|
|
else if (absT < 86400)
|
2015-07-27 00:19:48 -07:00
|
|
|
formattedTime << t / 3600. << "h";
|
2019-01-02 08:59:07 -08:00
|
|
|
else if (absT < 31536000)
|
2015-07-27 00:19:48 -07:00
|
|
|
formattedTime << t / 86400. << "d";
|
|
|
|
else
|
|
|
|
formattedTime << t / 31536000. << "y";
|
2017-03-05 05:15:55 -08:00
|
|
|
return formattedTime.str();
|
2015-07-27 00:19:48 -07:00
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
std::string TransferPlanner::printDeltaTime()
|
|
|
|
{
|
2015-07-19 05:43:11 -07:00
|
|
|
std::stringstream out;
|
2015-07-27 00:19:48 -07:00
|
|
|
out << std::setw(9);
|
|
|
|
double deltaT = m_startTime - Pi::game->GetTime();
|
2019-01-02 08:59:07 -08:00
|
|
|
if (std::fabs(m_startTime) < 1.)
|
2015-12-06 09:51:40 -08:00
|
|
|
out << Lang::NOW;
|
2015-07-19 05:43:11 -07:00
|
|
|
else
|
2017-03-05 05:15:55 -08:00
|
|
|
out << formatTime(deltaT);
|
2015-07-19 05:43:11 -07:00
|
|
|
|
|
|
|
return out.str();
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::AddDv(BurnDirection d, double dv)
|
|
|
|
{
|
|
|
|
if (m_position.ExactlyEqual(vector3d(0., 0., 0.))) {
|
2019-10-07 09:12:28 -07:00
|
|
|
FrameId frame = Frame::GetFrame(Pi::player->GetFrame())->GetNonRotFrame();
|
2015-07-19 05:43:11 -07:00
|
|
|
m_position = Pi::player->GetPositionRelTo(frame);
|
2015-07-19 09:57:33 -07:00
|
|
|
m_velocity = Pi::player->GetVelocityRelTo(frame);
|
2015-07-27 00:19:48 -07:00
|
|
|
m_startTime = Pi::game->GetTime();
|
2015-07-18 15:24:19 -07:00
|
|
|
}
|
|
|
|
|
2014-07-24 23:37:48 -07:00
|
|
|
switch (d) {
|
|
|
|
case PROGRADE: m_dvPrograde += m_factor * dv; break;
|
2019-01-02 08:59:07 -08:00
|
|
|
case NORMAL: m_dvNormal += m_factor * dv; break;
|
|
|
|
case RADIAL: m_dvRadial += m_factor * dv; break;
|
2014-07-24 23:37:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::ResetDv(BurnDirection d)
|
|
|
|
{
|
2014-07-24 23:37:48 -07:00
|
|
|
switch (d) {
|
|
|
|
case PROGRADE: m_dvPrograde = 0; break;
|
2019-01-02 08:59:07 -08:00
|
|
|
case NORMAL: m_dvNormal = 0; break;
|
|
|
|
case RADIAL: m_dvRadial = 0; break;
|
2014-07-24 23:37:48 -07:00
|
|
|
}
|
2015-07-19 05:43:11 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
if (std::fabs(m_startTime) < 1. &&
|
|
|
|
GetOffsetVel().ExactlyEqual(vector3d(0., 0., 0.))) {
|
2015-07-19 05:43:11 -07:00
|
|
|
m_position = vector3d(0., 0., 0.);
|
2015-07-19 09:57:33 -07:00
|
|
|
m_velocity = vector3d(0., 0., 0.);
|
2015-07-27 00:19:48 -07:00
|
|
|
m_startTime = 0.;
|
2015-07-19 05:43:11 -07:00
|
|
|
}
|
2014-07-24 23:37:48 -07:00
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::ResetDv()
|
|
|
|
{
|
|
|
|
m_dvPrograde = 0;
|
|
|
|
m_dvNormal = 0;
|
|
|
|
m_dvRadial = 0;
|
2015-07-27 00:19:48 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
if (std::fabs(m_startTime) < 1.) {
|
2015-07-27 00:19:48 -07:00
|
|
|
m_position = vector3d(0., 0., 0.);
|
|
|
|
m_velocity = vector3d(0., 0., 0.);
|
|
|
|
m_startTime = 0.;
|
2019-01-02 08:59:07 -08:00
|
|
|
}
|
2015-07-27 00:19: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
|
|
|
double TransferPlanner::GetDv(BurnDirection d)
|
|
|
|
{
|
|
|
|
switch (d) {
|
|
|
|
case PROGRADE: return m_dvPrograde; break;
|
|
|
|
case NORMAL: return m_dvNormal; break;
|
|
|
|
case RADIAL: return m_dvRadial; break;
|
|
|
|
}
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
std::string TransferPlanner::printDv(BurnDirection d)
|
|
|
|
{
|
2014-07-30 00:34:36 -07:00
|
|
|
double dv = 0;
|
2014-07-24 23:37:48 -07:00
|
|
|
char buf[10];
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
switch (d) {
|
2014-07-24 23:37:48 -07:00
|
|
|
case PROGRADE: dv = m_dvPrograde; break;
|
2019-01-02 08:59:07 -08:00
|
|
|
case NORMAL: dv = m_dvNormal; break;
|
|
|
|
case RADIAL: dv = m_dvRadial; break;
|
2014-07-24 23:37:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%6.0fm/s", dv);
|
|
|
|
return std::string(buf);
|
|
|
|
}
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::IncreaseFactor(void)
|
|
|
|
{
|
|
|
|
if (m_factor > 1000) return;
|
2014-07-24 09:54:03 -07:00
|
|
|
m_factor *= m_factorFactor;
|
|
|
|
}
|
|
|
|
void TransferPlanner::ResetFactor(void) { m_factor = 1; }
|
2014-07-24 23:37:48 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::DecreaseFactor(void)
|
|
|
|
{
|
|
|
|
if (m_factor < 0.0002) return;
|
2014-07-24 09:54:03 -07:00
|
|
|
m_factor /= m_factorFactor;
|
|
|
|
}
|
2014-07-23 10:47:47 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
std::string TransferPlanner::printFactor(void)
|
|
|
|
{
|
2017-06-21 23:21:07 -07:00
|
|
|
char buf[16];
|
2015-07-27 00:19:48 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%8gx", 10 * m_factor);
|
2014-07-24 23:37:48 -07:00
|
|
|
return std::string(buf);
|
2014-07-23 10:47:47 -07:00
|
|
|
}
|
|
|
|
|
2015-07-18 15:24:19 -07:00
|
|
|
vector3d TransferPlanner::GetPosition() const { return m_position; }
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void TransferPlanner::SetPosition(const vector3d &position) { m_position = position; }
|
2015-07-18 15:24:19 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
SystemView::SystemView(Game *game) :
|
|
|
|
UIView(),
|
2019-08-21 09:34:40 -07:00
|
|
|
m_game(game),
|
|
|
|
m_gridDrawing(GridDrawing::OFF),
|
|
|
|
m_shipDrawing(OFF),
|
2020-04-04 01:16:58 -07:00
|
|
|
m_showL4L5(LAG_OFF),
|
|
|
|
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);
|
|
|
|
|
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();
|
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);
|
2015-09-28 14:08:48 -07:00
|
|
|
m_orbitVts[i] = vector3f(offset + pos * double(m_zoom));
|
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
|
|
|
|
|
|
|
Gui::Screen::EnterOrtho();
|
|
|
|
vector3d pos;
|
2020-02-01 10:14:41 -08:00
|
|
|
if (Gui::Screen::Project(offset + orbit->Perigeum() * double(m_zoom), pos) && pos.z < 1)
|
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
|
|
|
AddProjected<RefType>(Projectable::PERIAPSIS, base, ref, pos);
|
2020-02-01 10:14:41 -08:00
|
|
|
if (Gui::Screen::Project(offset + orbit->Apogeum() * double(m_zoom), pos) && pos.z < 1)
|
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
|
|
|
AddProjected<RefType>(Projectable::APOAPSIS, base, ref, pos);
|
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-02-01 10:14:41 -08:00
|
|
|
if (Gui::Screen::Project(offset + posL4 * double(m_zoom), pos) && pos.z < 1) {
|
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
|
|
|
AddProjected<RefType>(Projectable::L4, base, ref, pos);
|
2015-11-17 12:57:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const vector3d posL5 = orbit->EvenSpacedPosTrajectory((1.0 / 360.0) * 300.0, tMinust0);
|
2020-02-01 10:14:41 -08:00
|
|
|
if (Gui::Screen::Project(offset + posL5 * double(m_zoom), pos) && pos.z < 1) {
|
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
|
|
|
AddProjected<RefType>(Projectable::L5, base, ref, pos);
|
2011-09-14 13:13:53 -07:00
|
|
|
}
|
|
|
|
}
|
2014-08-07 03:04:46 -07:00
|
|
|
Gui::Screen::LeaveOrtho();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
const double radius = b->GetRadius() * m_zoom;
|
|
|
|
|
|
|
|
matrix4x4f invRot = trans;
|
|
|
|
invRot.ClearToRotOnly();
|
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
|
|
|
|
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
|
|
|
AddNotProjected<const SystemBody>(Projectable::OBJECT, Projectable::SYSTEMBODY, b, offset);
|
2008-08-12 09:38:23 -07:00
|
|
|
}
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2019-10-07 09:12:28 -07:00
|
|
|
Frame *frame = Frame::GetFrame(Pi::player->GetFrame());
|
2019-01-02 08:59:07 -08:00
|
|
|
if (frame->IsRotFrame())
|
2019-10-07 09:12:28 -07:00
|
|
|
frame = Frame::GetFrame(frame->GetNonRotFrame());
|
2015-11-15 13:22:56 -08: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()) {
|
2017-03-05 05:15:55 -08:00
|
|
|
if (is_zero_general(kid->GetOrbit().GetSemiMajorAxis()))
|
2015-11-15 13:22:56 -08:00
|
|
|
continue;
|
|
|
|
|
2015-11-17 12:57:10 -08:00
|
|
|
const double axisZoom = kid->GetOrbit().GetSemiMajorAxis() * m_zoom;
|
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
|
2015-11-17 12:57:10 -08:00
|
|
|
const vector3d pos = kid->GetOrbit().OrbitalPosAtTime(m_time) * double(m_zoom);
|
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
|
|
|
{
|
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 (b->GetParent()) {
|
|
|
|
GetTransformTo(b->GetParent(), pos);
|
|
|
|
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
|
|
|
{
|
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);
|
|
|
|
else if (p.ref.body->GetType() == Object::Type::SHIP || p.ref.body->GetType() == Object::Type::PLAYER) {
|
|
|
|
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();
|
|
|
|
if (s->GetFlightState() != Ship::FlightState::FLYING) {
|
|
|
|
vector3d rpos(0.0);
|
|
|
|
if (Frame::GetFrame(shipFrameId)->IsRotFrame()) {
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
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()
|
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->SetPerspectiveProjection(CAMERA_FOV, m_renderer->GetDisplayAspect(), 1.f, 1000.f * m_zoom * float(AU) + DEFAULT_VIEW_DISTANCE * 2);
|
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();
|
|
|
|
//TODO add reserve
|
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
|
|
|
|
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);
|
|
|
|
m_renderer->SetTransform(m_cameraSpace);
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2020-04-04 01:16:58 -07:00
|
|
|
// smooth transition animation
|
|
|
|
m_transTo *= 0.0;
|
|
|
|
if (m_selectedObject.type != Projectable::NONE) GetTransformTo(m_selectedObject, m_transTo);
|
|
|
|
if (m_animateTransition) {
|
|
|
|
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 {
|
|
|
|
m_trans = m_transTo;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector3d pos = m_trans * m_zoom;
|
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
|
|
|
|
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_game->GetSpace()->GetStarSystem()->GetPath().IsSameSystem(m_game->GetSectorView()->GetSelected())) {
|
|
|
|
// draw ships
|
|
|
|
if (m_shipDrawing != OFF) {
|
|
|
|
RefreshShips();
|
|
|
|
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);
|
|
|
|
AddNotProjected<Body>(Projectable::OBJECT, Projectable::PLAYER, PlayerBody, ppos * m_zoom + pos);
|
|
|
|
|
|
|
|
vector3d offset(0.0);
|
|
|
|
CalculateFramePositionAtTime(playerNonRotFrameId, m_time, offset);
|
|
|
|
offset = offset * m_zoom + pos;
|
|
|
|
|
|
|
|
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.)
|
|
|
|
AddNotProjected<Body>(Projectable::OBJECT, Projectable::PLANNER, PlayerBody, offset + plannedOrbit.OrbitalPosAtTime(m_time - plannerStartTime) * static_cast<double>(m_zoom));
|
|
|
|
else
|
|
|
|
AddNotProjected<Body>(Projectable::OBJECT, Projectable::PLANNER, PlayerBody, offset + m_planner->GetPosition() * static_cast<double>(m_zoom));
|
|
|
|
}
|
|
|
|
}
|
2014-08-07 00:36:04 -07:00
|
|
|
}
|
|
|
|
|
2019-08-21 09:34:40 -07:00
|
|
|
if (m_gridDrawing != GridDrawing::OFF) {
|
|
|
|
DrawGrid();
|
|
|
|
}
|
|
|
|
|
2013-01-08 22:13:14 -08:00
|
|
|
UIView::Draw3D();
|
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;
|
|
|
|
}
|
|
|
|
else if (m_zoomView) {
|
|
|
|
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
|
|
|
|
|
|
|
UIView::Update();
|
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 &&
|
|
|
|
(*s)->GetType() == Object::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);
|
|
|
|
pos = pos * m_zoom + offset;
|
|
|
|
//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;
|
|
|
|
AddNotProjected<Body>(Projectable::OBJECT, Projectable::SHIP, static_cast<Body *>((*s).first), pos);
|
|
|
|
if (m_shipDrawing == ORBITS && (*s).first->GetFlightState() == Ship::FlightState::FLYING) {
|
|
|
|
vector3d framepos(0.0);
|
|
|
|
CalculateFramePositionAtTime(Frame::GetFrame((*s).first->GetFrame())->GetNonRotFrame(), m_time, framepos);
|
|
|
|
PutOrbit<Body>(Projectable::SHIP, static_cast<Body *>((*s).first), &(*s).second, offset + framepos * m_zoom, 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
|
|
|
|
|
|
|
void SystemView::PrepareGrid()
|
|
|
|
{
|
|
|
|
// calculate lines for this system:
|
|
|
|
double diameter = std::floor(m_system->GetRootBody()->GetMaxChildOrbitalDistance() * 1.2 / AU);
|
|
|
|
|
|
|
|
m_grid_lines = int(diameter) + 1;
|
|
|
|
|
|
|
|
m_displayed_sbody.clear();
|
|
|
|
if (m_gridDrawing == GridDrawing::GRID_AND_LEGS) {
|
2020-02-02 01:33:10 -08:00
|
|
|
m_displayed_sbody = m_system->GetRootBody()->CollectAllChildren();
|
2019-08-21 09:34:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::DrawGrid()
|
|
|
|
{
|
|
|
|
PrepareGrid();
|
|
|
|
|
|
|
|
m_lineVerts.reset(new Graphics::VertexArray(Graphics::ATTRIB_POSITION, m_grid_lines * 4 + m_displayed_sbody.size() * 2));
|
|
|
|
|
|
|
|
float zoom = m_zoom * float(AU);
|
|
|
|
vector3d pos(0.);
|
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_selectedObject.type != Projectable::NONE) GetTransformTo(m_selectedObject, pos);
|
|
|
|
pos *= m_zoom;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
for (SystemBody *sbody : m_displayed_sbody) {
|
|
|
|
vector3d offset(0.);
|
|
|
|
GetTransformTo(sbody, 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 *= m_zoom;
|
|
|
|
m_lineVerts->Add(vector3f(pos - offset), svColor[GRID] * 0.5);
|
2019-08-21 09:34:40 -07:00
|
|
|
offset.y = 0.0;
|
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(pos - offset), svColor[GRID] * 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>
|
|
|
|
void SystemView::AddNotProjected(Projectable::types type, Projectable::bases base, T *ref, const vector3d &worldscaledpos)
|
|
|
|
{
|
|
|
|
//project and add
|
|
|
|
Gui::Screen::EnterOrtho();
|
|
|
|
vector3d pos;
|
|
|
|
if (Gui::Screen::Project(worldscaledpos, pos) && pos.z < 1)
|
|
|
|
AddProjected<T>(type, base, ref, pos);
|
|
|
|
Gui::Screen::LeaveOrtho();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void SystemView::AddProjected(Projectable::types type, Projectable::bases base, T *ref, vector3d &pos)
|
|
|
|
{
|
|
|
|
float scale[2];
|
|
|
|
Gui::Screen::GetCoords2Pixels(scale);
|
|
|
|
Projectable p(type, base, ref);
|
|
|
|
p.screenpos.x = pos.x / scale[0];
|
|
|
|
p.screenpos.y = pos.y / scale[1];
|
|
|
|
p.screenpos.z = pos.z;
|
|
|
|
m_projected.push_back(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// SystemBody can't be inaccessible
|
|
|
|
void SystemView::BodyInaccessible(Body *b)
|
|
|
|
{
|
|
|
|
if (m_selectedObject.type == Projectable::OBJECT && m_selectedObject.base != Projectable::SYSTEMBODY && m_selectedObject.ref.body == b)
|
|
|
|
ResetViewpoint();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
else if (param == "SHIPS_OFF")
|
|
|
|
m_shipDrawing = OFF;
|
|
|
|
else if (param == "SHIPS_ON")
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemView::SetRotateMode(bool enable) {
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
m_animateTransition = MAX_TRANSITION_FRAMES;
|
|
|
|
}
|
|
|
|
|
|
|
|
double SystemView::ProjectedSize(double size, vector3d pos)
|
|
|
|
{
|
|
|
|
matrix4x4d dtrans;
|
|
|
|
matrix4x4ftod(m_cameraSpace, dtrans);
|
|
|
|
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(); }
|