Name: Anonymous 2010-10-30 16:24
So, suppose I have a list of things to render, and each thing could potentially have another list of things as a child, such that the thing's child is 'attached' (every transformation on it is relative to its parent).
How would I go about doing that properly? I've tried a combination of
I thought I understood the logic behind matrix stacks, but clearly not. Help me, /Xarn/, you're my only hope!
How would I go about doing that properly? I've tried a combination of
pushMatrix and popMatrix that doesn't quite work (children's coordinates and stuff stay global):void draw_many (Thing *x) {
while (x) {
glPushMatrix();
glTranslate (x->pos); /* and friends */
glDraw (x->stuff);
if (x->child)
draw_many (x->child);
glPopMatrix();
x = x->next;
}
}
void draw_everything() {
setup_gl_shite();
glLoadIdentity();
draw_many (first_thing);
finish_gl_shite();
}I thought I understood the logic behind matrix stacks, but clearly not. Help me, /Xarn/, you're my only hope!