Translation of Object Plug-ins

The following steps describe how to enable custom translation of object plug-ins (derived from GeomObject or ShapeObject) to a mental ray geometry shader. Geometry shaders are functions that procedurally create geometric objects. They are different from most other shaders because they do not return a color, but a reference to the object or instance group created by the shader. For more information on writing geometry shaders see the mental ray reference documentation.

Step 1: Add the class imrGeomShaderTranslation to the list of inherited classes of the plug-in.

Step 2: Implement InterfaceServer::GetInterface() to return a pointer to itself as an imrGeomShaderTranslation. Here is an example:

BaseInterface* YourTexmapPlugin::GetInterface(Interface_ID id) {
    if(id ==  IMRGEOMSHADERTRANSLATION_INTERFACE_ID) {
        return static_cast< imrGeomShaderTranslation*>(this);
    }
    else {
        return NULL;
    }
}

Step 3: Implement imrGeomShaderTranslation::GetGeomShader() to return a pointer to an object that translates to a geometry shader. The typical implementation will return a pointer to a Texmap that implements the imrShaderTranslation interface to translate itself to a specific geometry shader.

Step 4: Implement imrGeomShaderTranslation::GetScale(). In many cases, returning a scale of (1,1,1) is sufficient. For specific cases, however, where the geometry shader builds objects of a static size (that cannot be changed by passing a parameter to the shader), then you might want to expose a scale parameter in the UI and use this method to force the mental ray translator to apply that scale to the transform matrix of the instance.