Skip to content

Transform.cs

Charles Humphrey edited this page Nov 16, 2017 · 6 revisions

RandomchaosMGBase.Transform

This class holds all the data required to create a world transform (matrix) used to define an objects position, scale and rotation in world space.

The idea for this came from my use of Unity3D, I dare say, other engines utilize a similar mechanic when dealing with object to world transforms. The idea with this is that it makes it easy to set object as parent transforms for a given object, that is to say, using this mechanic it is easy to stick mesh's (models) together linked via a hierarchy of transforms.

For example, you may want to attach a light to the end of a shot gun, simply set the lights parent transform to that of the shotgun and give it a local position to situate it at the end of the weapon.

Public Properties

Properties that have been denoted as public scope.

Vector3 Scale

This is the global scale of the object.

Vector3 LocalScale

This is the scale of the object in relation to the parent objects transform.

Vector2 Scale2D

The 2D representation of Scale

Vector2 LocalScale2D

The 2D representation of LocalScale

Vector3 Position

This is the global position of the object.

Vector2 Position2D

The 2D representation of Position

Vector2 LocalPosition2D

The 2D representation of LocalPosition

Vector3 LocaPosition

This is the position of the object in relation to the parent objects transform.

Quaternion Rotation

This is the global rotation of the object.

Quaternion LocalRotation

This is the rotation of the object in relation to the parent objects transform/

Matrix World

This is the objects world matrix.

IHasTransform Parent

This is the parent object that has a Transform class.

Public Methods

Transform()

This is the default constructor for the class, when called scale is set to Vector3.One, position set to Vector3.Zero, rotation set to Quaternion.Identity and parent set to null.

Update()

The World Matrix is not calculated until this method is called, this should be called within the IHasTransform's Update(GameTime gameTime) method.

Public Static Properties

Identity

This returns a newly constructed instance of the Transform class.

Clone this wiki locally