Skip to content
On this page

Transforms

The Simplygon API allows the user to do transformations on geometry data and scene nodes.

IMatrix4x4

The IMatrix4x4 class is used to represent a standard or homogeneous 4x4 matrix inside the Simplygon API. The matrix is stored in a row major form. The class provides methods for accessing and setting matrix elements, transposing a matrix, calculating an inverse and can be used to transform 3D homogeneous coordinates.

ITransform3

The ITransform3 class is a utility class to setup a 4x4 homogeneous transform in the Simplygon API. You can use the ITransform3 to concatenate transformations. Transforms can be performed by calling AddTranslation, AddRotation and AddScaling. AddRotation works like a quaternion where you pass in the angle of rotation in radians and set the axis along which to rotate. The PreMultiply function can be use to add a transform around the current transform and PostMultiply can be used to add a transform inside the current transform. The default behavior is set to do post multiplication.

Example - Transformation

cpp
void TransformGeometryData(spGeometryData geom)
{
    spTransform3 xform = sg->CreateTransform3();
    // Set the tranfrom to use pre multiply.
    xform->PreMultiply();
    // Do a translations transformation.
    xform->AddTranslation(0,5.0,0.0);
   
    // ... do other transformations ...
    geom->Transform(xform->GetMatrix());
   
}
python
def TransformGeometryData(geom):
    # create a transform node for affine transformations
	xform = sg.CreateTransform3()
	
    # Set the tranfrom to use pre multiply.
    xform.PreMultiply()
	
    # Add a translations transformation, 5 units in y direction
    xform.AddTranslation( 0.0 , 5.0 , 0.0 )
   
    # Transform geometry
    geom.Transform(xform.GetMatrix())
csharp
void TransformGeometryData(spGeometryData geom)
{
    spTransform3 xform = sg.CreateTransform3();
    // Set the tranfrom to use pre multiply.
    xform.PreMultiply();
    // Do a translations transformation.
    xform.AddTranslation(0, 5.0f, 0.0f);

    // ... do other transformations ...
    geom.Transform(xform.GetMatrix());
}