Page 1 of 1

glRotate and glPushMatrix

Posted: Fri Apr 10, 2009 11:56 pm
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);
}

Posted: Sat Apr 11, 2009 2:55 am
by wuallen
It is that I will ask. Opengl coordinate becomes Irrlicht coordinate, is it ask?

Posted: Sat Apr 11, 2009 7:46 am
by jhr1021
wuallen wrote:It is that I will ask. Opengl coordinate becomes Irrlicht coordinate, is it ask?
Yes, right!!

Posted: Sat Apr 11, 2009 8:42 am
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.

Posted: Sat Apr 11, 2009 9:54 am
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]));

Posted: Sat Apr 11, 2009 11:55 am
by wuallen
I wait jhr1021 answer.

Posted: Sat Apr 11, 2009 12:11 pm
by jhr1021
Absolutely, you are right.

Posted: Sat Apr 11, 2009 1:42 pm
by wITTus
Are you both co-workers somehow?