Lua API  0.4.0
Game Engine
 All Files Functions
Transformation.lua File Reference

Functions

 rotate (object, axis, angle,"local")
 Rotates an object. More...
 
 translate (object,{x, y, z},"local")
 Translates an object. More...
 
 getPosition (object)
 Retrieves the position of an object. More...
 
 getRotation (object)
 Retrieves the rotation of an object. More...
 
 getScale (object)
 Retrieves the scale of an object. More...
 
 setPosition (object, pos)
 Sets the position of an object. More...
 
 setRotation (object, rot)
 Sets the rotation of an object. More...
 
 setScale (object, scale)
 Sets the scale of an object. More...
 
 getTransformedPosition (object)
 Retrieves the transformed position of an object. More...
 
 getTransformedRotation (object)
 Retrieves the transformed rotation of an object. More...
 
 getTransformedScale (object)
 Retrieves the transformed scale of an object. More...
 
 getInverseRotatedVector (object, vector)
 Calculates the inverse rotated vector according to the matrix of the object. More...
 
 getRotatedVector (object, vector)
 Rotates the given vector according to the matrix of the given object. More...
 
 getInverseVector (object, vector)
 Calculates the inverse vector according to the matrix of the object. More...
 
 getTransformedVector (object, vector)
 Multiplies the given with the matrix of the given object. More...
 
 updateMatrix (object)
 Recalculates the matrix of the given object. More...
 
 getMatrix (object)
 Retrieves the matrix of an object as a table. More...
 

Function Documentation

getInverseRotatedVector ( object  ,
vector   
)

Calculates the inverse rotated vector according to the matrix of the object.

Parameters
objectThe object.
vectorThe vec3 containing positional data.
Returns
A vec3 with the transformed data.
getInverseVector ( object  ,
vector   
)

Calculates the inverse vector according to the matrix of the object.

This can be useful for converting global vectors into local vectors.

Parameters
objectThe object.
vectorThe vec3 containing positional data.
Returns
A vec3 with the transformed data.
getMatrix ( object  )

Retrieves the matrix of an object as a table.

Parameters
objectThe object.
Returns
A table containing the current matrix.
getPosition ( object  )

Retrieves the position of an object.

Parameters
objectThe object.
Returns
A vec3 containing the current position.
getRotatedVector ( object  ,
vector   
)

Rotates the given vector according to the matrix of the given object.

Parameters
objectThe object.
vectorThe vec3 containing positional data.
Returns
A vec3 with the transformed data.
getRotation ( object  )

Retrieves the rotation of an object.

Parameters
objectThe object.
Returns
A vec3 containing the current rotation.
getScale ( object  )

Retrieves the scale of an object.

Parameters
objectThe object.
Returns
A vec3 containing the current scale.
getTransformedPosition ( object  )

Retrieves the transformed position of an object.

This includes all transformations done by parents.

Parameters
objectThe object.
Returns
A vec3 containing the current position.
getTransformedRotation ( object  )

Retrieves the transformed rotation of an object.

This includes all transformations done by parents.

Parameters
objectThe object.
Returns
A vec3 containing the current rotation.
getTransformedScale ( object  )

Retrieves the transformed scale of an object.

This includes all transformations done by parents.

Parameters
objectThe object.
Returns
A vec3 containing the current scale.
getTransformedVector ( object  ,
vector   
)

Multiplies the given with the matrix of the given object.

This is useful for converting local to global coordinates.

Parameters
objectThe object.
vectorThe vec3 containing positional data.
Returns
A vec3 with the transformed data.
rotate ( object  ,
axis  ,
angle  ,
"local"   
)

Rotates an object.

The local parameter is optional.
Example:

-- Rotate around X-Axis
rotate(object, {1,0,0}, 90)
Parameters
objectThe object to rotate.
axisAn vec3 containing the axis to rotate around.
angleThe angle to rotate.
localSpecifies if the rotation is in the global or the local space.
setPosition ( object  ,
pos   
)

Sets the position of an object.

Parameters
objectThe object.
posA vec3 containing the new position.
setRotation ( object  ,
rot   
)

Sets the rotation of an object.

Parameters
objectThe object.
rotA vec3 containing the new rotation.
setScale ( object  ,
scale   
)

Sets the scale of an object.

Parameters
objectThe object.
scaleA vec3 containing the new scale.
translate ( object  ,
{x, y, z}  ,
"local"   
)

Translates an object.

The local parameter is optional.
Example:

-- Translate on X-Axis in the local space<br>
rotate(object, {15,0,0}, "local")<br>
Parameters
objectThe object to translate.
axisAn vec3 containing the direction to translate to.
localSpecifies if the translation is in the global or the local space.
updateMatrix ( object  )

Recalculates the matrix of the given object.

Parameters
objectThe object.