00001 /* 00002 * Collision mesh header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_COLLISION_MESH_H__ 00009 #define __SP_COLLISION_MESH_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 #include "Base/spTreeBuilder.hpp" 00014 #include "SceneGraph/spSceneMesh.hpp" 00015 #include "SceneGraph/Collision/spCollisionNode.hpp" 00016 00017 00018 namespace sp 00019 { 00020 namespace scene 00021 { 00022 00023 00030 class SP_EXPORT CollisionMesh : public CollisionNode 00031 { 00032 00033 public: 00034 00035 CollisionMesh(CollisionMaterial* Material, scene::Mesh* Mesh, u8 MaxTreeLevel = DEF_KDTREE_LEVEL); 00036 CollisionMesh(CollisionMaterial* Material, const std::list<Mesh*> &MeshList, u8 MaxTreeLevel = DEF_KDTREE_LEVEL); 00037 ~CollisionMesh(); 00038 00039 /* Functions */ 00040 00041 s32 getSupportFlags() const; 00042 f32 getMaxMovement() const; 00043 00044 void findIntersections(const dim::line3df &Line, std::list<SIntersectionContact> &ContactList) const; 00045 bool checkIntersection(const dim::line3df &Line, SIntersectionContact &Contact) const; 00046 bool checkIntersection(const dim::line3df &Line, bool ExcludeCorners = false) const; 00047 00048 /* Inline functions */ 00049 00050 inline KDTreeNode* getRootTreeNode() const 00051 { 00052 return RootTreeNode_; 00053 } 00054 00056 inline void setCollFace(const video::EFaceTypes Type) 00057 { 00058 CollFace_ = Type; 00059 } 00061 inline video::EFaceTypes getCollFace() const 00062 { 00063 return CollFace_; 00064 } 00065 00066 /* Types */ 00067 00068 //#define _DEB_NEW_KDTREE_ 00069 00070 #ifndef _DEB_NEW_KDTREE_ 00071 typedef std::vector<SCollisionFace*> TreeNodeDataType; 00072 #else 00073 typedef std::vector<SCollisionFace> TreeNodeDataType; 00074 #endif 00075 00076 private: 00077 00078 /* Functions */ 00079 00080 void createCollisionModel(const std::list<Mesh*> &MeshList, u8 MaxTreeLevel, bool PreTransform); 00081 00082 /* Members */ 00083 00084 KDTreeNode* RootTreeNode_; 00085 video::EFaceTypes CollFace_; 00086 00087 }; 00088 00089 00090 } // /namespace scene 00091 00092 } // /namespace sp 00093 00094 00095 #endif 00096 00097 00098 00099 // ================================================================================