I create a component definition:
SUComponentDefinitionRef comp_def = SU_INVALID;
SUComponentDefinitionCreate(&comp_def);
SUComponentBehavior behavior;
behavior.component_always_face_camera = true;
SUComponentDefinitionSetBehavior(comp_def, &behavior);
SUModelAddComponentDefinitions(model, 1, &comp_def);
I am creating my model with SUGeometryInputRef, so I can use SUGeometryInputFaceSetFrontMaterial since I am mapping my texture. I then use SUEnititesFill. I am filling the enitites from SUModelGetEntities. How can I add my component behavior to this model?
I used the following code to create an instance. But it does not do what I want. It pauses before it opens my model and waits for me to click then it places it at the origin. It also does not always face the camera.
SUComponentDefinitionRef comp_def = SU_INVALID;
SUComponentDefinitionCreate(&comp_def);
SUComponentBehavior behavior;
behavior.component_always_face_camera = true;
SUComponentDefinitionSetBehavior(comp_def, &behavior);
SUModelAddComponentDefinitions(model, 1, &comp_def);
SUComponentInstanceRef instance = SU_INVALID;
SUComponentDefinitionCreateInstance(comp_def, &instance);
//SUStringRef name = SU_INVALID;
//SUStringCreateFromUTF8(&name, "always face camera");
SUEntitiesAddInstance(entities, instance, NULL);