Pivot API Changes

The internal implementation of pivots has been improved, and with this comes some new interfaces to simplify Lua interaction with Assemblies that are affected by a pivot point.

Creation

To add a pivot point to an Assembly, use

local target = vrTreeRoot():find("Scenes/My/Node")
context_create_pivot(target, 0)
This adds a child node called "Pivot" to the target assembly node. This assembly node now behaves as if its origin is located at the pivot location.

The second argument specifies whether to place the pivot at the existing origin (0), or at the centre of the assembly bounding box (1).

Transforms

To set the world or local transform of a node (pivot point as origin):

target.WorldTransform = myNewWorldMatrix --world
--or
target.Transform = myNewLocalMatrix --local
To set the world of local transform of a node, ignoring the pivot point:

target.UnpivotedWorldTransform = myNewWorldMatrix --world
--or
target.UnpivotedTransform = myNewLocalMatrix --local
To set the transform of the pivot itself (this will not change the final position of target):

target.Pivot.WorldTransform = myNewWorldMatrix --world
--or
target.Pivot.Transform = myNewLocalMatrix --local
To set the post-transform of the pivot (similar to target.UnpivotedTransform but leaves the pivot point in place)

target.Pivot.UnpivotedWorldTransform = myNewWorldMatrix --world
--or
target.Pivot.UnpivotedTransform = myNewLocalMatrix --local

Advanced Example

Moving an object around a pivot

-- Ensure a pre-defined fix position of the target assembly for comparing results 
target.UnpivotedWorldTransform = vrMat4()
target.UnpivotedWorldTransform.Position = {0,-2,0}
-- describe the pivot space ..
target.Pivot.WorldTransform.Position = {0,1,0}
target.Pivot.WorldTransform.Rotation = {0,0,0}
-- Rotate the target assembly around its pivot point
target.WorldTransform.Rotation = {0,0,20}
-- Rotate the target assembly around its world transform (Set on pivot node so the position of the pivot wont change)
target.Pivot.UnpivotedWorldTransform.Rotation = {0,0,0}


No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtree_cppCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API