void rotateCube( int alpha, int beta, int gamma)
{
    int j, i, ar, br, gr;
    
    for(j = 0; j <= 90; j+= STEP)
    {                        
        // clear painting screen
        gClearScreen();                 // clear the hidden screen
        
       // rotate the corresponding axis
        ar = alpha * j;
        br = beta * j;
        gr = gamma * j ;

        for( i=objc; i<MAXOBJ; i++)
        {
           // transform and draw the object                        
            initMatrix( mo, ar, br, gr, 0, 0, 0);
            drawObject( mo, i);

            // if final rotation
            if ( j == 90)
                rotateObject( mo, i);
        }
                
        // update visible screen
        copyV();

    } // for j steps

    // update pointer matrix c[][][]
    
    for ( i=0; i<3; i++)
    {
        if (( alpha<0)||( beta<0)||( gamma<0))
            rotateC( ( alpha!=0), ( beta!=0), ( gamma!=0), i, -1);    
        else
            rotateC( ( alpha!=0), ( beta!=0), ( gamma!=0), i, +1);    
    }
} // animate rotation of entire cube
void rotateRow( int x, int y, int z, int v, int s)
{
    // rotate all objects matching x, y, z mask  with value v
    // s verse of rotation
    int j, i, ix, iy, iz;
    
    // animation loop 0-90 deg
    for(j = 0; j <= 90; j+= STEP)
    {
        // clear painting scren
        gClearScreen();                 // clear the hidden screen

        // search all objects for matching pattern
        for( iz=0; iz<3; iz++)
            for( iy=0; iy<3; iy++)
                for(ix=0; ix<3; ix++)
                {   
                    if ( ix*iy*iz == 1) continue; // ignore c[1][1][1]
                    i = c[ix][iy][iz];

                    // check if requires rotation
                    if (( (ix+1)*x == v+1) || ((iy+1)*y == v+1) || ((iz+1)*z == v+1))
                    {  // rotate the corresponding axis
                        // transform and draw the object                        
                        initMatrix( mo, x*s*j, y*s*j, z*s*j, 0, 0, 0);
                        drawObject( mo, i);

                        // if final rotation
                        if ( j == 90)
                            rotateObject( mo, i);
                    }
                    else 
                    {
                        // transform and draw the object                        
                        initMatrix( mo, 0, 0, 0, 0, 0, 0);
                        drawObject( mo, i);
                    }    
                    
                }
        
        
        // update visible screen
        copyV();            
    } // for j steps

    // update pointer matrix c[][][]
    rotateC( x, y, z, v, s);    
        
} // animate rotation of one row/face   
Example #3
0
void RotateMessageHandlerSubSystem::Execute(Message const& message)
{
    RotateMessage const& msg=static_cast<RotateMessage const&>(message);
    Opt<Actor> actor=mScene.GetActor(msg.mActorGUID);
    if (!actor.IsValid())
    {
        L1("cannot find actor with GUID: (%s) %d \n",__FUNCTION__,msg.mActorGUID );
        return;
    }
    Opt<IRotateComponent> rotateC( actor->Get<IRotateComponent>() );
    if (!rotateC.IsValid())
    {
        L1( "rotate is called on an actor that has no rotate_component \n" );
        return;
    }
    rotateC->SetSpeed( msg.mSpeed );
    rotateC->SetRotating( msg.mRotating );
}
Example #4
0
void rotateSquare(char arr[4][9])
{
	int pass0, pass1, pass2, pass3;
	int square, mark;
	pass3 = 0;
	char rawrot[] = "A'";
	while (pass3 == 0)
	{
		pass0 = 0;
		pass1 = 0;
		pass2 = 0;
		printf("Rotation (ie. A' or C\"): ");
		fgets(rawrot, 3, stdin);
		if (rawrot[strlen(rawrot) -1] != '\n')
		{
			int dropped = 0;
			while (fgetc(stdin) != '\n')
			dropped++;
			if (dropped == 0)
			{
				pass0 = 1;
			}
		}
		if (pass0)
		{
			int i;
			char letters[]=
			{'A', 'B', 'C', 'D'};
			if(rawrot[1]=='\'' || rawrot[1]=='\"')
			{
				pass1 = 1;
			}
			for (i=0;i<4;i++)
			{
				if(rawrot[0]==letters[i])
				{
					pass2 = 1;
				}
			}
		}
		if(pass1 && pass2)
		{
			if (rawrot[0] == 'A')
			{
				square = 0;
			}
			else if (rawrot[0] == 'B')
			{
				square = 1;
			}
			else if (rawrot[0] == 'C')
			{
				square = 2;
			}
			else if (rawrot[0] == 'D')
			{
				square = 3;
			}
			pass3=1;
		}
	}
	if (rawrot[1] == '\'')
	{
		rotateC(arr, square);
	}
	else
	{
		rotateCC(arr, square);
	}
}