GetRelativeTransformation

This function returns the relative transformation matrix between two instances, i.e. in practise this means the matrices connected to the Transformation instances in the path in between.
The matrix is only given when a unique path through inverse relations can be found, otherwise the identity matrix is returned. owlInstanceHead is allowed to be not defined, i.e. zero.

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetRelativeTransformation")]
public static extern void GetRelativeTransformation(Int64 owlInstanceHead, Int64 owlInstanceTail, out double transformationMatrix);    

Property owlInstanceHead

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property owlInstanceTail

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property transformationMatrix

Size: 64 bit / 8 byte (reference)
The transformationMatrix is expected to be nullptr or a 12 element double value allocated by the host (i.e. 96 bytes / 12 doubles). The matrix values are defined column by column as is common for DirectX, OpenGL and VULKAN, i.e. _11, _12, _13, _21, ... _42, _43.

Example

Here you can find code snippits that show how the API call GetRelativeTransformation can be used.

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classBox = Engine.x86_64.GetClassByName(model, "Box"),
                classMatrix = Engine.x86_64.GetClassByName(model, "Matrix"),
                classMatrixMultiplication = Engine.x86_64.GetClassByName(model, "MatrixMultiplication"),
                classTransformation = Engine.x86_64.GetClassByName(model, "Transformation");

        //
        //  Object Properties (relations)
        //
        Int64   propertyFirstMatrix = Engine.x86_64.GetPropertyByName(model, "firstMatrix"),
                propertyMatrix = Engine.x86_64.GetPropertyByName(model, "matrix"),
                propertyObject = Engine.x86_64.GetPropertyByName(model, "object"),
                propertySecondMatrix = Engine.x86_64.GetPropertyByName(model, "secondMatrix");

        //
        //  Datatype Properties (attributes)
        //
        Int64   property_42 = Engine.x86_64.GetPropertyByName(model, "_42"),
                propertyLength = Engine.x86_64.GetPropertyByName(model, "length"),
                propertyWidth = Engine.x86_64.GetPropertyByName(model, "width"),
                propertyHeight = Engine.x86_64.GetPropertyByName(model, "height");

        //
        //  Instances (creating)
        //
        Int64   instanceBox = Engine.x86_64.CreateInstance(classBox, (string) null),
                instanceMatrixI = Engine.x86_64.CreateInstance(classMatrix, (string) null),
                instanceMatrixII = Engine.x86_64.CreateInstance(classMatrix, (string) null),
                instanceMatrixIII = Engine.x86_64.CreateInstance(classMatrix, (string) null),
                instanceMatrixMultiplication = Engine.x86_64.CreateInstance(classMatrixMultiplication, (string) null),
                instanceTransformationI = Engine.x86_64.CreateInstance(classTransformation, (string) null),
                instanceTransformationII = Engine.x86_64.CreateInstance(classTransformation, (string) null);

        Engine.x86_64.SetObjectProperty(instanceTransformationI, propertyObject, ref instanceTransformationII, 1);
        Engine.x86_64.SetObjectProperty(instanceTransformationI, propertyMatrix, ref instanceMatrixMultiplication, 1);

        Engine.x86_64.SetObjectProperty(instanceTransformationII, propertyObject, ref instanceBox, 1);
        Engine.x86_64.SetObjectProperty(instanceTransformationII, propertyMatrix, ref instanceMatrixIII, 1);

        Engine.x86_64.SetObjectProperty(instanceMatrixMultiplication, propertyFirstMatrix, ref instanceMatrixI, 1);
        Engine.x86_64.SetObjectProperty(instanceMatrixMultiplication, propertySecondMatrix, ref instanceMatrixII, 1);

        double  length = 2.8,
                width = 1.3,
                height = 1.4;

        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyWidth, ref width, 1);
        Engine.x86_64.SetDatatypeProperty(instanceBox, propertyHeight, ref height, 1);

        //
        //  As a simple case we only apply vertical translation
        //
        double  verticalTranslationMatrixI = 3.05,
                verticalTranslationMatrixII = 2.2,
                verticalTranslationMatrixIII = 7.4;

        Engine.x86_64.SetDatatypeProperty(instanceMatrixI, property_42, ref verticalTranslationMatrixI, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMatrixII, property_42, ref verticalTranslationMatrixII, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMatrixIII, property_42, ref verticalTranslationMatrixIII, 1);

        Engine.x86_64.UpdateInstance(instanceTransformationI);

        double[]  transformationMatrix = new double[12];
        Engine.x86_64.GetRelativeTransformation(instanceTransformationI, instanceBox, out transformationMatrix[0]);
        System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixI + verticalTranslationMatrixII + verticalTranslationMatrixIII);

        Engine.x86_64.GetRelativeTransformation(instanceTransformationII, instanceBox, out transformationMatrix[0]);
        System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixIII);

        Engine.x86_64.GetRelativeTransformation(instanceTransformationI, instanceTransformationII, out transformationMatrix[0]);
        System.Diagnostics.Debug.Assert(transformationMatrix[3 * 3 + 1] == verticalTranslationMatrixI + verticalTranslationMatrixII);

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin");
        Engine.x86_64.CloseModel(model);
    }
}