Looking through the C API, I am a little confused about creating Groups. As I understand it, conceptually, Groups and ComponentInstances are basically the same - they are both essentially “instances” of a ComponentDefinition.
Now, when creating a new ComponentInstance and adding to an EntitiesRef object, all is very simple:
SUComponentInstanceRef instance = SU_INVALID; SUComponentDefinitionCreateInstance(definition, &instance); SUComponentInstanceSetTransform(instance, &transform); SUEntitiesAddInstance(entities, instance, NULL);
Essentially, you get a pre-existing ComponentDefinitionRef, apply a transformation and you get your instance added to the model.
With a GroupRef, however, there is no equivalent to “SUComponentDefinitionCreateInstance” - ie there is no SUComponentDefinitionCreateGroup. One is instead forced to do this:
SUGroupRef group = SU_INVALID; SUEntitiesAddGroup(entities, group); SUEntitiesRef = SU_INVALID; SUGroupGetEntities(SUGroupRef group, &entities); // Build your entities object here.
In other words, you have to rebuild geometry every time. This is despite the fact that the Group object has the function SUGroupGetDefinition( SUGroupRef group, SUComponentDefinitionRef* component)
, which allows access to the group’s ComponentDefinitionRef object.
Is there a way for me to avoid having to rebuild the geometry in a group every time? Or in other words, to be able to use a ComponentDefinition object and a Transformation struct to create a group, like with ComponentInstance?
Perhaps I have overlooked something - is it possible that a Group is a kind of ComponentInstance (in C++ terms, the ComponentInstance is a parent class of Group)? I would appreciate the clarity!