data structure for object orientation

hi everybody

i want to create some simple object classes
tcube for example
it should have some methods/properties which shall be used to draw and transform it
now the problem is what kind of rotation values i shall store and depending on this how i shall rotate the cube before drawing it (i just want to call tcube.draw and all transformations are done dependend on the properties before it is drawn)
as long as i can see using glrotate (and storing three values for the rotations around x,y,z-axis) does not suit my needs
, because the first rotation is always about world axis (=local axis after glloadidentity) and the following are about local axis and of course the order of rotation problem again
is there any way to do rotations about three axis with just one matrix (perhaps about an arbitrary axis) and i do not mean using three matrices and multiply them because it would raise the same problems
the only thing i came up with is doing it like i did in my camera class that is storing three orthonormal vectors and rotate about them but then i cannot load the identity matrix at the start of the rendering routine which in my opinion makes the whole thing numerical instable (i hope this is the right term) and decrease performance

i hope anybody got what i am talking about since my english is not to good

any help is highly welcome as it took me the last three days searching the net for anything helpful but all i got was either useless or dealt with camera rotations which didn’t help

thx in advance

sorry for posting again but i deleted the previous one and i wanted to give it a new subject since nobody seemed interested in at all

so just tell me i am to stupid or something but plz reply on this (or shall i post this in advanced? i do not think so since it is basic stuff)

Wouldn’t it be easiest to just store the 4x4 OpenGL Modelview matrix? It describes everything (translation, local/global rotation, scaling etc). If you do not want the translation, you can just store the upper left 3x3 part of the matrix, which has the rotation in it.

The order in which rotational operations are performed are “remembered” in this one matrix.

i do not really like this approach, because all rotations then have to be done by the user and have to directly act on the modelview matrix instead of my tcube.draw method
meaning that if you call tcube.rotatewhatever(some nice parameters) this function will have to modify the modelview matrix
when you do some more rotations let’s say 3 before rendering you have to modify the modelview matrix 3 times while when you only have some values (the way i like to have them) you only modify these values in your rotation methods and only do one transform on the modelview matrix
and i don’t like it to have rendering code in the rotation functions because all and every rendering code shall be in the draw functions so that my camera.renderscene function can just call them and the user has just to call this (global?!) rendering function to render the scene and transform the objekts without knowing a bit of opengl

perhaps this is all bulls*** what i am talking (and perhaps i did not really get what you where trying to explain to me), but perhaps you get what i think my problem is

thx for your post and any other posts that will perhaps follow

p.s.:after thinking for somemore time i think this modelview matrix approach can be the right direction and i just up to now could not figure really out how

either i don’t get anything right in my brain at the moment or thinking helps to solve problems

so my guess(i just store a matrix m):

set m to the identity matrix
then when the user transforms something i just multiply m with tranformation matrix created dependend on the transform
when drawing i just use m as the modelview matrix (loadidentity - loadmatrix(m) - multmatrix(m))
this for each object in the scene and that’s it

if so i was such a stupid bast***

Yup, you got that right as far as I can tell. You can store a matrix for each object that will accumulate all your transforms. However you can do one better than glLoadIdentity, etc. If you use glMultMatrix(…) you can add the models matrix to the current matrix. This way you can do general world transforms then add your transforms to it. I don’t know how this will affect performance though.

Code should be something like this (I may have the order wrong).

// Do world transforms.

where YourObject.Draw has code…

glPushMatrix() //Save current matrix.
// Multiply by your matrix.
// Draw your vertices etc.
glPopMatrix(); // Restore matrix.

thx alot
i will definitly try this and will see what performance i can get