I have tried absolutely everything with this piece of code to get it working without success. The output is a scrambled cube but it does not show each rotation as it happens. What am I missing??? If you can think of anything at all, please let me know.
Thanks.
/* Process the main menu when the right mouse button is pressed*/
static void selectMainMenu(int selection)
{
int numb_of_rotations = 1; //maximum number of rotations
int i;
switch (selection)
{
case MAIN_MENU_QUIT:
exit(0); break; //terminates the application
case 1: /* stop cube spinning */
spinStop();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning stops*/
break;
case 2: /* help */
//help();
/* windows system call that tells windows to open the help text file */
system("notepad C:\Program Files\Microsoft Visual Studio\MyProjects\RubikCubefyp\interface.txt");
break;
case 3:
for( i=0; i < numb_of_rotations; i++)
{
rotcounter = 1;
for(int j=0; j< numb_of_rotations; j++) //to ensure all axis are randomized
{
scramble_cube(); /* call to scramble cube function */
//glutPostRedisplay();
}
//rotcounter = 0;
//sx=sy=sz=0;//nothing is selected, no grey areas
}
rotcounter = 1 ;
break;
case 4: /* reset */
resetcube();
sx=sy=sz=0;/*makes sure no part of the cube is selected when reset*/
break;
case 5: /* spin cube */
spinDisplay();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning starts*/
break;
case 6: /* solve */
// solve_cube();
break;
}
/* Scrambles the rubik's cube */
void scramble_cube(void)
{
int axis ;
char char_axis;
int direction;
axis = rand() % 3;//selects a random axis
cout << "axis = " << axis << endl ;
switch (axis)
{
case 0:
char_axis = 'z';
//rotcounter = 0;
//inputUpdate() ;
break;
case 1:
char_axis = 'x';
//rotcounter = 0;
//inputUpdate();
break;
case 2:
char_axis = 'c';
//rotcounter = 0;
//inputUpdate() ;
break;
}
cout << "char_axis = " << char_axis << endl;
Keyboard(char_axis, 0, 0);
direction = rand() % 3 ; //creates a ramdom direction
//from rotate_selected in main
if(direction == 0) //no dierection at start
rotate_selected(-1); //counter-clockwise rotation
else
rotate_selected(1) ; //clockwise rotation
//glutPostRedisplay();
}
}
Rotation
Started by Astro, Apr 13 2003 07:48 PM
4 replies to this topic
#1
Posted 13 April 2003 - 07:48 PM
#2
Posted 13 April 2003 - 11:25 PM
the code [that you provided above] seems to work. do you have an idea as to where the "error" may be? are you willing to show us your entire program?
mod: there's two threads. can you please merge? thanks
:yes:
mod: there's two threads. can you please merge? thanks
:yes:
Imagine.
#3
Posted 13 April 2003 - 11:41 PM
do you know of rotate_selected(...) works properly?
:yes:
:yes:
Imagine.
#4
Posted 14 April 2003 - 06:59 AM
Assuming that your cube is not rotating:
Check the function that does the glRotate().
remember that you might be undoing the rotation... its very genuine.
Check the function that does the glRotate().
remember that you might be undoing the rotation... its very genuine.
#5
Posted 14 April 2003 - 08:59 AM
I'm not sure I follow what you mean. Is the problem that when you call the scramble_cube, it isn't making the cube become randomised. Or is it that cube rotation is not being displayed on your screen?
Its not about having an infinite number of monkeys, its about having the right monkey
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











