This section contains the following topics:
• Object, Material and Shader Handle
Object, Material and Shader Handle
The shader can have access to the owner object, owner material and itself via the SOFTIMAGE|XSI C++ API.
If you need to get the object handle, the GetRequirements function should return TRUE to the RTS_REQUIRE_OBJECTHANDLE requirement.
If you need to get the material handle, your GetRequirements function should return TRUE to the RTS_REQUIRE_LIGHTHANDLE requirement.
To use the shader handle with the SOFTIMAGE|XSI C++ sdk, use the following code:
XSI::CRef shaderCRef = *( (XSI::CRef *) in_pSysParams->m_pShaderHandle); XSI::Shader shader = shaderCRef;
You can use the same technique for the object and material handle.
To access the light handles with the SOFTIMAGE|XSI C++ sdk, use 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;
}
In SOFTIMAGE|XSI you can create and manipulate global states that are stored in the XSI 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::siXGSInteger)
• Floating point values (siXGSStateType::siXGSFloat)
• Pointer values (siXGSStateType::siXGSHandle)
• Vector values (siXGSStateType::siXGSVector4)
• Matrix values (siXGSStateType::siXGSMatrix4)
This section contains the following topics:
• SOFTIMAGE|XSI Factory Display Public Data
To create an graphic sequencer state, use the CGraphicSequencer::CreateState function. For example:
pXGS->CreateState(XSI::siXGSInteger, pInstanceData->m_XGSHandleCGcontextCountName, 0, &pInstanceData->m_XGSHandleCGcontextCount);
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);
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.
To delete a state use the CGraphicSequencer::DeleteState function.
SOFTIMAGE|XSI Factory Display Public Data
To get to the SOFTIMAGE|XSI 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|XSI 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;
|
SOFTIMAGE|XSI v6.01