[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [www-vrml] OPEN--GL Question



Juan,

I think I understand your question to be that you want to rotate an object about another point in space, much like the Earth rotates around the Sun.

I assume that your object is at the origin (at least in its coordinate system) and the point in space that you wish for the center of rotation is Y

You need to transform (move) the object so that the desired center of rotation is the origin and the object is at -Y.

You then rotate this.

If we call Ty the transform to move Y to the origin, Ra the rotation by angle a, and O the object, you have

        Ra (Ty (O))

I do not know OpenGL, so I cannot help beyond this.

        Leonard Daly



At 12:35 PM 3/3/05, Juan Manuel Gonzalez Calleros wrote:
Hello everybody

I am new in the business of computer graphics and of course 3D. I had a problem with transformations in OPENGL. My program, it is supposed that should make the rotations ans translations of an object, it works but the object rotates just  on its own axis X Y Z, I need that  it rotate around the Space. I know and I read that I need to multiply the matrix by the matrix inverse but it didn't work or ?I don't know how. could you have a view on it and if somebody know what do I need or send me a link to any web page with examples or a good explanation on what do I need.
void WireGL::paintGL()
{
printf("On est ds paintgl. xTranslat = %f\n",xTranslat);
printf("Angles GLfloat phiRot, thetaRot, rhoRot : %f, %f, %f\n",phiRot,thetaRot,rhoRot);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

//trace le repère mondial
glColor3f((GLfloat)0.7, (GLfloat)0.0, (GLfloat)0.1);
axis(1,0,0,2);
axis(0,1,0,2);
axis(0,0,1,2);

//applique les transformations
glRotatef(phiRot,1,0,0);
glRotatef(thetaRot,0,1,0);
glRotatef(rhoRot,0,0,1);
glTranslatef(xTranslat,yTranslat,zTranslat);


glCallList(object);

//retourne dans le repère initial
glTranslatef(-xTranslat,-yTranslat,-zTranslat);
glRotatef(-rhoRot,0,0,1);
glRotatef(-thetaRot,0,1,0);
glRotatef(-phiRot,1,0,0);

glFlush();
}

--
Best Regards
M. Sc. Juan Manuel González Calleros Ph. D. Student

Université catholique de Louvain (UCL)
School of Management (IAG)
Unit of Information Systems (ISYS)

Place des Doyens, 1 (office a.036)
Louvain-la-Neuve, Belgium P.C. 1348
E-mail: gonzalez@isys.ucl.ac.be
E-mail: jmgonzalez@inaoep.mx 
E-mail:jumagoca78@hotmail.com web: http://www.isys.ucl.ac.be/bchi/members/jgo/index.htm

Phone: +32 10/478349
Fax: +32 10/478324

-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html

+--------
| Leonard Daly <daly@realism.com>
| Internet & Web Consulting http://realism.com/
| Online 3D Graphics http://e3dNews.com/
| X3D Author and Lecturer
| Member, Web3D Board of Directors
+------------------------------