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

ccylindercollider.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) 2003 Koblenz University
00006    $Id: ccylindercollider.cpp,v 1.7 2004/04/16 06:45:45 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 "ccylindercollider.h"
00023 
00024 using namespace oxygen;
00025 using namespace salt;
00026 
00027 CCylinderCollider::CCylinderCollider() : Collider()
00028 {
00029 }
00030 
00031 void CCylinderCollider::SetParams(float radius, float length)
00032 {
00033     dGeomCCylinderSetParams (mODEGeom, radius, length);
00034 }
00035 
00036 void CCylinderCollider::SetRadius(float radius)
00037 {
00038     SetParams(radius,GetLength());
00039 }
00040 
00041 void CCylinderCollider::SetLength(float length)
00042 {
00043     SetParams(GetRadius(),length);
00044 }
00045 
00046 void
00047 CCylinderCollider::GetParams(float& radius, float& length)
00048 {
00049     dReal r,l;
00050     dGeomCCylinderGetParams(mODEGeom,&r,&l);
00051     radius = r;
00052     length = l;
00053 }
00054 
00055 float
00056 CCylinderCollider::GetRadius()
00057 {
00058     float length;
00059     float radius;
00060     GetParams(radius,length);
00061     return radius;
00062 }
00063 
00064 float
00065 CCylinderCollider::GetLength()
00066 {
00067     float radius;
00068     float length;
00069     GetParams(radius,length);
00070     return length;
00071 }
00072 
00073 bool
00074 CCylinderCollider::ConstructInternal()
00075 {
00076     if (! Collider::ConstructInternal())
00077     {
00078         return false;
00079     }
00080 
00081     // create a unit capped cylinder
00082     mODEGeom = dCreateCCylinder(0, 1.0f, 1.0f);
00083 
00084     return (mODEGeom != 0);
00085 }
00086 
00087 float
00088 CCylinderCollider::GetPointDepth(const Vector3f& pos)
00089 {
00090     Vector3f worldPos(GetWorldTransform() * pos);
00091     return dGeomCCylinderPointDepth
00092         (mODEGeom,worldPos[0],worldPos[1],worldPos[2]);
00093 }
00094 

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