Designing 3D Robots

Hi OpenGL Community,

I am working ina final project that consists in a 3D Robot Modeller where the user can build his own robots linking pieces of
the robot like we do when we are using lego.
My class robot is a set of component where the component can be
specialiazed in 4 classes: The first rotates the robot piece in one axis, the second rotates in two axis, the third rotates in 3 axis and the last makes translation movements like hands do for example.
When I have to display the robot I have to display the components in the right order using glPushMatrix() and glPopMatrix().

(Current situation of the project)
Ex: (C++)

Component * base = new Component;
CFDegree * arm = new CFDegree; // One level of movement (Z)
CSDegree * forearm = new CSDegree; // Two levels of movement (Z,X)
CTransl * hand = new CTransl; // Hands translates to open and

Robot * robot = new Robot;

robot->display(); // draws the robot

PS:When its just a robot arm, the robot can be a list of components …
But Imagine if its any kind of robot with a body, head, n-arms, n-
forearms and n-hands …

The challenge is what kind of data structure should I have to use for
my robot (Tree of components, Graph of components, list …) ?
And How can I do to create a robot with its pieces in C++ without
having to declare its components as objects ?

If someone knows something about this in a website, tutorial or
book … please let me know

thanks in advance


I’m curious why you ask how to create your robot without declaring its component pieces as C++ objects…

Object-oriented design/programming are tools to manage complexity, to hide all the nasty, niggling details away so you can concentrate on the bigger picture. There will be countless ways to acheive your desired results without using OOD/OOP practices, but then there are also countless ways to build a jumbo jet using aluminum foil and bailing wire - the only difference is it’ll take 73,000 times as long, will be impossible to maintain, and nobody in their right mind would ever fly in it.

The robot system you described seems to me to be the perfect example of where an object-oriented design would be exceptionally useful.

I have to guess that others on this board will probably echo these sentiments.

Good luck


Hi Mike,

I’d like something like this:

Robot * robot = new Robot;

Its just an example where instead of declaring the components, its is like if I am calling its components by their names.
Think of “BASE1”, “ARM1” like component names.(Identification)
I have to create some kind of identification because the user can add new components to link the robot.
A component class can be created reading information in a DXF file, for example.
I spent a lot of time thinking about this.
I dont think its so simple maybe I didnt explain it in a correct way.
But anyway, if somebody knows something related with this problem please tell me.

thanx again.