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,161

    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's Avatar
    Join Date
    Feb 2000
    Location
    Montreal
    Posts
    350

    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.

  4. #4

Similar Threads

  1. Rotating a slice of a Rubik cube
    By custard in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-06-2011, 10:59 AM
  2. Rotation Problem with Rubikīs Cube
    By faMouZ* in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-26-2009, 03:51 AM
  3. creating random rotations for a rubik's cube
    By AstroJazz in forum OpenGL: General
    Replies: 1
    Last Post: 04-10-2003, 12:16 PM
  4. scrambling a rubik's cube using srand() C++ and opengl
    By AstroJazz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-09-2003, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean