How to connect geometry data with object definitions/instances


Basically I have groups sharing the same vertex buffer and index buffer and some local transformations. All of the groups create a component definition.

Then separately I want to create instances of each object with some additional transformations. That would be the component instance.

How can I map all of this into actual code?

I’ve read about SUComponentDefinitionRef and SUComponentInstanceRef and SUGeometryInputRef and SUEntitiesRef and SUGroupRef - I just don’t know how to put them into actual code.

I’ve came a long way since and I’m currently creating an array of SUComponentInstanceRef using SUComponentDefinitionCreate. Then I’m obtaining the definition entities using SUComponentDefinitionGetEntities. After that I’m creating geometry and then SUEntitiesFill. Next I’m creating instances using SUComponentDefinitionCreateInstance of specific objects with transformation. Then I’m adding this to the entity from the component definition which the instance was created from. But it seems I’m doing something wrong since when I import the object in sketchup it says it is empty. Every method is being checked for SU_ERROR_NONE (with assert) so that is obviously not the problem. I feel like the problem is only the definitions get added and no actual geometry gets included.

What I feel like right now is that I need somehow to add multiple geometry inputs to the model entities since they are the only ones that get registered. I have no idea how to get SUComponentDefinitionGetEntities to work.