Class UniverseObject
- Namespace
- NominalSystems.Universe
- Assembly
- NominalSystems.Universe.dll
[Nominal] A universe object is a special object that can have a physical position and may be visible in the world. It can be attached to a parent or moved around relative to the origin. This object is useful for visualisations to help keep track of the locations of objects.
public class UniverseObject : UniverseEvent
- Inheritance
-
UniverseObject
- Derived
- Extension Methods
Constructors
UniverseObject()
Default constructor
protected UniverseObject()
Fields
Behaviours
The list of all behaviours that are attached to this object.
[ReadOnly]
[Metadata(IsAdvanced = true)]
public List<UniverseBehaviour> Behaviours
Field Value
Children
The list of all child objects that are attached to this object.
[ReadOnly]
[Metadata(IsAdvanced = true)]
public List<UniverseObject> Children
Field Value
Models
The list of all models that are attached to this object.
[ReadOnly]
[Metadata(IsAdvanced = true)]
public List<UniverseModel> Models
Field Value
Name
This defines the name of the object. This name does not need to be unique and can be left as empty if required. The name is used as a display purpose or can be searched for.
public string Name
Field Value
Out_TransformMsg
This defines the base transform message that stores the state of the transform of this object.
public TransformMessage? Out_TransformMsg
Field Value
Properties
LocalForward
The direction of the transform frame's forward vector, which is along the Y axis.
[Unit(UnitType.NONE)]
[ReadOnly]
[Metadata(IsAdvanced = true)]
public virtual Vector3 LocalForward { get; }
Property Value
LocalRight
The direction of the transform frame's right vector, which is along the X axis.
[Unit(UnitType.NONE)]
[ReadOnly]
[Metadata(IsAdvanced = true)]
public virtual Vector3 LocalRight { get; }
Property Value
LocalUp
The direction of the transform frame's up vector, which is along the Z axis.
[Unit(UnitType.NONE)]
[ReadOnly]
[Metadata(IsAdvanced = true)]
public virtual Vector3 LocalUp { get; }
Property Value
Parent
This is an optional parent that can enable an anchor point for where the object exists on. If the parent object transform changes, so does the absolute transform of the sub-object.
[ReadOnly]
[Metadata(IsAdvanced = true)]
public UniverseObject? Parent { get; }
Property Value
Position
[m] The position of the object relative to the parent or to world origin, if no parent exists.
[Unit(UnitType.METRE)]
public virtual Vector3 Position { get; set; }
Property Value
Rotation
[-] The rotation of the object relative to the parent or to the world origin, if no parent exists. This is the transpose of the DCM matrix.
[Unit(UnitType.NONE)]
public virtual Matrix3 Rotation { get; set; }
Property Value
Transform
This controls the position and rotation of the object relative to the parent of the object, or absolute if there is no parent.
[Hidden]
public Transform Transform { get; }
Property Value
Methods
AddBehaviour(Type)
Adds a behaviour of a particular type to this universe object, if it is able to.
public UniverseBehaviour AddBehaviour(Type type)
Parameters
type
TypeThe universe behaviour type to add
Returns
- UniverseBehaviour
The behaviour that was created and added
AddBehaviour<T>()
Adds a behaviour of a particular type to this universe object, if it is able to.
public T AddBehaviour<T>() where T : UniverseBehaviour
Returns
- T
The behaviour that was created and added
Type Parameters
T
The universe behaviour type to add
Add<T>()
Adds a new object to the current object. This will make the current object the parent / owner of the new object.
public T Add<T>() where T : UniverseObject
Returns
- T
The object that was attached
Type Parameters
T
The universe object type to attach
Attach(UniverseObject)
Attempts to attach this object to a new parent. This will only work if the current object is no parented to any other object.
public virtual bool Attach(UniverseObject parent)
Parameters
parent
UniverseObjectThe new parent to attach this object to
Returns
- bool
A successful attachment flag
ContainsModel(string)
Returns a flag whether the universe object currently contains an instance of a particular universe model, of some type.
public bool ContainsModel(string typeName)
Parameters
typeName
stringThe universe model type to check
Returns
- bool
A success if the object contains a model type
ContainsModel<T>()
Returns a flag whether the universe object currently contains an instance of a particular universe model, of some type.
public bool ContainsModel<T>() where T : UniverseModel
Returns
- bool
A success if the object contains a model type
Type Parameters
T
The universe model type to check
Destroy()
Destroys the object and all of its children. This will also ensure that it is no longer being simulated.
public void Destroy()
Detach()
This is an action to detach the current object from its parent, if it exists and move it to another object or to just exist within the simulation.
public virtual bool Detach()
Returns
- bool
A successful detachment flag
GetBehaviour<T>(bool)
Returns a behaviour that exists on this object, or any of its children (if recursing).
public T? GetBehaviour<T>(bool recurse = true) where T : UniverseBehaviour
Parameters
recurse
boolA flag whether to recurse down the chain
Returns
- T
The reference to the behaviour that is attached, if it exists
Type Parameters
T
The universe behaviour type to search for
GetBehaviours<T>(bool)
Returns the array of behaviours that exists on this object, or any of its children (if recursing).
public T[] GetBehaviours<T>(bool recurse = true) where T : UniverseBehaviour
Parameters
recurse
boolA flag whether to recurse down the chain
Returns
- T[]
The array of behaviours that exist on this object
Type Parameters
T
The universe behaviour type to search for
GetChild<T>(bool)
Attempts to find a child of a particular universe object type within the hierarchy of the current object.
public T? GetChild<T>(bool recurse = true) where T : UniverseObject
Parameters
recurse
boolA flag whether to recurse down the chain
Returns
- T
A child reference, if it exists
Type Parameters
T
The universe object child to search for
GetChildren<T>(bool)
Attempts to find children of a particular universe object type within the hierarchy of the current object.
public T[] GetChildren<T>(bool recurse = true) where T : UniverseObject
Parameters
recurse
boolA flag whether to recurse down the chain
Returns
- T[]
A child array of all matching objects
Type Parameters
T
The universe object child to search for
GetModel(Type)
Returns a registered "NominalSystems.Universe.UniverseModel" with the specified type.
public UniverseModel GetModel(Type type)
Parameters
type
TypeA "NominalSystems.Universe.UniverseModel" type.
Returns
GetModel<T>()
Returns a registered "NominalSystems.Universe.UniverseModel" with the specified type.
public T GetModel<T>() where T : UniverseModel
Returns
- T
Type Parameters
T
A "NominalSystems.Universe.UniverseModel" type.
GetModels()
Returns the list of all models attached to the current object and only to the current object. This will not look down the chain and find model.
public UniverseModel[] GetModels()
Returns
- UniverseModel[]
The universe models that exist
GetParent<T>(bool)
Attempts to find a parent object of the given type. If the recurse mode is on, this will look up the chain until a parent object is found.
public T? GetParent<T>(bool recurse = true) where T : UniverseObject
Parameters
recurse
boolA flag whether to go up the object chain
Returns
- T
The parent object of the type specified, if it exists
Type Parameters
T
The type of object to look for
GetRoot()
Returns the root object of the Universe Object which will either be the current object, if there is no parent, or the parent of the parent of the current object.
public UniverseObject GetRoot()
Returns
- UniverseObject
The root object of this hierarchy
GetRoot<T>()
Returns the root object of this Universe Object in a particular type. This will find the highest root object that is of the type specified.
public T? GetRoot<T>() where T : UniverseObject
Returns
- T
The universe object type that exists as the root
Type Parameters
T
The Universe Object type to look for
GetWorldForward()
Returns the forward vector of the object in world space.
public Vector3 GetWorldForward()
Returns
- Vector3
The world forward vector
GetWorldRight()
Returns the right vector of the object in world space.
public Vector3 GetWorldRight()
Returns
- Vector3
The world right vector
GetWorldTransform()
Returns the world transform of the object which is relative to the parent. If no parent exists, this will be the transform of the object in world space.
public virtual Transform GetWorldTransform()
Returns
- Transform
The transform relative to the origin coordinate space
GetWorldUp()
Returns the up vector of the object in world space.
public Vector3 GetWorldUp()
Returns
- Vector3
The world up vector
OnBehaviourAttached(UniverseBehaviour)
This event is called when a new behaviour is added to this component. The behaviour is passed into the event and a component can override this method to implement some form of checking when this event is executed.
protected virtual void OnBehaviourAttached(UniverseBehaviour behaviour)
Parameters
behaviour
UniverseBehaviourA reference to the behaviour that was just added
OnBehaviourDetached(UniverseBehaviour)
This event is called when a behaviour is removed from this component. The behaviour will be passed to the event but it is now no longer attached to this component.
protected virtual void OnBehaviourDetached(UniverseBehaviour behaviour)
Parameters
behaviour
UniverseBehaviourA reference to the behaviour that was detached
OnChildAttached(UniverseObject)
This event is called when a child has been attached to this object. This will pass in the reference to the child object that was added.
protected virtual void OnChildAttached(UniverseObject child)
Parameters
child
UniverseObjectThe child object that was added
OnChildDetached(UniverseObject)
This event is called when a child has been detached from this object. This will pass in the child object that was removed.
protected virtual void OnChildDetached(UniverseObject child)
Parameters
child
UniverseObjectThe child object that was detached
OnCreate()
Called when the 'Component' is created from the controller.
protected override void OnCreate()
OnParentChanged(UniverseObject?)
This event is called when the parent object has been changed. This will pass in the reference to the current parent. If the parent is missing, a null reference will be passed in.
protected virtual void OnParentChanged(UniverseObject? parent)
Parameters
parent
UniverseObjectThe reference to the current parent
PitchDegrees(double)
Pitches the local transform by some rotation along the X axis.
public virtual void PitchDegrees(double degrees)
Parameters
degrees
double[deg] The angle to pitch by
RollDegrees(double)
Rolls the local transform by some rotation along the Y axis.
public virtual void RollDegrees(double degrees)
Parameters
degrees
double[deg] The angle to roll by
SetParent(UniverseObject?)
Sets the parent of the object to a new parent, or detaching the object completely and adding back to the controller base.
public bool SetParent(UniverseObject? newOwner)
Parameters
newOwner
UniverseObjectThe new owner, if it exists
Returns
- bool
A successful setting of the parent to a new, or empty, object
SetUpdatePriority(int)
This method is able to set the priority of a component for its update event. Since the update is called based on the components that are ticked, any components that need to be ticked before other objects can have their priorities changed here.
public void SetUpdatePriority(int priority = -1)
Parameters
priority
intA priority index, where -1 will put to the top of the list
SetWorldTransform(Transform)
Sets the transform of this object, relative to the simulation origin. This will climb up the hierarchy of the components attached and will update the absolute transform to the origin.
public virtual void SetWorldTransform(Transform transform)
Parameters
transform
TransformThe transform relative to the origin coordinate space
YawDegrees(double)
Yaws the local transform by some rotation along the Z axis.
public virtual void YawDegrees(double degrees)
Parameters
degrees
double[deg] The angle to yaw by