PDA

View Full Version : rotations

mikethebike
06-04-2013, 12:07 AM
Hi
all ok and centered but as soon as I try to rotate the mesh I only see it in the distance.

glPushMatrix();
// glRotatef(XPLMGetDataf(psi), 0, 1, 0);//heading
// glRotatef(XPLMGetDataf(theta), -1, 0, 0);//pitch
// glRotatef(XPLMGetDataf(phi), 0, 0, 1);//roll

drawGLCube();

glPopMatrix();

So how to rotate my cube at the very same place?
Many thanks
Michael

uwi2k2
06-04-2013, 12:15 AM
hi,

we need to know the content of: drawGLCube();
i just guess its moving the cube to some place in 3d space .. and its NOT around ( 0,0,0 ) right ?
caus thats the point... you need to play around with the order of translate and rotate to get a feeling for it.
its a difference if you rotate first or translate first ..
try it !

cu
uwi

mikethebike
06-04-2013, 01:15 AM
Ohh like that is rotating ok:
glTranslatef(XPLMGetDatad(locX), XPLMGetDatad(locY), XPLMGetDatad(locZ));
glRotatef(XPLMGetDataf(psi), 0, 1, 0);//heading
glRotatef(XPLMGetDataf(theta), -1, 0, 0);//pitch
glRotatef(XPLMGetDataf(phi), 0, 0, 1);//roll
glTranslatef(-XPLMGetDatad(locX), -XPLMGetDatad(locY), -XPLMGetDatad(locZ));

Hmm if I draw:
gluCylinder(quadratic,1.0f,0.0f,3.0f,32,32); // A Cone With A Bottom Radius Of .5 And A Height Of 2

it shows the inside but not the outside. Any idea on how to switch that?

Thanks again

thokra
06-04-2013, 04:04 AM
it shows the inside but not the outside. Any idea on how to switch that?

You are either inside the cylinder and have backface culling disabled or you're outside and have frontface culling enabled.

mikethebike
06-04-2013, 08:15 AM
Was a easy fix with:
glScalef(1,-1,1);