My entity system work like that:
---------------------------------------------------------------------------
Entity* entity = world->createEntity();
MeshComponent* mesh = entity->addComponent<MeshComponent>(material);
mesh->loadFromFile("monkey.obj");
PhysicComponent* physic = entity->addComponent<PhysicComponent>();
physic->setMass(5.4f);
physic->setVelocity( 0.5f, 2.f );
---------------------------------------------------------------------------
class RenderingSystem
{
private:
Scene scene;
public:
void onEntityAdded( Entity* entity )
{
scene.addMesh( entity->getComponent<MeshComponent>() );
}
}
class PhysicSystem
{
private:
World world;
public:
void onEntityAdded( Entity* entity )
{
world.addBody( entity->getComponent<PhysicComponent>()->getBody() );
}
void process( Entity* entity )
{
PhysicComponent* physic = entity->getComponent<PhysicComponent>();
}
}
---------------------------------------------------------------------------