Rotating a 3d Model

Problems with Canvas, OpenGL, etc...

Rotating a 3d Model

Postby mr87 » Mon Aug 02, 2010 9:16 pm

Hi

I am having trouble rotating a 3D model. I woud like to rotate it about the vertical axis of the screen rather than the object's y-axis. The glRotate function seems to only rotate the object about its own axis.

Thanks
mr87
Freshman
Freshman
 
Posts: 3
Joined: Mon Jul 19, 2010 7:50 pm

Top

Re: Rotating a 3d Model

Postby mb_zi » Mon Aug 02, 2010 10:17 pm

use glRotate but use a different axis/vector, glRotate takes in a vector(x,y,z) plus an angle amount.

glRotate(angle, 1,0,0) = rotate on X
glRotate(angle, 0,1,0) = rotate on y
glRotate(angle, 0,0,1) = rotate on z

or you can use your own vector for glRotate(angle, X,Y,Z);
mb_zi
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sat Feb 27, 2010 2:16 am

Re: Rotating a 3d Model

Postby mr87 » Thu Aug 05, 2010 4:25 pm

I was using glRotate, but it rotates the model about the model's own axis. I want it to rotate about an axis on the screen.

For example.

If I have a model with y axis pointing up, x axis pointing right, and z axis pointing out of the screen. The if I do a glRotate(90,1,0,0), the y axis (of the model) now points out of the screen and the z axis points down. Now if I do a rotation about the y axis, it rotates about the model's y axis, instead of the axis vertical to the screen.
mr87
Freshman
Freshman
 
Posts: 3
Joined: Mon Jul 19, 2010 7:50 pm

Re: Rotating a 3d Model

Postby keerthi » Thu Aug 12, 2010 7:37 am

Hi everyone ,im new to this forum
hey buddies i am facing diffculty in solving some issues related to cube transformations

Im trying to rotate a 3D cube on touch. the distance moved to left or right is taken as the angle of rotation with respect to Y axis and the distance moved to up or down is taken as the angle of rotation with respect to X axis .
So these are the rotations im making
glrotate(angleXdistance, 0, 1, 0); // with respect to Y axis
glrotate(angleYdistance, 1, 0, 0); // with respect to X axis


so every time i add the angles with previous angles lik angleXdiatance + = angleXdiatance; in touch event

so the problem im facing is :
1.) when i rotate to right or left for 90 degree it rotates corectly ,and after when i rotate to up or down it rotates with respect to Z axis instead of Y axis
2.)when i rotate to right or left for 180 degree it rotates corectly ,and after when i rotate to up it rotates
down , to say in it rotates in opposite direction .

i could analyse that after 90/180 degree roataions the default axes changes , so it will roatate with respect to current axes , so i tried to chk the condition if it crosses 90 thn instead of rotating with respect to X rotate with respect to Z , and after 180 , reverse the rotation angle sign .. it works but nt always .. sm prblm occurs in sm other condition,,,

so i found out all posibilities , at certain angle of rotation , these are the current axes and thn passes those axes but still din work coz two rotations are happening so tht the number of possiblities increaes which is nt possible to find all conditions..

so if anyone has idea how to solve this issue plz help ... my cube and my head rotating unexpectedly plz help to rotate them correctly
i could see many examples or applications with such problem there also ...
keerthi
Junior Developer
Junior Developer
 
Posts: 16
Joined: Thu Aug 12, 2010 6:40 am
Location: India

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest