The parameters of the property page are stored in an array of 32 bit integers. This array can be cast to a more meaningful structure that can be accessed easily in the shader code. For example, if you had a property page with the following definition:
Parameter "inner_ring" input
{
GUID = "{E15724EF-4A13-403C-BDEB-FEE3930DB03E}";
Type = scalar;
Value = 1.0;
}
Parameter "outer_ring" input
{
GUID = "{E5FA4D50-C71A-4CFB-BB5C-C252850C1598}";
Type = scalar;
Value = 1.1;
}
Parameter "tex" input
{
GUID = "{4C03FB2C-67C0-481B-8A07-C7E5172E165E}";
Type = texture;
}
Parameter "color" input
{
GUID = "{2BC32197-E76A-4B56-BFEA-761E9C552DD3}";
Type = color;
Value = 1.0 0.0 0.0 0.5;
}Then you can create a structure as follows:
typedef struct tagMyStruct
{
float inner_ring;
float outer_ring;
XSI_RTS_ColorRGBAf color;
XSI_RTS_Texture tex; // textures are always packed in last
} MyStruct;
![]()
|
Softimage packs the parameters in exactly the same order as they are defined in the SPDL with the exception of texture parameters, which are always written at the end of the struct. |
And in the code itself, it is just a simple matter of casting the property page void pointer to the structure.
MyStruct *l_pPPG = (MyStruct *) in_pParams;
To to support 64-bit platforms, realtime shaders must use the #pragma pack directive to remove padding between structure fields:
#pragma pack(push, 1)
// PPG structures...
#pragma pack(pop)On 64-bit platforms, all structures used to construct a property page must be compiled without padding between the structure fields. This is because pointers to PPG structures are initialized by type-casting a void pointer:
MyPPG * my_ppg = (MyPPG*) in_pVoid;
The #pragma pack directive is not necessary on 32-bit platforms, because on 32-bit platforms a PPG contains only floats (4 bytes), longs (4 bytes), and pointers (4 bytes), and therefore the structures never contain padding. But on 64-bit platoforms, where pointers are 8 bytes, if you don't force the compiler to remove the automatic padding, the struct may contain padding. This padding is not considered when initializing the void pointer (in_pVoid). Therefore, the direct type casting would not work.
Mapping SPDL parameters to C++
Here is a table of mapping for SPDL parameters.
|
SPDL type |
C++ type |
Number of bytes (32-bit platforms) |
Number of bytes (64-bit platforms) |
|
Boolean |
LONG |
4 |
4 |
|
Color |
XSI_RTS_ColorRGBAf |
16 |
16 |
|
Filename |
unsigned char * |
4 |
8 |
|
Integer |
LONG |
4 |
4 |
|
Matrix |
float[16] |
64 |
64 |
|
Scalar |
float |
4 |
4 |
|
String |
unsigned char * |
4 |
8 |
|
Texture |
XSI_RTS_Texture |
32 |
40 |
|
Texture space |
LONG |
4 |
4 |
|
Vector |
float[4] |
16 |
16 |
Autodesk Softimage v7.5