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: Help for Rubik's Cube Rotation of each slice...

  1. #1
    Junior Member Newbie
    Join Date
    May 2011
    Posts
    1

    Help for Rubik's Cube Rotation of each slice...

    Any can please give opengl c++ code for Rubik's cube...

    i created rubik's cube...

    but i cant rotate each slice...

    void colorcube()
    {

    for(i=0;i<=.66;i=i+.22)
    {
    for(j=0;j<=.66;j=j+.22)
    {
    for(k=0;k<=.66;k=k+.22)
    {
    glColor3fv(colors[1]);
    glBegin(GL_POLYGON);
    glVertex3f(i-.3,j-.3,k-.3);

    glVertex3f(i-.3,j-.1,k-.3);
    glVertex3f(i-.1,j-.1,k-.3);
    glVertex3f(i-.1,j-.3,k-.3);
    glEnd();
    glColor3fv(colors[2]);
    glBegin(GL_POLYGON);
    glVertex3f(i-.3,j-.3,k-.3);
    glVertex3f(i-.3,j-.1,k-.3);
    glVertex3f(i-.3,j-.1,k-.1);
    glVertex3f(i-.3,j-.3,k-.1);
    glEnd();
    glColor3fv(colors[3]);
    glBegin(GL_POLYGON);
    glVertex3f(i-.3,j-.3,k-.3);
    glVertex3f(i-.3,j-.3,k-.1);
    glVertex3f(i-.1,j-.3,k-.1);
    glVertex3f(i-.1,j-.3,k-.3);
    glEnd();
    glColor3fv(colors[4]);
    glBegin(GL_POLYGON);
    glVertex3f(i-.1,j-.1,k-.3);
    glVertex3f(i-.1,j-.3,k-.3);
    glVertex3f(i-.1,j-.3,k-.1);
    glVertex3f(i-.1,j-.1,k-.1);
    glEnd();
    glBegin(GL_POLYGON);
    glColor3fv(colors[5]);
    glVertex3f(i-.1,j-.1,k-.1);
    glVertex3f(i-.3,j-.1,k-.1);
    glVertex3f(i-.3,j-.3,k-.1);
    glVertex3f(i-.1,j-.3,k-.1);
    glEnd();
    glBegin(GL_POLYGON);
    glColor3fv(colors[6]);
    glVertex3f(i-.1,j-.1,k-.1);
    glVertex3f(i-.3,j-.1,k-.1);
    glVertex3f(i-.3,j-.1,k-.3);
    glVertex3f(i-.1,j-.1,k-.3);
    glEnd();
    }
    }
    }
    }

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,165

    Re: Help for Rubik's Cube Rotation of each slice...

    I seriously doubt that anyone has a Rubiks cube lurking in their tool kits.
    What is this for a school project?
    Try to visualise a Rubiks cube and break it down to it's basic components - namely 27 cubes arranged in a cuboid. Each row can be rotated around a central pivot, each column similarly. Now you can use gl rotations to manipulate sets of cube depending upon the pivot point you select.

  3. #3
    Administrator Regular Contributor Khronos_webmaster's Avatar
    Join Date
    Apr 2007
    Location
    Montreal
    Posts
    148

    Re: Help for Rubik's Cube Rotation of each slice...

    This has come up before on these forums, so I will assume this is a school project. I highly doubt anyone here will do your project for you. However, if you put the effort forth, search the forums and google, and when you get stuck, show your code, ask for specific help, you will find folks here that are happy to help you move forward.
    Webmaster Khronos.org and OpenGL.org

  4. #4

Posting Permissions

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