Labuzz
11-20-2003, 04:40 PM
put the matrix.mp in your plug dir.
start messiah and add the matrixObject.lwo to the scene ( this is a good visual ref ).
Go to setup mode and rotate the matrixObject on h, p and b. Do not move the object.
enter "matrix" in the command line, the plug will build the complete coord system for you.
So in the end the rotation matrix is :
Xvector
Yvector
Zvector
Code source :
#define _MESSIAH_FULL_API
#define _MAINPLUGIN_FILE
#include "messiah_main.h"
FX_EXPFUNC( matrix, void, Data );
_pluginEntry
{ _API_OBJECT ;
_API_EXPFUNC ;
_API_FUNCTION ;
_API_COMMAND ;
_API_MESSAGE ;
_API_ARG ;
_API_DATA ;
_API_VARIABLE ;
_API_TOOLTYPE;
_API_MOTION;
_API_TIME ;
_MESSIAH_PLUGIN_ANIMATE("matrix");
fxFunctionRegister("matrix", FX_FUNCCLASS_GENERAL, &matrix, NULL, FX_ARG_DOUBLE, FX_NOFLAG);
return FX_PLUGIN_OK;
}
FX_EXPFUNC( matrix, void, Data )
{
FXobject selection, directionZ, directionY, directionX ;
FXvecd setupRotation = { 0.0, 0.0, 0.0 } ;
FXvecd Xvector = {0.0, 0.0, 0.0 } ;
FXvecd Yvector = {0.0, 0.0, 0.0 } ;
FXvecd Zvector = {0.0, 0.0, 0.0 } ;
fxCommandExecute ( FX_NULLID,"Mode Setup", FX_NOFLAG) ;
fxFrameCalculate (NOW, FX_NOFLAG) ;
/////////////////////////////////Get the rotations of the Z vector
selection = fxObjectCurrent ( FX_NOFLAG ) ;
fxChannelsGet ( selection, FX_ROTATION, 0, setupRotation, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Creation of the normalized Zvector (Zdirection)
directionZ = fxToolCreate ( FX_TOOLTYPE_NULL, "Zdirection", FX_NO ,FX_NOFLAG ) ;
Zvector[0] = sin(setupRotation [0])* cos(setupRotation [1]) ;
Zvector[1] = -sin(setupRotation [1]) ;
Zvector[2] = cos(setupRotation [0])* cos(setupRotation [1]) ;
fxChannelsSet ( directionZ, FX_POSITION, Zvector, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Creation of the Y and X vectors
/////////////////////////////////the rotation Matrix is complete
Yvector[0] = (-cos(setupRotation [0])*sin(setupRotation[2]))+(sin(setupRotation[0])*sin(setupRotation[1])
*cos(setupRotation[2]));
Yvector[1] = cos(setupRotation[2])*cos(setupRotation[1]) ;
Yvector[2] = (sin(setupRotation [2])*sin(setupRotation[0]))+(cos(setupRotation[0])*sin(setupRotation[1])
*cos(setupRotation[2]));
FX_V3CROSS(Xvector,Yvector, Zvector);
directionY = fxToolCreate ( FX_TOOLTYPE_NULL, "Ydirection", FX_NO ,FX_NOFLAG ) ;
fxChannelsSet ( directionY, FX_POSITION, Yvector, FX_CHANXFER_SETUP ) ;
directionX = fxToolCreate ( FX_TOOLTYPE_NULL, "Xdirection", FX_NO ,FX_NOFLAG ) ;
fxChannelsSet ( directionX, FX_POSITION, Xvector, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Select the matrix Object
fxObjectSetCurrent ( selection, FX_NOFLAG );
fxObjectDeselectAll ( FX_NOFLAG );
fxArgSetDouble (return_arg, NULL, 0, 666);
return FX_FUNC_OK;
}
Download :
http://perso.wanadoo.fr/borhan.berthet/matrix.zip
start messiah and add the matrixObject.lwo to the scene ( this is a good visual ref ).
Go to setup mode and rotate the matrixObject on h, p and b. Do not move the object.
enter "matrix" in the command line, the plug will build the complete coord system for you.
So in the end the rotation matrix is :
Xvector
Yvector
Zvector
Code source :
#define _MESSIAH_FULL_API
#define _MAINPLUGIN_FILE
#include "messiah_main.h"
FX_EXPFUNC( matrix, void, Data );
_pluginEntry
{ _API_OBJECT ;
_API_EXPFUNC ;
_API_FUNCTION ;
_API_COMMAND ;
_API_MESSAGE ;
_API_ARG ;
_API_DATA ;
_API_VARIABLE ;
_API_TOOLTYPE;
_API_MOTION;
_API_TIME ;
_MESSIAH_PLUGIN_ANIMATE("matrix");
fxFunctionRegister("matrix", FX_FUNCCLASS_GENERAL, &matrix, NULL, FX_ARG_DOUBLE, FX_NOFLAG);
return FX_PLUGIN_OK;
}
FX_EXPFUNC( matrix, void, Data )
{
FXobject selection, directionZ, directionY, directionX ;
FXvecd setupRotation = { 0.0, 0.0, 0.0 } ;
FXvecd Xvector = {0.0, 0.0, 0.0 } ;
FXvecd Yvector = {0.0, 0.0, 0.0 } ;
FXvecd Zvector = {0.0, 0.0, 0.0 } ;
fxCommandExecute ( FX_NULLID,"Mode Setup", FX_NOFLAG) ;
fxFrameCalculate (NOW, FX_NOFLAG) ;
/////////////////////////////////Get the rotations of the Z vector
selection = fxObjectCurrent ( FX_NOFLAG ) ;
fxChannelsGet ( selection, FX_ROTATION, 0, setupRotation, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Creation of the normalized Zvector (Zdirection)
directionZ = fxToolCreate ( FX_TOOLTYPE_NULL, "Zdirection", FX_NO ,FX_NOFLAG ) ;
Zvector[0] = sin(setupRotation [0])* cos(setupRotation [1]) ;
Zvector[1] = -sin(setupRotation [1]) ;
Zvector[2] = cos(setupRotation [0])* cos(setupRotation [1]) ;
fxChannelsSet ( directionZ, FX_POSITION, Zvector, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Creation of the Y and X vectors
/////////////////////////////////the rotation Matrix is complete
Yvector[0] = (-cos(setupRotation [0])*sin(setupRotation[2]))+(sin(setupRotation[0])*sin(setupRotation[1])
*cos(setupRotation[2]));
Yvector[1] = cos(setupRotation[2])*cos(setupRotation[1]) ;
Yvector[2] = (sin(setupRotation [2])*sin(setupRotation[0]))+(cos(setupRotation[0])*sin(setupRotation[1])
*cos(setupRotation[2]));
FX_V3CROSS(Xvector,Yvector, Zvector);
directionY = fxToolCreate ( FX_TOOLTYPE_NULL, "Ydirection", FX_NO ,FX_NOFLAG ) ;
fxChannelsSet ( directionY, FX_POSITION, Yvector, FX_CHANXFER_SETUP ) ;
directionX = fxToolCreate ( FX_TOOLTYPE_NULL, "Xdirection", FX_NO ,FX_NOFLAG ) ;
fxChannelsSet ( directionX, FX_POSITION, Xvector, FX_CHANXFER_SETUP ) ;
/////////////////////////////////Select the matrix Object
fxObjectSetCurrent ( selection, FX_NOFLAG );
fxObjectDeselectAll ( FX_NOFLAG );
fxArgSetDouble (return_arg, NULL, 0, 666);
return FX_FUNC_OK;
}
Download :
http://perso.wanadoo.fr/borhan.berthet/matrix.zip
