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

spherecollider.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++ -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2003 Koblenz University
00006    $Id: spherecollider.cpp,v 1.5 2004/04/15 18:33:15 rollmark Exp $
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; version 2 of the License.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program; if not, write to the Free Software
00019    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 */
00021 
00022 #include "spherecollider.h"
00023 
00024 using namespace oxygen;
00025 using namespace salt;
00026 
00027 SphereCollider::SphereCollider() : Collider()
00028 {
00029 }
00030 
00031 void
00032 SphereCollider::SetRadius(float r)
00033 {
00034     dGeomSphereSetRadius(mODEGeom, r);
00035 }
00036 
00037 float
00038 SphereCollider::GetRadius() const
00039 {
00040     return dGeomSphereGetRadius(mODEGeom);
00041 }
00042 
00043 bool
00044 SphereCollider::ConstructInternal()
00045 {
00046     if (! Collider::ConstructInternal())
00047     {
00048         return false;
00049     }
00050 
00051     // create a unit sphere
00052     mODEGeom = dCreateSphere(0, 1.0f);
00053 
00054     return (mODEGeom != 0);
00055 }
00056 
00057 float
00058 SphereCollider::GetPointDepth(const Vector3f& pos)
00059 {
00060   Vector3f worldPos(GetWorldTransform() * pos);
00061   return dGeomSpherePointDepth
00062     (mODEGeom,worldPos[0],worldPos[1],worldPos[2]);
00063 }

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