GetBoundingBox

When the transformationMatrix is given, it will fill an array of 12 double values.
When the transformationMatrix is left empty and both startVector and endVector are given the boundingbox without transformation is calculated and returned.

Syntax

//
//   Strong typing definition
//
bool            GetBoundingBox(
                        OwlInstance             owlInstance,
                        double                  * transformationMatrix,
                        double                  * startVector,
                        double                  * endVector
                    );

static  inline  bool    GetBoundingBox(
                                OwlInstance             owlInstance,
                                double                  * startVector,
                                double                  * endVector
                            )
{
    return  GetBoundingBox(
                    owlInstance,
                    nullptr,                            //    transformationMatrix
                    startVector,
                    endVector
                );
}


//
//   Weak typing definition
//
bool    __declspec(dllexport) __stdcall GetBoundingBox(
                                                int64_t                 owlInstance,
                                                double                  * transformationMatrix,
                                                double                  * startVector,
                                                double                  * endVector
                                            );

static  inline  bool    GetBoundingBox(
                                int64_t                 owlInstance,
                                double                  * startVector,
                                double                  * endVector
                            )
{
    return  GetBoundingBox(
                    owlInstance,
                    nullptr,                            //    transformationMatrix
                    startVector,
                    endVector
                );
}
    

Property owlInstance

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.

Property startVector

Size: 64 bit / 8 byte (reference)
The startVector is expected to be a 3 element double value allocated by the host (i.e. 24 bytes). The function will fill in X, Y, Z as the start vector.

Property endVector

Size: 64 bit / 8 byte (reference)
The endVector is expected to be a 3 element double value allocated by the host (i.e. 24 bytes). The function will fill in X, Y, Z as the end vector.

Example (based on pure API calls)

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

#include    "./include/engine.h"
#include    <assert.h>

void    main()
{
    int64_t model = CreateModel();

    if (model) {
        //
        //  Classes 
        //
        int64_t classBox = GetClassByName(model, "Box");

        //
        //  Datatype Properties (attributes)
        //
        int64_t propertyLength = GetPropertyByName(model, "length"),
                propertyWidth = GetPropertyByName(model, "width"),
                propertyHeight = GetPropertyByName(model, "height");

        //
        //  Instances (creating)
        //
        int64_t instanceBox = CreateInstance(classBox, nullptr);

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

        SetDatatypeProperty(instanceBox, propertyLength, &length, 1);
        SetDatatypeProperty(instanceBox, propertyWidth, &width, 1);
        SetDatatypeProperty(instanceBox, propertyHeight, &height, 1);

        double  transformationMatrix[12],
                startVector[3],
                endVector[3];
        GetBoundingBox(instanceBox, transformationMatrix, startVector, endVector);

        assert(endVector[0] == 2.8);

        length = 4.1;
        SetDatatypeProperty(instanceBox, propertyLength, &length, 1);

        assert(endVector[0] == 2.8);

        GetBoundingBox(instanceBox, transformationMatrix, startVector, endVector);

        assert(endVector[0] == 4.1);

        //
        //  Next to the minimum bounding box also the AABB can be retrieved through startVector / endVector
        //
        GetBoundingBox(instanceBox, nullptr, startVector, endVector);

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