00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "odeobject.h"
00023 #include "space.h"
00024 #include "world.h"
00025 #include <oxygen/sceneserver/scene.h>
00026 #include <zeitgeist/logserver/logserver.h>
00027
00028 using namespace oxygen;
00029 using namespace boost;
00030
00032 shared_ptr<World> ODEObject::GetWorld()
00033 {
00034 shared_ptr<Scene> scene = GetScene();
00035 if (scene.get() == 0)
00036 {
00037 GetLog()->Error() << "(ODEObject) ERROR: found no Scene node\n";
00038 return shared_ptr<World>();
00039 }
00040
00041 shared_ptr<World> worldNode = shared_dynamic_cast<World>
00042 (scene->GetChildOfClass("World"));
00043 if (worldNode.get() == 0)
00044 {
00045 GetLog()->Error() << "(ODEObject) ERROR: found no World node\n";
00046 }
00047
00048 return worldNode;
00049 }
00050
00051 shared_ptr<Space> ODEObject::GetSpace()
00052 {
00053 shared_ptr<Scene> scene = GetScene();
00054 if (scene.get() == 0)
00055 {
00056 GetLog()->Error() << "(ODEObject) ERROR: found no Scene node\n";
00057 return shared_ptr<Space>();
00058 }
00059
00060 shared_ptr<Space> spaceNode = shared_dynamic_cast<Space>
00061 (scene->GetChildOfClass("Space"));
00062 if (spaceNode.get() == 0)
00063 {
00064 GetLog()->Error() << "(ODEObject) ERROR: found no Space node\n";
00065 }
00066
00067 return spaceNode;
00068 }
00069
00070 dWorldID ODEObject::GetWorldID()
00071 {
00072 shared_ptr<World> world = GetWorld();
00073 if (world.get() == 0)
00074 {
00075 return 0;
00076 }
00077
00078 dWorldID worldId = world->GetODEWorld();
00079 if (worldId == 0)
00080 {
00081 GetLog()->Error()
00082 << "(ODEObject) ERROR: World returned empty ODE handle\n";
00083 }
00084
00085 return worldId;
00086 }
00087
00088 dSpaceID ODEObject::GetSpaceID()
00089 {
00090 shared_ptr<Space> space = GetSpace();
00091 if (space.get() == 0)
00092 {
00093 return 0;
00094 }
00095
00096 dSpaceID spaceId = space->GetODESpace();
00097
00098 if (spaceId == 0)
00099 {
00100 GetLog()->Error()
00101 << "(ODEObject) ERROR: Space returned empty ODE handle\n";
00102 }
00103
00104 return spaceId;
00105 }
00106
00107 void ODEObject::ConvertRotationMatrix(const salt::Matrix& rot, dMatrix3& matrix)
00108 {
00109 matrix[0] = rot.m[0];
00110 matrix[1] = rot.m[4];
00111 matrix[2] = rot.m[8];
00112 matrix[3] = 0;
00113 matrix[4] = rot.m[1];
00114 matrix[5] = rot.m[5];
00115 matrix[6] = rot.m[9];
00116 matrix[7] = 0;
00117 matrix[8] = rot.m[2];
00118 matrix[9] = rot.m[6];
00119 matrix[10] = rot.m[10];
00120 matrix[11] = 0;
00121 }
00122
00123