Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_COLLISION_SPHERE_H__
00009 #define __SP_COLLISION_SPHERE_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "SceneGraph/Collision/spCollisionNode.hpp"
00014
00015
00016 namespace sp
00017 {
00018 namespace scene
00019 {
00020
00021
00028 class SP_EXPORT CollisionSphere : public CollisionNode
00029 {
00030
00031 public:
00032
00033 CollisionSphere(CollisionMaterial* Material, SceneNode* Node, f32 Radius);
00034 ~CollisionSphere();
00035
00036
00037
00038 s32 getSupportFlags() const;
00039 f32 getMaxMovement() const;
00040
00041 bool checkIntersection(const dim::line3df &Line, SIntersectionContact &Contact) const;
00042 bool checkIntersection(const dim::line3df &Line, bool ExcludeCorners = false) const;
00043
00044
00045
00047 inline void setRadius(f32 Radius)
00048 {
00049 Radius_ = Radius;
00050 }
00052 inline f32 getRadius() const
00053 {
00054 return Radius_;
00055 }
00056
00057 private:
00058
00059
00060
00061 bool checkCollisionToSphere (const CollisionSphere* Rival, SCollisionContact &Contact) const;
00062 bool checkCollisionToCapsule (const CollisionCapsule* Rival, SCollisionContact &Contact) const;
00063 bool checkCollisionToCylinder (const CollisionCylinder* Rival, SCollisionContact &Contact) const;
00064 bool checkCollisionToCone (const CollisionCone* Rival, SCollisionContact &Contact) const;
00065 bool checkCollisionToBox (const CollisionBox* Rival, SCollisionContact &Contact) const;
00066 bool checkCollisionToPlane (const CollisionPlane* Rival, SCollisionContact &Contact) const;
00067 bool checkCollisionToMesh (const CollisionMesh* Rival, SCollisionContact &Contact) const;
00068
00069 bool checkAnyCollisionToMesh(const CollisionMesh* Rival) const;
00070
00071 void performCollisionResolvingToSphere (const CollisionSphere* Rival);
00072 void performCollisionResolvingToCapsule (const CollisionCapsule* Rival);
00073 void performCollisionResolvingToCylinder(const CollisionCylinder* Rival);
00074 void performCollisionResolvingToCone (const CollisionCone* Rival);
00075 void performCollisionResolvingToBox (const CollisionBox* Rival);
00076 void performCollisionResolvingToPlane (const CollisionPlane* Rival);
00077 void performCollisionResolvingToMesh (const CollisionMesh* Rival);
00078
00079 bool checkPointDistanceSingle(
00080 const dim::vector3df &SpherePos, const dim::vector3df &ClosestPoint,
00081 f32 MaxRadius, SCollisionContact &Contact
00082 ) const;
00083 bool checkPointDistanceDouble(
00084 const dim::vector3df &SpherePos, const dim::vector3df &ClosestPoint,
00085 f32 MaxRadius, f32 RivalRadius, SCollisionContact &Contact
00086 ) const;
00087
00088
00089
00090 f32 Radius_;
00091
00092 };
00093
00094
00095 }
00096
00097 }
00098
00099
00100 #endif
00101
00102
00103
00104