00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #include "../include/IPSA/ipsaclasses.h"
00028 #include "../include/IPSA/viewer/instructions/GetBodyRotation.h"
00029
00030 #include <Inventor/nodes/SoRotation.h>
00031
00032 #include <sstream>
00033
00034 Instruction::tExecResultType GetBodyRotation::vExecute(std::vector<std::string>& Instr, std::ostringstream& answer, unsigned int& numberOfReturnValues)
00035 {
00036 numberOfReturnValues = 0;
00037 tExecResultType res = eBODY_NOT_FOUND;
00038 SoPhysics* phy = Instruction::GetNodeOfTypeByName<SoPhysics*>(Instr[1]);
00039 if (phy)
00040 {
00041 SbMatrix transform = phy->getMatrixTransform();
00042 SbRotation rot;
00043 SbVec3f t; SbVec3f s; SbRotation so;
00044 transform.getTransform(t, rot, s, so);
00045 SbMatrix rotMatrix;
00046 rot.getValue(rotMatrix);
00047 answer << std::scientific << rotMatrix[0][0] << ' ' << rotMatrix[0][1] << ' ' << rotMatrix[0][2] << ' '
00048 << rotMatrix[1][0] << ' ' << rotMatrix[1][1] << ' ' << rotMatrix[1][2] << ' '
00049 << rotMatrix[2][0] << ' ' << rotMatrix[2][1] << ' ' << rotMatrix[2][2] << ' ';
00050 numberOfReturnValues = 9;
00051 res = eOK;
00052 }
00053 else
00054 res = eNODE_IS_NOT_A_BODY;
00055
00056 answer << '\r' << std::endl;
00057 return res;
00058 }