If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#1 |
|
Retarded moron
|
Can someone please tell me how to simplifying this without reverting to me creating a scenegraph?
What do you guys think? http://members.optusnet.com.au/ksaho...ent2/Robot.exe keys 0-9 to move joints Code:
void Render::drawObjs()
{
glEnable(GL_LIGHT0);
glLightf(GL_LIGHT0, GL_AMBIENT, 0.6f);
glPushMatrix();
{
drawHead();
glTranslated(0, -1.5, 0);
glPushMatrix();
{
drawNeck();
glTranslated(0, -1.5, 0);
glPushMatrix();
{
drawTorso();
glPushMatrix();
{
glTranslated(.6, .4, 0);
drawJoint();
glPushMatrix();
{
glTranslated(1, -2, 0);
drawArm();
glPushMatrix();
{
glTranslated(.2, -.6, 0);
glScaled(7, 1, 1);
drawJoint();
}
glPopMatrix();
}
glPopMatrix();
}
glPopMatrix();
glPushMatrix();
{
glTranslated(-0.6, .4, 0);
drawJoint();
glPushMatrix();
{
glTranslated(-1, -2, 0);
drawArm();
glPushMatrix();
{
glTranslated(-.2, -.6, 0);
glScaled(7, 1, 1);
drawJoint();
}
glPopMatrix();
}
glPopMatrix();
}
glPopMatrix();
}
glPopMatrix();
}
glPopMatrix();
}
glPopMatrix();
}
__________________
I eat coffee. |
|
|
|
|
|
#2 |
|
Regular
Join Date: Feb 2002
Location: California
Posts: 4,732
|
No matter what, you've got a scene graph. It's either implicit, or explicit. Yours in the above code is implicit.
You could do it in two other ways that look cleaner than one mega-method. #1 make the individual methods themselves responsible for drawing children. This is sort of an implicit scene graph represented on the call stack Code:
drawHead()
push/translate
drawNeck()
pop
drawNeck()
push/translate
drawTorso()
pop
drawTorso
push/translate
drawJoint()
etc
|
|
|
|
|
|
#3 |
|
Retarded moron
|
Thanks.
The second mode looks a lot better.
__________________
I eat coffee. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|