Skip to content

Transform nodes

zeganstyl edited this page Sep 18, 2020 · 1 revision

Transform nodes contains spatial data to define object position, orientation and etc in space.

Each such node must implement ITransformNode interface.

Default transform node in Thelema is Node. It contains TRS data: position (translation), rotation and scale. These data is used to build worldMatrix (also known as model matrix). worldMatrix matrix is global and can be passed to shader.

Transform node can have children. Child node contains local transform data and, when updated, will compute the global world matrix by applying parent's matrix to its local data.

After changing data of node, you have to call updateTransform() to update matrix. You can specify parameter recursive as true, to update whole children tree.

Some transform node implementations may not have full TRS data. For example it may contain only position, and world matrix will be build with default rotation (0, 0, 0, 1) and scale (1, 1, 1).

You can create custom transform node class that must implement ITransformNode and you can there define transform data that you want.

If you referencing to node, it is recommended to use ITransformNode as type in class properties or method parameters.

val root = Node()
root.scale.set(0.5f, 0f, 0f)

val child = Node()
child.position.set(5f, 0f, 0f)

root.addChildNode(child)
root.updateTransform(recursive = true)

println(child.worldMatrix)
Clone this wiki locally