My Project: openb3dlib.mod/openb3d/src/tree.h Source File

My Project

tree.h
Go to the documentation of this file.
1 #ifndef MESHCOLLIDER_H
2 #define MESHCOLLIDER_H
3
4 #include <set>
5 #include <map>
6 #include <vector>
7 using namespace std;
8
9 #include "collision.h"
10 #include "geom.h"
11
12 class Collision;
13
14 class MeshCollider{
15 public:
16 struct Vertex{
17 Vector coords;
18 };
19 struct Triangle{
20 int surface;
21 int verts[3],index;
22 };
23 MeshCollider( const vector<Vertex> &verts,const vector<Triangle> &tris );
24 ~MeshCollider();
25
26 //sphere collision
27 bool collide( const Line &line,float radius,const Transform &tform,Collision *curr_coll );
28
29 bool intersects( const MeshCollider &c,const Transform &t )const;
30
31 MeshCollider(){
32 }
33
34 private:
35 vector<Vertex> vertices;
36 vector<Triangle> triangles;
37
38 struct Node{
39 Box box;
40 Node *left,*right;
41 vector<int> triangles;
42 Node():left(0),right(0){}
43 ~Node(){ delete left;delete right; }
44 };
45
46 Node *tree;
47 vector<Node*> leaves;
48
49 Box nodeBox( const vector<int> &tris );
50 Node *createLeaf( const vector<int> &tris );
51 Node *createNode( const vector<int> &tris );
52 bool collide( const Box &box,const Line &line,float radius,const Transform &tform,Collision *curr_coll,Node *node );
53 };
54
55 class MeshInfo{
56
57 public:
58
59 vector<MeshCollider::Triangle> tri_list;
60 vector<MeshCollider::Vertex> vert_list;
61
62 MeshInfo(){};
63
64 };
65
66 MeshInfo* C_NewMeshInfo();
67 void C_DeleteMeshInfo(MeshInfo* mesh_info);
68 void C_AddTriangle(MeshInfo* mesh_info, int index, short v0, short v1, short v2, int surface);
69 void C_AddVertex(MeshInfo* mesh_info, float x, float y, float z,int surface);
70 void C_AddSurface(MeshInfo* mesh_info,int no_tris,int no_verts,short tris[],float verts[],int surface);
71 MeshCollider* C_CreateColTree(MeshInfo* mesh_info);
72 void C_DeleteColTree(MeshCollider* mesh_col);
73
74 #endif
MeshCollider::Vertex::coords
Vector coords
Definition: tree.h:17
load3ds::surface
Surface * surface
Definition: 3ds.cpp:43
geom.h
C_NewMeshInfo
MeshInfo * C_NewMeshInfo()
Definition: tree.cpp:208
C_DeleteMeshInfo
void C_DeleteMeshInfo(MeshInfo *mesh_info)
Definition: tree.cpp:215
MeshCollider::Triangle::surface
int surface
Definition: tree.h:20
std
C_CreateColTree
MeshCollider * C_CreateColTree(MeshInfo *mesh_info)
Definition: tree.cpp:294
MeshInfo::vert_list
vector< MeshCollider::Vertex > vert_list
Definition: tree.h:60
Transform
Definition: geom.h:394
MeshCollider
Definition: tree.h:14
MeshCollider::Triangle
Definition: tree.h:19
C_AddVertex
void C_AddVertex(MeshInfo *mesh_info, float x, float y, float z, int surface)
Definition: tree.cpp:238
C_AddSurface
void C_AddSurface(MeshInfo *mesh_info, int no_tris, int no_verts, short tris[], float verts[], int surface)
Definition: tree.cpp:252
C_DeleteColTree
void C_DeleteColTree(MeshCollider *mesh_col)
Definition: tree.cpp:301
collision.h
Line
Definition: geom.h:118
C_AddTriangle
void C_AddTriangle(MeshInfo *mesh_info, int index, short v0, short v1, short v2, int surface)
Definition: tree.cpp:221
Collision
Definition: collision.h:32
MeshCollider::MeshCollider
MeshCollider()
Definition: tree.h:31
MeshCollider::Vertex
Definition: tree.h:16
MeshInfo::MeshInfo
MeshInfo()
Definition: tree.h:62
Vector
Definition: geom.h:19
Box
Definition: geom.h:338
MeshInfo
Definition: tree.h:55
MeshInfo::tri_list
vector< MeshCollider::Triangle > tri_list
Definition: tree.h:59