Chunks
Moddable voxel sandbox for room-scale VR.
Public Member Functions | Public Attributes | Properties | List of all members
Chunks.Entities.Transform Class Reference

Contains the position, rotation and scale of an entity. More...

Inheritance diagram for Chunks.Entities.Transform:
Chunks.Entities.Object Chunks.Controls.ControlTransform

Public Member Functions

void Add (Transform transform, bool worldPositionStays)
 Adds a child transform, optionally keeping its transformation in world space intact. More...
 
void DetachFromParent (bool worldPositionStays)
 Removes this transform as a child of its current parent, and makes it a root transform. More...
 
Vector TransformPosition (Vector position)
 Applies this transformation to a position, moving it from local space to world space. More...
 
Vector TransformVector (Vector vector)
 Applies this transformation to a vector, moving it from local space to world space without offsetting it by this transform's position. More...
 
Vector InverseTransformPosition (Vector position)
 Applies the inverse of this transformation to a position, moving it from world space to local space. More...
 
Vector InverseTransformVector (Vector vector)
 Applies the inverse of this transformation to a vector, moving it from world space to local space without offsetting it by this transform's position. More...
 
void Rotate (Vector axis, float angle)
 Rotates this transform about a given axis by the given angle in degrees. More...
 
void Save (BinaryWriter writer)
 Serializes this transformation to a BinaryWriter. More...
 
void Load (BinaryReader reader)
 Deserializes this transformation from a BinaryReader. More...
 
override string ToString ()
 Returns the name of the entity this transform is attached to. More...
 
- Public Member Functions inherited from Chunks.Entities.Object
Entity CreateChild ()
 Creates a new Entity parented to this one. More...
 
TComponent CreateChildWithComponent< TComponent > ()
 Creates a new Entity parented to this one with a component of the given type, which is returned. More...
 
Entity FindChild (string name, bool recurse=true)
 Attempts to find a child Entity of this one with the given name, and optionally searches recursively through all children. Null is returned if no matches are found. More...
 
TComponent FindChildComponent< TComponent > (string name, bool recurse=true)
 Attempts to find a child Entity of this one with the given name, and optionally searches recursively through all children. If a matching Entity is found, a component of the given type is retrieved from it. Null is returned if no matches are found. More...
 
Entity FindParent (string name)
 Attempts to find an Entity that contains this Object's Entity with the given Name. Returns null if no match is found. More...
 
TComponent FindParentComponent< TComponent > ()
 Attempts to find an Entity that contains this Object's Entity with a component of the given type. If a matching Entity is found, the component of the given type is retrieved from it. Returns null if no match is found. More...
 
TComponent FindParentComponent< TComponent > (string name)
 Attempts to find an Entity that contains this Object's Entity with the given Name. If a matching Entity is found, a component of the given type is retrieved from it. Returns null if no match is found. More...
 
TComponent AddComponent< TComponent > ()
 Adds a component of the specified type to this entity, returning the new component. More...
 
TComponent GetOrAddComponent< TComponent > ()
 Attempts to get a component of the specified type from this entity, adding it if one doesn't already exist. More...
 
TComponent GetComponent< TComponent > ()
 Attempts to get a component of the specified type from this entity, returning null if one doesn't exist. More...
 
IEnumerable< TComponent > GetComponents< TComponent > ()
 Gets all components derived from the given type. More...
 

Public Attributes

override bool IsValid => Inner != null
 Tests to see if this transform's entity hasn't been removed. More...
 
Vector Forward => new Vector(Inner.forward)
 The world space forward facing vector of this transform. More...
 
Vector Up => new Vector(Inner.up)
 The world space upwards facing vector of this transform. More...
 
Vector Right => new Vector(Inner.right)
 The world space right facing vector of this transform. More...
 
Vector LossyScale => new Vector(Inner.lossyScale)
 Approximate scale of this transform in world space. More...
 
Matrix4 WorldToLocal => new Matrix4(Inner.worldToLocalMatrix)
 
Matrix4 LocalToWorld => new Matrix4(Inner.localToWorldMatrix)
 
Entity Entity => _entity ?? (_entity = Inner.GetComponent<EntityBehaviour>().Entity)
 The entity that this transform represents. More...
 
int ChildCount => Inner.childCount
 The number of entities that are parented to this one. More...
 

Properties

bool IsReadOnly [get, set]
 This transform cannot be modified if true. More...
 
Vector Position [get, set]
 The world space position of this transform. More...
 
Vector LocalPosition [get, set]
 The position of this transform inside its parent. More...
 
Vector LocalScale [get, set]
 Scale of this transform relative to its parent. More...
 
Quaternion Rotation [get, set]
 The world space rotation of this transform. More...
 
Quaternion LocalRotation [get, set]
 The rotation of this transform relative to its parent. More...
 
Transform Parent [get, protected set]
 The transform of the parent entity, or null if this transform has no parent. More...
 
IEnumerable< TransformChildren [get]
 An enumeration of the transforms of any entities parented to this one. More...
 
- Properties inherited from Chunks.Entities.Object
abstract bool IsValid [get]
 Tests to see if this object hasn't been removed. More...
 
virtual string Name [get, set]
 Custom name associated with this Object's Entity, used to find the Entity in the hierarchy. More...
 
virtual Transform Transform [get]
 Transformation of this Object's Entity. More...
 
virtual IWorld World [get]
 The IWorld that contains this Object. More...
 

Detailed Description

Contains the position, rotation and scale of an entity.

Member Function Documentation

void Chunks.Entities.Transform.Add ( Transform  transform,
bool  worldPositionStays 
)

Adds a child transform, optionally keeping its transformation in world space intact.

Parameters
transformTransform to add as a child
worldPositionStaysIf true, the child transform keeps its world space transformation
void Chunks.Entities.Transform.DetachFromParent ( bool  worldPositionStays)

Removes this transform as a child of its current parent, and makes it a root transform.

Parameters
worldPositionStaysIf true, this transform keeps its world space transformation
Vector Chunks.Entities.Transform.InverseTransformPosition ( Vector  position)

Applies the inverse of this transformation to a position, moving it from world space to local space.

Parameters
positionPosition to be transformed
Vector Chunks.Entities.Transform.InverseTransformVector ( Vector  vector)

Applies the inverse of this transformation to a vector, moving it from world space to local space without offsetting it by this transform's position.

Parameters
vectorVector to be transformed
void Chunks.Entities.Transform.Load ( BinaryReader  reader)

Deserializes this transformation from a BinaryReader.

Parameters
readerReader to read from
void Chunks.Entities.Transform.Rotate ( Vector  axis,
float  angle 
)

Rotates this transform about a given axis by the given angle in degrees.

Parameters
axisAxis to rotate about
angleAngle to rotate in degrees
void Chunks.Entities.Transform.Save ( BinaryWriter  writer)

Serializes this transformation to a BinaryWriter.

Parameters
writerWriter to serialize to
override string Chunks.Entities.Transform.ToString ( )

Returns the name of the entity this transform is attached to.

Vector Chunks.Entities.Transform.TransformPosition ( Vector  position)

Applies this transformation to a position, moving it from local space to world space.

Parameters
positionPosition to be transformed
Vector Chunks.Entities.Transform.TransformVector ( Vector  vector)

Applies this transformation to a vector, moving it from local space to world space without offsetting it by this transform's position.

Parameters
vectorVector to be transformed

Member Data Documentation

int Chunks.Entities.Transform.ChildCount => Inner.childCount

The number of entities that are parented to this one.

Entity Chunks.Entities.Transform.Entity => _entity ?? (_entity = Inner.GetComponent<EntityBehaviour>().Entity)

The entity that this transform represents.

Vector Chunks.Entities.Transform.Forward => new Vector(Inner.forward)

The world space forward facing vector of this transform.

override bool Chunks.Entities.Transform.IsValid => Inner != null

Tests to see if this transform's entity hasn't been removed.

Matrix4 Chunks.Entities.Transform.LocalToWorld => new Matrix4(Inner.localToWorldMatrix)
Vector Chunks.Entities.Transform.LossyScale => new Vector(Inner.lossyScale)

Approximate scale of this transform in world space.

Vector Chunks.Entities.Transform.Right => new Vector(Inner.right)

The world space right facing vector of this transform.

Vector Chunks.Entities.Transform.Up => new Vector(Inner.up)

The world space upwards facing vector of this transform.

Matrix4 Chunks.Entities.Transform.WorldToLocal => new Matrix4(Inner.worldToLocalMatrix)

Property Documentation

IEnumerable<Transform> Chunks.Entities.Transform.Children
get

An enumeration of the transforms of any entities parented to this one.

bool Chunks.Entities.Transform.IsReadOnly
getset

This transform cannot be modified if true.

Vector Chunks.Entities.Transform.LocalPosition
getset

The position of this transform inside its parent.

Quaternion Chunks.Entities.Transform.LocalRotation
getset

The rotation of this transform relative to its parent.

Vector Chunks.Entities.Transform.LocalScale
getset

Scale of this transform relative to its parent.

Transform Chunks.Entities.Transform.Parent
getprotected set

The transform of the parent entity, or null if this transform has no parent.

Vector Chunks.Entities.Transform.Position
getset

The world space position of this transform.

Quaternion Chunks.Entities.Transform.Rotation
getset

The world space rotation of this transform.


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