My C++ is a bit rusty, so I guess this could be solved by inheritance. I have a class that inherit LogicComponent. This class has a method called “Hit”. The object created by my class is then “hit” by a Raycast that has the result in result->drawable_. This object is a private member of my class.
What’s the best way to handle the scenario: result->drawable_->Hit(…); ?
The class pseudo-looks like this:
class MyClass: public LogicComponent
{
public:
Hit();
private:
StaticModel* object;
CollisionShape* shape;
RigidBody* body;
};
Edit #1: I believe I’ve got this LogicComponent a bit wrong. Guess I should somehow register my class as a component to the engine?
Edit #2: So I’ve tried to understand the LogicComponent structure but I’m not sure how to use it in my case.
My class is like the above but called Chunk, the Chunk class creates my TriangleMesh model and includes the Node/StaticModel/ etc. But I would like to have my Chunk class as a LogicComponent so that I can get my chunk->Update() function automatically called. Not sure if this is a good idea?
Perhaps this is the way to go?
World->nodes[i] = new Node->CreateComponent();
nodes[i]->GetComponent->Init(positionVector3, some_attrs);