Communicating with Softimage

This section contains the following topics:

• Object, Material and Shader Handle

• Graphic Sequencer States

Object, Material and Shader Handle

The shader can have access to the owner object, owner material and itself via the Softimage C++ API. Every callback function provides access to the IRTSExecutionState object which allows you to get handles via these methods:

• IRTSExecutionState::GetShader

• IRTSExecutionState::GetMaterial

• IRTSExecutionState::GetPrimitive

To use the shader handle with the Softimage C++ API, use the following code:

    XSI::CRef shaderCRef = *( (XSI::CRef *) in_pExecState->GetShader);
    XSI::Shader shader = shaderCRef;

You can use the same technique for the object and material handle.

Cameras and Lights

The tagXSI_RTS_SceneData structure allows you to access camera and light information via its m_sCamera and m_pLights members which return the tagXSI_RTS_Camera and tagXSI_RTS_Light structs. The tagXSI_RTS_SystemParams (available from the IRTSExecutionState) provides access to the tagXSI_RTS_SceneData structure.

For example, you can access the light handles with the Softimage C++ API, using the following code:

    for (int i=0; i < in_pSysParams->m_SceneData->m_iNbLights; i++) {
        XSI::CRef lightRef = *(XSI::CRef*)in_pSysParams->m_SceneData->m_pLights[i].m_pchID;
        XSI::Light light = lightRef;
    }

Graphic Sequencer States

In Softimage you can create and manipulate global states that are stored in the Softimage Graphic Sequencer (XGS). These states act as “cookies”. The states can be accessed by a realtime shader, a C++ API plug-in or a graphic sequencer plug-in. This is a mechanism that is designed to:

• Share public data between shaders or plug-ins

• Store per viewport data

XGS states can store the following data:

• Integer values (siXGSStateType::siXGSStateType)

• Floating point values (siXGSStateType::siXGSFloat)

• Pointer values (siXGSStateType::siXGSHandle)

• Vector values (siXGSStateType::siXGSVector4)

• Matrix values (siXGSStateType::siXGSMatrix4)

This section contains the following topics:

• Creating States

• Getting the State Handle

• Getting the State Value

• Deleting a State

• Softimage Factory Display Public Data

Creating States

To create an graphic sequencer state, use the CGraphicSequencer::CreateState function. For example:

    pXGS->CreateState(XSI::siXGSInteger, pInstanceData->m_XGSHandleCGcontextCountName, 0, &pInstanceData->m_XGSHandleCGcontextCount);

Getting the State Handle

Before you start manipulating states, you need to get their handle. To do so, use CGraphicSequencer::GetStateHandle . For example:

    pXGS->GetStateHandle(XSI::siXGSHandle, pInstanceData->m_XGSHandleName, &pInstanceData->m_XGSHandle);

Getting the State Value

To get the state value, you need to get the state handle with GetStateHandle. You can then use CGraphicSequencer::GetStateValue . For example:

    pXGS->GetStateValue(XSI::siXGSHandle, pInstanceData->m_XGSHandle, &pInstanceData->m_Program);

The state value is context dependant. There is one value per viewport. So for example, if you have an integer state, it could be 0 in viewport A, 43 in viewport B, and so on. This is particularly useful if each viewport don’t share resources, such as when they run in DirectX mode.

Deleting a State

To delete a state use the CGraphicSequencer::DeleteState function.

Softimage Factory Display Public Data

To get to the Softimage factory public data, include the FactoryDisplayPublicData.h file.

These are all handle states.

State ID | Description | Structure
XSI_VIEWDATA | Viewport display information. |
    typedef struct tagXSI_ViewData
    {
       // colors
       float   BackgroundColor[4];
       float   ViewportColor[4];

       // sizes
       LONG  Width;
       LONG  Height;

       // viewing gizmos
       int  DrawAxis;
       int   DrawRulers;
       int  DrawGrid;
       int   DrawSafeGuide;

       // view Data
       UINT   CameraType;
       UINT   CameraIndex;
       UINT   CameraProjType;

       // View ID
       UINT  ID;
       TCHAR   ViewName[1024];

    } XSI_ViewData;
XSI_CAMERADISPLAY | Camera display playback information. |
    typedef struct tagXSI_CameraDisplay
    {
       // fast playback
       LONG   FastPlaybackMode;
       LONG   FastPlaybackWireframe;

    } XSI_CameraDisplay;
XSI_OPENGLDATA | Viewport OpenGL drawing context. |
    typedef struct tagXSI_OpenGLData
    {
       // primary context
       HDC    hdc;
    } XSI_OpenGLData;
XSI_HWRENDERINGDATA | Hardware rendering information. Softimage is rendering when the Activate flag is TRUE. |
    typedef struct tagXSI_HWRenderingData
    {
       bool    Activate;
       int    Width;
       int    Height;
       unsigned char*  Buffer;
       unsigned char*  BigBuffer;
       wchar_t  RenderEngineName[1024];
    } XSI_HWRenderingData;

Autodesk Softimage v7.5