Original Post
Hey. I'm doing an intro to 3d programming unit at uni and we're using C++ with opengl. I've decided to make up shape classes to speed up the work that I'll be doing. I'm a bit unsure how to structure the shape hierarchy though. I have the base Shape_3d abstract class:At this point, I am unsure where to go next. So, I have a few questions: I plan to have some shapes that have a vector of vertices (e.g. cube)... is this a good idea or should the vertices for cubes and stuff be rendered/transformed dynamically? If I do store the vertices in a vector, should I make a base class that saves each class declaring a vector of vertices? If I want to have a set of functions to translate/scale/rotate a shape after it is constructed, should I put them in a namespace or a base class as virtual/pure virtual functions? I want to be mindful of the "model inheritance through "has-a" or "is-implement-in-terms-of" through composition" rule of thumb (as seen in Effective C++). Is it wise/possible to do this in my scenario? Basically I have a whole heap of behaviour I want derived shape classes to be able to have and I want to a nice way to implement it. Cheers.
class Shape_3d : public GL_Renderable
{
public:
Shape_3d();
Shape_3d(const Point_3d& pos);
virtual ~Shape_3d() = 0;
virtual void Render() = 0;
const Point_3d& Get_Pos() const;
protected:
Point_3d pos;
};