Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Rotation around the center

Hybrid View

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207

    Rotation around the center

    I have object moving from A to B on x-axis and there is no translation of object apart from it. Now, while moving, i want to rotate it around y-axis and the motion should change accordingly, i mean If it rotates 90 in clockwise while moving along +x axis, it should take a turn and move towards near plane along z axis. I have variable in gltranslatef which is modified in the loop after that i have glscalef to scale whole object which is made of hierarchical structure. Now i tried following code to achieve the expected result but its not working properly
    Code :
    	glTranslatef(move, 0, 0);
     
    	// If I comment these 3 lines, it does not affect the output
             glTranslatef(-move, 0, 0);
    	glRotatef(rotate,0,1,0);
    	glTranslatef(move, 0, 0);
     
    	glScalef(0.2, 0.2, 1.0);
    Last edited by debonair; 10-10-2013 at 11:22 PM.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Bounce..!!

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by debonair View Post
    i want to rotate it around y-axis and the motion should change accordingly, i mean If it rotates 90 in clockwise while moving along +x axis, it should take a turn and move towards near plane along z axis.
    You'll need to clarify what you mean here.

    If you want to model an object which always moves in the direction it's facing, and its orientation changes over time, then you'll need to maintain its position yourself (i.e. numerically integrate velocity with respect to time). As its position depends upon the complete history of its orientation, it cannot be determined solely from its current orientation, speed, and elapsed time.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    207
    Thanks for your help. I got it solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •