Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


rotation of a collection of cubes

This topic is 5232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi im trying to create a rubiks cube using a display list. so far the program is able to draw all the individual cubes but im only able to rotate the individual cube as apposed to a face of cubes. (code is taken from lesson 12 - display lists) each list contains a face,(as it was easy to specify the colour of the individual faces) top=glGenLists(6); glNewList(top,GL_COMPILE); glBegin(GL_QUADS); glColor3f(1.0f,1.0f,1.0f); glNormal3f( 0.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glEnd(); glEndList(); bottom=top+1; etc code above is repeated for all faces(this works fine) below is the code i use to draw all the cubes that make up the rubiks cube ( found in DrawGLScene(GLvoid))this rotates individual cubes(unsure how to rotate whole face ) for (yloop=0;yloop<3;yloop++) { for(zloop=0;zloop<3;zloop++) { for (xloop=0;xloop<3;xloop++) { glLoadIdentity(); glTranslatef((xloop*2.0)-2.0f,(yloop*2.0)-1.0f,zloop*2.0)-20.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glRotatef(xrot,1.0f,0.0f,0.0f); glCallList(top); glCallList(bottom); glCallList(left); glCallList(right); glCallList(front); glCallList(back); } } } i think its something to do with glLoadIdentity. I have tried putting this outside the loop and crazy things happen. all rotation calls are only specific to an individual cube on the inner most loop however as glloadidentity has to be called in this loop any rotation i do before it is useless. i could of course be doing this all wrong(more than likely) so any help will be appriciated cheers ash

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!