rotation in OpenGL

This is a discussion on rotation in OpenGL within the Game Programming forums, part of the General Programming Boards category; Say I have a rubick's cube. how do i set up my glPush/glPop's to allow me to rotate each row ...

  1. #1
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926

    rotation in OpenGL

    Say I have a rubick's cube. how do i set up my glPush/glPop's to allow me to rotate each row and each column and each face separately? I hope this is enough information
    Attached Images Attached Images  

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    each sub-cube will have its own rotation. glpush the rotation draw the subcube, glpop the rotation. Pretty basic in that sense.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you'll want to translate to the centre of the middle cube of the rotating face, this is your pivot point for rotation. Then rotate each cube around this point within the plane formed by the face using the method FYB described.

  4. #4
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I think this will have to be more than just push/pop voodoo, since if you rotate, say the left side, you will be rotating different blocks depending on the position of hte top side, which depends on the right side, etc. as both FYB and Perspective were saying.

    I would like to know what progress you make on this =)

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    I was about to answer this as well but then it hit me. There are a lot of rotations there and you cannot just create one set of cubes to rotate. Since all of the cubes can rotate my suggestion would be to make each cube a separate entity. The overall cube shape will only be there simply because that's how you arrange each individual cube in world space. If you approach the cube this way it should work:

    1. Arrange all individual cubes around the center of the entire rubix cube using translation
    2. Now rotate the cubes - as a group. This will require some code to determine which cubes are a part of the face the player is attempting to rotate.
    3. Because you translated first and then rotated, your cubes will now properly rotate around the center x,y,z of the entire cube.

    If you don't translate your cubes will rotate around their local center (transformed to world space of course) which is not what you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL hue rotation
    By Blink in forum Game Programming
    Replies: 4
    Last Post: 08-14-2007, 04:42 PM
  2. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 11:17 AM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  5. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21