Hello everyone,
I'm programming a
simple gaz particule simulator, (in C++) and I wonder what is the best way to link the UI with my other classes.
Here is my conception, any comments or advices are welcome :)
We simulate particules moving in a room.The view should be able to show the particules moving in an
openGl view, or to describe their position in
text mode.
Here is what I have for now : (question below)
A data structure
Particule { Speed ; Position ; Mass };
A data structure
Room { Width ; Heigth ; Length };
A class Motion that has one logic method responsible for moving the particule for a given time :
Motion {
void move( vector<Particule*> , Room* , Time dt );
};
A class Init that gives proper Positon and Speed to new particule :
Init {
void init(Particule* , Room*);
};
Questions :
1) Should I give to each particule a view_component ?My particule are of different kind (Neon, Argon, Silver, etc).
That changes nothing for the Motion part, but I would like to display them differently.
What's a good way to do this ? Should I give to each particule a view_component ? If so, does the motion class have to know ?
I also need somewhere to store the particules : if they have a part specific to their graphical representation, how could I instanciate them from the App and still be able to change the UI as a plug-in ?
2) Or something else ?I tried a method :
void render(vector<Particule*> , Room*);
but once the type of a specific particule is lost I can't get it back (no RTTI).
Thank you for your advices :)