Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How do I make a spinning cube?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2017

    How do I make a spinning cube?

    I'm trying to make a cube where the center of mass of the cube located at (−0.5, 0.5, 0.0) and it spins continuously
    about x-axis and its fix point of rotation is at its center of mass (−0.5, 0.5, 0.0). I know the cube would have 36 vertices so I would have something like
    Code :
    vec4 cube_vertices[36] = {...};

    Not sure where to go from here. I need help making the cube itself and then need help with making it spin. Any help would be appreciated.

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2017
    SE Pennsylvania on 6 acre wooded hillside
    There are a lot of tutorials online which show how to send data to make a textured cube (it's one of the standards), do a google search. Generally the rotation is done by grabbing the time at start of the program and then using the time difference to increment the rotation matrix in the modelview transform. Note that if you want to rotate around a point as stated that is not the origin (0,0,0) then you should first translate to origin, then rotate, then translate back to starting point. Else you rotate around the origin, not the center of the cube.

    Found many such tutorials doing this Google search "tutorial opengl rotating cube" go look.

Posting Permissions

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