glRotate and glPushMatrix

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jhr1021
Posts: 8
Joined: Fri Apr 10, 2009 11:48 pm

glRotate and glPushMatrix

Post by jhr1021 »

Hello,

I have trouble in changing OpenGL code to Irrlicht. I don't know how to change the below code to Irrlicht. Would you let me know how to convert OpenGL code to Irrlicht?

for(int i = 1; i < NUM_LINKS; i++)
{
glPushMatrix();
glTranslatef(t[0], t[1], t[2]);
glRotatef(angle, axis[0], axis[1], axis[2]);
glCallList(meshList + i);
glPopMatrix();
}


=> It didn't work. ^^;;;

for(nCnt = 1; nCnt < NUM_LINKS; nCnt++)
{
jointPos = vector3df(t[0], t[1], t[2]);
rot.fromAngleAxis(angle, vector3df(axis[0], axis[1], axis[2]));
rot.toEuler(jointRot);

ptrSceneNode = g_ptrSmgr->getSceneNodeFromId(nCnt);
ptrSceneNode->setPosition(jointPos);
ptrSceneNode->setRotation(jointRot);
}
wuallen
Posts: 67
Joined: Thu Jan 25, 2007 3:07 am
Location: Shanghai

Post by wuallen »

It is that I will ask. Opengl coordinate becomes Irrlicht coordinate, is it ask?
jhr1021
Posts: 8
Joined: Fri Apr 10, 2009 11:48 pm

Post by jhr1021 »

wuallen wrote:It is that I will ask. Opengl coordinate becomes Irrlicht coordinate, is it ask?
Yes, right!!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The code should be quite ok, however you're dealing with different coordinate systems here. OpenGL uses a right-handed y-up, while Irrlicht uses left-handed. This means that you have to negate one or all three coord elements of a vector. Rotations are much more involved, although using angle and axis should work almost the same: Invert both the axis and the angle.
Maybe you can also write up your current results so we can know how much is already working. Maybe using a skeletal animation would be also much simpler.
jhr1021
Posts: 8
Joined: Fri Apr 10, 2009 11:48 pm

Post by jhr1021 »

hybrid wrote:The code should be quite ok, however you're dealing with different coordinate systems here. OpenGL uses a right-handed y-up, while Irrlicht uses left-handed. This means that you have to negate one or all three coord elements of a vector. Rotations are much more involved, although using angle and axis should work almost the same: Invert both the axis and the angle.
Maybe you can also write up your current results so we can know how much is already working. Maybe using a skeletal animation would be also much simpler.
I changed the code like this. But it doesn't work.
rot.fromAngleAxis(angle, vector3df(-axis[0], axis[1], -axis[2]));
wuallen
Posts: 67
Joined: Thu Jan 25, 2007 3:07 am
Location: Shanghai

Post by wuallen »

I wait jhr1021 answer.
jhr1021
Posts: 8
Joined: Fri Apr 10, 2009 11:48 pm

Post by jhr1021 »

Absolutely, you are right.
wITTus
Posts: 167
Joined: Tue Jun 24, 2008 7:41 pm
Location: Germany

Post by wITTus »

Are you both co-workers somehow?
Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
Post Reply