Entities are the objects in the Engine connecting components together to form meaningful structures. An entity does not by itself hold any data, but is rather a container of handles to a set of components. The components hold the actual data and compose the behavior desired from the entity.
Where a traditional scene graph design might contain something like a basic shape or scene entity looking like this;
struct SceneEntity
{
vec4 position;
bool visible;
Mesh * mesh;
void update();
void render();
}
a similar construct in Cogs.Core would be an Entity with four components attached to it;
The components themselves will not be responsible for the behavior attached to their data, this responsibility is handled by several component systems for all base components.
The creation of entities and components is not usually necessary to perform manually, but is rather delegated to the EntityStore, which contains a registry on how to compose different types of entities and how to create and attach components to entities.
Thus, the process of creating an entity looks like the following:
...
// Global context.
Context * context;
// Create our new entity.
Cogs::Core::EntityPtr myExtrusion = context->store->createEntity("MyExtrusion", "ExtrudeShape");
// The entity lives as long as myExtrusion (shared_ptr) is either in scope or any copies of it are.
// Access a component:
auto transform = myExtrusion->getComponent();
...
Modifying entity data is then done through accessing the components of the entity and how to access components. For complete documentation of the Entity API see the documentation for Cogs.Foundation.