Results 1 to 3 of 3

Thread: 3d rotation

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    20

    3d rotation

    I have the following code
    Code :
    glLoadIdentity();
    	glTranslatef(x,y,z);
    	gluLookAt(sin(angle*0.0174532925),0.0,cos(angle*0.0174532925),0.0,0.0,0.0,0.0,1.0,0.0);
    	glTranslatef(sidedistance,0.0,distance);
    	glColor3fv(color);
    	if ((armsraised)&&(!walking)&&(!sidestep))
    		DrawRobotArmsRaised();
        if ((armslowered)&&(!walking)&&(!sidestep))
    		DrawRobotArmsLowered();
    	if ((walking)&(!sidestep))
    		DrawRobotWalking();
    	if ((sidestep)&&(!walking))
    		DrawRobotSideStep();
    	if ((!walking)&&(!armsraised)&&(!armslowered)&&(!sidestep))
    		DrawRobotStanding();
    I am trying to get the models to be able to walk forward and backwards and sidestep left and right using the arrow keys and rotate using the mouse. The problem is with the rotation no matter what I do they always rotate around the origin and if I put the gltranslates before the glulookat then they rotate correctly but do not move correctly.
    Can anyone help me fix this problem?

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: 3d rotation

    Putting a translation before gluLookAt doesn't have any sense...

    If you want to rotate around the robot shoulder for instance, move the shoulder at the origin, then rotate and finally move the shoulder at the correct location.

    I mean, in general, move to the rotation center and then rotate. But remember that this transformation are done in the reverse order and are applied to objects. So actually, you move the center of rotation to the origin.

    Hoping this is clear...

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    20

    Re: 3d rotation

    I am still confused since the robots rotate fine before I move them forward or backwards or side to side using the sidedistance and distance. The problem occurs when I move them away from the origin and if I do the translates bedore the glulookat then they never walk in the direction they are facing.
    Can anyone help me clear up this confusion?

Similar Threads

  1. Rotation of an object by rotation matrix
    By MrFoil in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-02-2015, 04:41 PM
  2. Matrix Rotation loses 1 axes of rotation
    By Benzino in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-15-2011, 06:53 AM
  3. Replies: 1
    Last Post: 04-16-2010, 02:59 PM
  4. changing axis of rotation and center of rotation in openGL performer
    By ravishashi in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-08-2003, 04:42 AM
  5. world rotation v. body rotation
    By cosmicGirl in forum OpenGL: Basic Coding
    Replies: 31
    Last Post: 03-11-2003, 12:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean