Gravity Engine 12.0
Unity Asset for Gravity
Loading...
Searching...
No Matches
NBody Class Reference

N body. More...

Inheritance diagram for NBody:

Public Member Functions

void Awake ()
 
float CalculateSize ()
 
void UpdateVelocity ()
 Updates the velocity. The Gravity Engine does not copy back velocity updates during evolution. Calling this method causes an update to the scaled velocity.
 
void SetPosVel3d (Vector3d pos, Vector3d vel)
 
void GEUpdate (Vector3 position, Vector3 velocity, GravityEngine ge)
 Update called from GE to set new position/velocity based on gravity evolution. The NBody referance frame moves so that the local axis points along the path.
 
bool IsFixedOrbit ()
 Is the NBody activly under the control of a fixedOrbit element?
 
void EditorUpdate (GravityEngine ge)
 Set transform position during scene editing if the object is being manipulated by orbit components.
 
void InitPosition (GravityEngine ge)
 Used to determine the initial physics position of an NBody (initialPhysPosition).
 
void ApplyScale (float lengthScale, float velocityScale)
 Rescale with specified lengthScale.
 
void CalcOrbitDepth ()
 Determine if and how many objects are orbital parents. e.g. Sun = 0, planet=1, moon=2.
 
int GetOrbitDepth ()
 
int Compare (NBody x, NBody y)
 Sort by increasing order of the order depth parameter.
 

Public Attributes

float mass
 mass of object (mass scale in GravityEngine will be applied to get value used in simulation)
 
Vector3 vel
 Velocity - initial velocity as set in the inspector. In the unit system selected in GE.
 
Vector3 vel_phys
 Current physics velocity (in internal scaled units used in GE)
 
Vector3 initialPos
 The initial position/velocity This indicates the position in the active units used by the Gravity engine (m or AU). If the units are DIMENSIONLESS, then this field is not active and the transform position is not affected by scaling.
 
Vector3 initialPhysPosition
 
bool initWithDouble = false
 
Vector3d initialPhysPositionV3
 
Vector3d vel_physV3
 
bool automaticParticleCapture = true
 Automatically detect particle capture size from a child with a mesh.
 
double size = 0.1
 Particle capture radius. Particles closer than this will be inactivated.
 
GravityEngine.EngineRef engineRef
 Opaque data maintained by the GravityEngine. Do not modify.
 
bool rotateFrame
 Rotate the frame as the body moves. Used when objects are in orbit.
 

Detailed Description

N body.

Specifies the information required for NBody physics evolution of the associated game object.

Member Function Documentation

◆ ApplyScale()

void NBody.ApplyScale ( float  lengthScale,
float  velocityScale 
)

Rescale with specified lengthScale.

This is called:

  • from editor scripts when a scale update has occured in the GE inspector.
  • from GravityScalar when a body is added to GE (before SetupGameObjectAndChildren)

Not typically called by user scripts.

Parameters
lengthScaleLength scale.
velocityScaleVelocity scale (GE Units to Phys Units).

◆ Compare()

int NBody.Compare ( NBody  x,
NBody  y 
)

Sort by increasing order of the order depth parameter.

Parameters
_x
_y
Returns

◆ EditorUpdate()

void NBody.EditorUpdate ( GravityEngine  ge)

Set transform position during scene editing if the object is being manipulated by orbit components.

Parameters
ge

◆ GEUpdate()

void NBody.GEUpdate ( Vector3  position,
Vector3  velocity,
GravityEngine  ge 
)

Update called from GE to set new position/velocity based on gravity evolution. The NBody referance frame moves so that the local axis points along the path.

Parameters
positionThe position
velocityThe velocity

◆ InitPosition()

void NBody.InitPosition ( GravityEngine  ge)

Used to determine the initial physics position of an NBody (initialPhysPosition).

Used in two contexts: (1) When a body is added to GE (either at setup or when a body is dynamically added at run-time). (2) In the editor DrawGizmo calls when the orbit path is being show in a scene that is not running. In the case of orbit gizmos the orbit parameters will MOVE the object to the correct position in the orbit based on the position calculated here.

If the NBody game object has an INBodyInit component (e.g from an OrbitEllipse) then this is used to determine it's position. There is a potential for recursion here, since that orbit ellipse may be on a NBody that is in turn positioned by an orbit ellipse e.g. moon/planet/sun.

If the NBody has an engine ref (i.e. GE has taken charge) then update with the position from GE.

Parameters
ge

◆ IsFixedOrbit()

bool NBody.IsFixedOrbit ( )

Is the NBody activly under the control of a fixedOrbit element?

Returns

Member Data Documentation

◆ initialPos

Vector3 NBody.initialPos

The initial position/velocity This indicates the position in the active units used by the Gravity engine (m or AU). If the units are DIMENSIONLESS, then this field is not active and the transform position is not affected by scaling.

When m or AU are active, a change in the scale factor of the gravity engine in the editor will change all the associated transform positions and velocities but the initialPos/initialVel will not be changed.

When the transform is changed in the inspector this value will be updated.

Positions are affected by changes in the lengthScale Velocities are affected by changes in both the length scale and the timeScale. (See ApplyScale() )


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