00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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