void RageMatrixCommand( CString sCommandString, RageMatrix &mat ) { CStringArray asCommands; split( sCommandString, ";", asCommands, true ); for( unsigned c=0; c<asCommands.size(); c++ ) { CStringArray asTokens; split( asCommands[c], ",", asTokens, true ); int iMaxIndexAccessed = 0; #define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed)) #define fParam(i) (strtof(sParam(i),NULL)) #define iParam(i) (atoi(sParam(i))) #define bParam(i) (iParam(i)!=0) CString& sName = asTokens[0]; sName.MakeLower(); RageMatrix b; // Act on command if( sName=="x" ) RageMatrixTranslation( &b, fParam(1),0,0 ); else if( sName=="y" ) RageMatrixTranslation( &b, 0,fParam(1),0 ); else if( sName=="z" ) RageMatrixTranslation( &b, 0,0,fParam(1) ); else if( sName=="zoomx" ) RageMatrixScaling(&b, fParam(1),1,1 ); else if( sName=="zoomy" ) RageMatrixScaling(&b, 1,fParam(1),1 ); else if( sName=="zoomz" ) RageMatrixScaling(&b, 1,1,fParam(1) ); else if( sName=="rotationx" ) RageMatrixRotationX( &b, fParam(1) ); else if( sName=="rotationy" ) RageMatrixRotationY( &b, fParam(1) ); else if( sName=="rotationz" ) RageMatrixRotationZ( &b, fParam(1) ); else { CString sError = ssprintf( "MatrixCommand: Unrecognized matrix command name '%s' in command string '%s'.", sName.c_str(), sCommandString.c_str() ); LOG->Warn( sError ); Dialog::OK( sError ); continue; } if( iMaxIndexAccessed != (int)asTokens.size()-1 ) { CString sError = ssprintf( "MatrixCommand: Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).c_str(), iMaxIndexAccessed+1, (int)asTokens.size() ); LOG->Warn( sError ); Dialog::OK( sError ); continue; } RageMatrix a(mat); RageMatrixMultiply(&mat, &a, &b); } }
void RotateYLocal( float degrees ) { RageMatrix m; RageMatrixRotationY( &m, degrees ); MultMatrixLocal( m ); }
RageMatrix RageMatrixRotationY( float theta ) { RageMatrix m; RageMatrixRotationY( &m, theta ); return m; }