PDA

View Full Version : Sphere mapping - rotation



idan333
04-06-2003, 11:58 AM
I want to rotate a sphere that i built around a specific 3d Object bone,i used sphere mapping ,but i don't know how to rotate the sphere accordingly to the poles direction.


I have this code for the mapping:
/////////////////////SPHERE MAPPING////////////////////////
// Calculate the U coordinate
u = atan2(vertex.x-center.x,vertex.z-center.z) / PI_TIMES_TWO + 0.5;
MAKEVECTOR(vect,vertex.x-center.x,vertex.y-center.y,vertex.z-center.z)
NormalizeVector(&vect);
// Take the Arcsin of Y and scale to 0-1 range
// Calculate the V coordinate
v = asin(vect.y-center.y)/M_PI + 0.5;
///////////////////////////////////////////////////////////
vertex= the bone vertex.
center= bone's center mass.

///////////////SPHERE CREATION/////////
if (selectedBone!=NULL)
{
FindBoneCenter(selectedBone,&center);
glPushMatrix();
glTranslatef(center.x, center.y, center.z);
glutWireSphere(1.0f, 30, 30);
glPopMatrix();
}

I need to know where the poles of the sphere are mapping to,and to add to creation of the sphere the accordingly rotate direction.
Or in the contrast how to map the sphere accordingly to its poles position?

Thanks a lot...