Gravity Engine 2 3.0
Loading...
Searching...
No Matches
GravityEngine2.GSDisplay Class Reference

Control the display of all GSDisplay objects for a given GE. The GE is commonly implied by the use of GravitySceneController, otherwise it can be set via a script. More...

Inheritance diagram for GravityEngine2.GSDisplay:
GravityEngine2.GSDisplay2D GravityEngine2.GSLaunchDisplay GravityEngine2.GSMapDisplay

Classes

struct  GSDisplayObjectInfo
 

Public Types

enum  AddMode { CHILDREN , LIST , SCENE }
 Mode the controller will use to find GSBody objects to add CHILDREN: Scan all children of this controller for GSBody LIST: Add objects explicitly listed SCENE: Find all objects in the scene with GSBody components.
 
enum  DisplayMode { DIRECT , INTERPOLATE }
 

Public Member Functions

void ActiveSet (bool value)
 Change the active status.
 
void DisplayBodyRemoveByBodyId (int id)
 Remove all GSDisplayObjects with the given bodyId.
 
delegate void DisplayInScene (GECore ge, MapToSceneFn mapToScene, double timeWorld, bool alwaysUpdate=false)
 
void DisplayObjectAdd (GSDisplayObject gdo)
 Add a GSDisplayObject (typically a GSDisplayBody or GSDisplayOrbit). Different display objects may have different update methods or choose to register custom display functions so they are asked to "add themselves" via AddToSceneDisplay(). As part of this they must call RegisterDisplayObject() [which is where the "book-keeping" is done.].
 
void DisplayObjectRemove (GSDisplayObject gdo)
 Remove a GSDisplayObject (e.g. GSDisplayBody, GSDisplayOrbit etc.)
 
virtual void DisplayUpdate (GECore ge, double elapsedWorldTime)
 Main update loop for display of bodies and orbits in the scene. (Internal)
 
string DumpAll ()
 
virtual List< int > Init ()
 Initialize the objects for this display controller. This is called by GSController init as part of its Start()
 
virtual Vector3 MapToScene (Vector3 rWorld, double time=-1)
 Map from the world space to the display space:
 
delegate Vector3 MapToSceneFn (Vector3 rWorld, double time=-1)
 
void ParticleSetup (double dt, double timeStart, GBUnits.GEScaler geScaler)
 
void ParticlesUpdate (double lenPhysToWorld)
 
List< GSParticlesParticleSystems ()
 
int RegisterDisplayObject (GSDisplayObject gdo, int bodyId, Transform transform=null, DisplayInScene displayInScene=null, bool trajectory=false, LineRenderer trajLine=null)
 
void UpdateDisplayObjectBody (long displayId, int bodyId)
 Update the internal state of GSDisplayObject. Can be used to designate a new bodyId to track.
 

Public Attributes

bool active = true
 
GSDisplayObject[] addBodies
 
AddMode addMode = AddMode.CHILDREN
 
CR3BP.ReferencePoint cr3bpRefPoint = CR3BP.ReferencePoint.NONE
 
DisplayMode displayMode = DisplayMode.INTERPOLATE
 
bool editorScalingFoldout = false
 
GSController gsController
 
float maxSceneDimension = 10000
 
float scale = 1.0f
 
GSBody wrtBody
 
bool xzOrbitPlane = true
 

Protected Member Functions

virtual void DisplayUpdateInit (GECore ge, double elapsedWorldTime)
 
virtual void TrajectoryUpdate (GECore geTrajectory)
 Trajectories are computed by a "look-ahead" GE instance that has a circular recording buffer in GE scale units.
 

Protected Attributes

int[] displayIndices
 
GSDisplayObjectInfo[] displayObjects
 displayObjects may be sparsely filled. The empty slots are managed by a Stack and the allocated slots are listed in an array of indices.
 
Queue< int > displayOptQueue
 
Vector3 displayPosition
 
Quaternion displayRotation
 
bool maintainCoRo
 
int numDO
 
float queueConsumeRate
 
float queueConsumeTokens
 
Vector3 wrtWorldPosition
 

Detailed Description

Control the display of all GSDisplay objects for a given GE. The GE is commonly implied by the use of GravitySceneController, otherwise it can be set via a script.

This is the typical display component used. It will display all objects with a GSDisplayObject (or extending class such as GSDisplayBody, GSDisplayOrbit etc.) in a scaled fashion but will not apply any other transformations or limitations.

GSDisplayObject bodies are typically arranged in the heirarchy to be children of this object. If not, then they must add themselves by registering with AddGSDisplayObject(). This will register them to have a state or COE update when appropriate. The state or COE update mode is specified at the time of registration.

This class may be extended to produce a different visual result while taking advantage of all the "plumbing" implemented here. This is typically done by over-riding MapToScene delegate GSDMapToScene().

Member Function Documentation

◆ ActiveSet()

void GravityEngine2.GSDisplay.ActiveSet ( bool value)

Change the active status.

If active -> inactive:

  • set all GSDisplayBody displayBody to inactive (if present)
  • set all GSDisplayBody traj LineRenderes to inactive
  • set all GSDisplayOrbit LineRenderers to inactive

(flip if going the other way)

Parameters
value

◆ DisplayBodyRemoveByBodyId()

void GravityEngine2.GSDisplay.DisplayBodyRemoveByBodyId ( int id)

Remove all GSDisplayObjects with the given bodyId.

There may be more than one.

Parameters
id

◆ DisplayObjectAdd()

void GravityEngine2.GSDisplay.DisplayObjectAdd ( GSDisplayObject gdo)

Add a GSDisplayObject (typically a GSDisplayBody or GSDisplayOrbit). Different display objects may have different update methods or choose to register custom display functions so they are asked to "add themselves" via AddToSceneDisplay(). As part of this they must call RegisterDisplayObject() [which is where the "book-keeping" is done.].

Parameters
gdo

◆ DisplayObjectRemove()

void GravityEngine2.GSDisplay.DisplayObjectRemove ( GSDisplayObject gdo)

Remove a GSDisplayObject (e.g. GSDisplayBody, GSDisplayOrbit etc.)

Parameters
gdo

◆ DisplayUpdate()

virtual void GravityEngine2.GSDisplay.DisplayUpdate ( GECore ge,
double elapsedWorldTime )
virtual

Main update loop for display of bodies and orbits in the scene. (Internal)

Bodies will generally be set to have their transforms updated directly by this code.

Display of orbits is done by delegates that determine how to poulate their line renderers.

There is code to allow objects with dlegates to limit how often they are caled which can be useful for orbit display, since computing all the points in an orbit can cost CPU.

Parameters
ge
elapsedWorldTime

◆ DisplayUpdateInit()

virtual void GravityEngine2.GSDisplay.DisplayUpdateInit ( GECore ge,
double elapsedWorldTime )
protectedvirtual
Parameters
ge
elapsedWorldTime

Reimplemented in GravityEngine2.GSLaunchDisplay, and GravityEngine2.GSMapDisplay.

◆ DumpAll()

string GravityEngine2.GSDisplay.DumpAll ( )
Returns

◆ Init()

virtual List< int > GravityEngine2.GSDisplay.Init ( )
virtual

Initialize the objects for this display controller. This is called by GSController init as part of its Start()

  • find the GSDisplayObject implementations (mostly GSDisplayBody)
  • find the GSDisplayOrbit
  • arrange internal data structure by having above objects register with this class
  • determine if any bodies want trajectory recording and pass their ids back
Returns
List of trajectories

Reimplemented in GravityEngine2.GSDisplay2D, GravityEngine2.GSLaunchDisplay, and GravityEngine2.GSMapDisplay.

◆ MapToScene()

virtual Vector3 GravityEngine2.GSDisplay.MapToScene ( Vector3 rWorld,
double time = -1 )
virtual

Map from the world space to the display space:

  • if XZ orbit mode, then flip YZ coords
  • apply scale from world to display
  • add position offset and rotation from the GSDisplay transform

Extensions of this class will commonly override this method to produce a different mapping e.g. GSDisplayMercator

Typically the time is not required, but some display controllers may elect to show things in a rotating frame and the time is needed in those cases.

Parameters
rWorldPosition in world space and default world units
timeworld time for this point
Returns

Reimplemented in GravityEngine2.GSDisplay2D, GravityEngine2.GSLaunchDisplay, and GravityEngine2.GSMapDisplay.

◆ ParticleSetup()

void GravityEngine2.GSDisplay.ParticleSetup ( double dt,
double timeStart,
GBUnits::GEScaler geScaler )
Parameters
dt
timeStart
geScaler

◆ ParticleSystems()

List< GSParticles > GravityEngine2.GSDisplay.ParticleSystems ( )
Returns

◆ RegisterDisplayObject()

int GravityEngine2.GSDisplay.RegisterDisplayObject ( GSDisplayObject gdo,
int bodyId,
Transform transform = null,
DisplayInScene displayInScene = null,
bool trajectory = false,
LineRenderer trajLine = null )
Parameters
gdo
bodyId
transform
displayInScene
trajectory
trajLine
Returns

◆ TrajectoryUpdate()

virtual void GravityEngine2.GSDisplay.TrajectoryUpdate ( GECore geTrajectory)
protectedvirtual

Trajectories are computed by a "look-ahead" GE instance that has a circular recording buffer in GE scale units.

To display this we read out from the current point in the buffer accounting for the wrap-around. Since the reading of a buffer with scaling would change the buffer contents we need to do the scaling here (otherwise we'd scale the scaled version next time through).

Parameters
geTrajectory

Reimplemented in GravityEngine2.GSDisplay2D, GravityEngine2.GSLaunchDisplay, and GravityEngine2.GSMapDisplay.

◆ UpdateDisplayObjectBody()

void GravityEngine2.GSDisplay.UpdateDisplayObjectBody ( long displayId,
int bodyId )

Update the internal state of GSDisplayObject. Can be used to designate a new bodyId to track.

Parameters
displayId
bodyId
transform
displayInScene
trajectory
trajLine

The documentation for this class was generated from the following file: