Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

odeobject.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: odeobject.cpp,v 1.6 2004/04/15 14:14:26 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4