GetCenter

This function calculates the center of an instance. For performance reasons it is beneficial to call it with vertex and index buffer when the arrays are calculated anyway or Volume and Area are needed.

There are two ways to call GetCenter:
  vertexBuffer and indexBuffer are both zero: in this case the instance will be
    recalculated when needed. It is expected the client does not
    need the arrays itself or there is no performance issue.
  vertexBuffer and indexBuffer are both given: the call is placed directly after
    updateBuffer calls and no structural change to depending instances have
    been done in between. The transformationMatrix array is not needed,
    even if it is being used due to not giving any performance gain to this
    operation.

Note: internally the call does not store its results, any optimization based on known
    dependencies between instances need to be implemented on the client.
Note: in case precision is important and vertex array is 32 bit it is advised to
    set vertexBuffer and indexBuffer to 0 even if arrays are existing.

Syntax

//
//   Strong typing definition
//
void            GetCenter(
                        OwlInstance             owlInstance,
                        const void              * vertexBuffer,
                        const void              * indexBuffer,
                        double                  * center
                    );

static  inline  void    GetCenter(
                                OwlInstance             owlInstance,
                                double                  * center
                            )
{
    const void * vertexBuffer = nullptr,
                * indexBuffer = nullptr;
    GetCenter(
            owlInstance,
            vertexBuffer,
            indexBuffer,
            center
        );
}


//
//   Weak typing definition
//
void    __declspec(dllexport) __stdcall GetCenter(
                                                int64_t                 owlInstance,
                                                const void              * vertexBuffer,
                                                const void              * indexBuffer,
                                                double                  * center
                                            );

static  inline  void    GetCenter(
                                int64_t                 owlInstance,
                                double                  * center
                            )
{
    const void * vertexBuffer = nullptr,
                * indexBuffer = nullptr;
    GetCenter(
            owlInstance,
            vertexBuffer,
            indexBuffer,
            center
        );
}
    

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 vertexBuffer

Size: 32 bit / 4 byte (reference)
The array of vertices, this array is allocated by the host application. Depending on SetFormat() the array exists of 32 bit (4 byte) single precision floats or 64 bit (8 byte) double precision floats. Each vertex elements exists of several elemens, i.e. X, Y, Z values, but optionally also nX, nY, nZ, texture coordinates, bitangent / binormal coordinates, colors etc. What is contained is defined by SetFormat() and can be retrieved via GetFormat(). The host application has to make sure enough memory is allocated for the vertexBuffer array.

Property indexBuffer

Size: 32 bit / 4 byte (reference)
The array of indices, this array is allocated by the host application. Depending on SetFormat() the array exists of 32 bit (4 byte) integers or 64 bit (8 byte) integeres.

Property center

Size: 32 bit / 4 byte (reference)
The center 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 center coordinates.