1

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);
ecw
  • 11
  • 1
  • You say you create a definition, but then you generate your entities in the model entities instead of the definition's entities? From the sound of it you are creating an empty definition and then adding the faces to the model root. Sounds like you should use `SUComponentDefinitionGetEntities` instead. – thomthom May 11 '15 at 19:03
  • I tried it that way. Then I filled the SUComponentDefinition entities, but when I saved my model and tried opening it, it gave me the error "cannot open empty component" – ecw May 12 '15 at 12:28

0 Answers0