00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "planecollider.h"
00023
00024 using namespace oxygen;
00025 using namespace salt;
00026
00027 PlaneCollider::PlaneCollider() : Collider()
00028 {
00029 }
00030
00031 void PlaneCollider::SetParams(float a, float b, float c, float d)
00032 {
00033
00034 float l = Vector3f(a,b,c).Length();
00035 if (l != 0)
00036 {
00037 a /= l;
00038 b /= l;
00039 c /= l;
00040 d /= l;
00041 }
00042
00043 dGeomPlaneSetParams(mODEGeom, a, b, c, d);
00044 }
00045
00046 bool PlaneCollider::ConstructInternal()
00047 {
00048 if (! Collider::ConstructInternal())
00049 {
00050 return false;
00051 }
00052
00053
00054 mODEGeom = dCreatePlane(0, 0, 1, 0, 0);
00055
00056 return (mODEGeom != 0);
00057 }
00058
00059 void
00060 PlaneCollider::SetParams(const salt::Vector3f& pos, salt::Vector3f normal)
00061 {
00062 normal.Normalize();
00063 float d = pos.Dot(normal);
00064 dGeomPlaneSetParams(mODEGeom, normal.x(), normal.y(), normal.z(), d);
00065 }
00066
00067 void
00068 PlaneCollider::SetPosition(const salt::Vector3f& )
00069 {
00070
00071 }
00072
00073 void
00074 PlaneCollider::SetRotation(const Matrix& )
00075 {
00076
00077 }
00078
00079 float
00080 PlaneCollider::GetPointDepth(const Vector3f& pos)
00081 {
00082 Vector3f worldPos(GetWorldTransform() * pos);
00083 return dGeomPlanePointDepth
00084 (mODEGeom,worldPos[0],worldPos[1],worldPos[2]);
00085 }
00086
00087
00088