I want to read back transformations of instances. Currently SUComponentInstanceGetTransform of a parsed model always returns identity. Here is my code:
main(number, arguments)
int number; char *arguments[];
{
//SUInitialize();
SUModelRef model = SU_INVALID;
SUModelCreateFromFile(&model, 3[arguments]);
SUEntitiesRef entities = SU_INVALID;
SUModelGetEntities(model, &entities);
SUComponentInstanceRef instances[260];
size_t szinstances;
SUEntitiesGetInstances(entities, 260, instances, &szinstances);
while (szinstances--)
{
struct SUTransformation matrix;
SUComponentInstanceGetTransform(szinstances[instances], &matrix);
struct FloatingPosition {float x,z,y,d;} pos = { .x = matrix.values[12], .z = matrix.values[14], .y = matrix.values[13], .d = matrix.values[15] };
SUStringRef name = SU_INVALID; char szname[260];
SUStringCreate(&name);
SUComponentInstanceGetName(szinstances[instances], &name);
SUStringGetUTF8(name, sizeof szname, szname, (size_t[]) { 0 });
printf("%f, %f, %f - %s\n", pos.x, pos.y, pos.z, name);
}
SUTerminate();
system("PAUSE");
}
Ignore the fact that there is no error checking - I converted the original calls - initially they were in the form: b(SUfunction, args) where b was defined as:
#define b(function,...)(assert(function(__VA_ARGS__)==SU_ERROR_NONE))
The problem is that the above program always returns 0 for the translation of the matrix.
And I’m sure it isn’t zero because I’ve written the model myself with the same program.