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

My Project

mesh.h
Go to the documentation of this file.
1 /*
2 * mesh.h
3 * iminib3d
4 *
5 * Created by Simon Harrison.
6 * Copyright Si Design. All rights reserved.
7 *
8 */
9
10 #ifndef MESH_H
11 #define MESH_H
12
13 #include "entity.h"
14 #include "bone.h"
15 #include "surface.h"
16 #include "brush.h"
17 #include "texture.h"
18 #include "tree.h"
19
20 #include <iostream>
21 #include <vector>
22 #include <list>
23
24 extern "C" {
25 int tri_tri_intersect(float V0[3],float V1[3],float V2[3], float U0[3],float U1[3],float U2[3]);
26 }
27
28
29
30 using namespace std;
31
32 class MeshCollider;
33
34 class Mesh : public Entity{
35
36 public:
37
38 int no_surfs;
39
40 list<Surface*> surf_list;
41 list<Surface*> anim_surf_list; // only used if mesh contains anim info, only contains vertex coords array, initialised upon loading b3d
42
43 //int no_bones;
44 vector<Bone*> bones;
45
46 Matrix mat_sp; // mat_sp used in TMesh's Update to provide necessary additional transform matrix for sprites
47
48 MeshCollider* c_col_tree;
49 int reset_col_tree;
50
51 // reset flags - these are set when mesh shape is changed by various commands in TMesh
52 int reset_bounds;
53
54 float min_x,min_y,min_z,max_x,max_y,max_z;
55
56 Mesh(){
57
58 no_surfs=0;
59 //no_bones=0;
60
61 c_col_tree=NULL;
62 reset_col_tree=0;
63
64 reset_bounds=true;
65
66 min_x=0.0;min_y=0.0;min_z=0.0;max_x=0.0;max_y=0.0;max_z=0.0;
67
68 }
69
70 Mesh* CopyEntity(Entity* ent=NULL);
71 void FreeEntity(void);
72
73 static Mesh* CreateMesh(Entity* parent_ent=NULL);
74 Surface* CreateSurface(Brush* Bru=NULL);
75 Bone* CreateBone(Entity* parent_ent=NULL);
76 static Mesh* LoadMesh(string filename,Entity* parent_ent=NULL);
77 static Mesh* LoadAnimMesh(string filename,Entity* parent_ent=NULL);
78 static Mesh* CreateQuad(Entity* parent_ent=NULL);
79 static Mesh* CreatePlane(int divs=1, Entity* parent_ent=NULL);
80 static Mesh* CreateCube(Entity* parent_ent=NULL);
81 static Mesh* CreateSphere(int segments=8,Entity* parent_ent=NULL);
82 static Mesh* CreateCylinder(int verticalsegments=8,int solid=true,Entity* parent_ent=NULL);
83 static Mesh* CreateCone(int segments=8,int solid=true,Entity* parent_ent=NULL);
84 Mesh* CopyMesh(Entity* parent_ent=NULL);
85 Mesh* RepeatMesh(Entity* parent_ent=NULL);
86 void AddMesh(Mesh* mesh2);
87 void FlipMesh();
88 void PaintMesh(Brush* bru);
89 void MeshColor(float r,float g,float b,float a);
90 void MeshColor(float r,float g,float b);
91 void MeshRed(float r);
92 void MeshGreen(float g);
93 void MeshBlue(float b);
94 void MeshAlpha(float a);
95 void FitMesh(float x,float y,float z,float width,float height,float depth,int uniform=false);
96 void ScaleMesh(float sx,float sy,float sz);
97 void RotateMesh(float pitch,float yaw,float roll);
98 void PositionMesh(float px,float py,float pz);
99 void UpdateNormals();
100 float MeshWidth();
101 float MeshHeight();
102 float MeshDepth();
103 int CountSurfaces();
104 Surface* GetSurface(int surf_no_get);
105 void SkinMesh(int surf_no_get, int vid, int bone1, float weight1=1.0, int bone2=0, float weight2=0, int bone3=0, float weight3=0, int bone4=0, float weight4=0);
106
107 static void CopyBonesList(Entity* ent,vector<Bone*>& bones);
108 Mesh* CollapseAnimMesh(Mesh* mesh=NULL);
109 Mesh* CollapseChildren(Entity* ent0,Mesh* mesh=NULL);
110 void TransformMesh(Matrix& mat);
111 void GetBounds();
112 int Alpha();
113 void TreeCheck();
114 int MeshesIntersect(Mesh* mesh2);
115 Mesh* MeshCSG(Mesh* mesh2, int method);
116 void Update() {};
117 void Render();
118 void UpdateShadow();
119
120 };
121
122 #endif
RepeatMesh
Mesh * RepeatMesh(Mesh *mesh, Entity *parent)
Definition: functions.cpp:1306
Alpha
int Alpha(Mesh *obj)
Definition: methods.cpp:308
entity.h
Mesh
Definition: mesh.h:34
LoadAnimMesh
Mesh * LoadAnimMesh(char *file, Entity *parent)
Definition: functions.cpp:1020
CreateQuad
Mesh * CreateQuad(Entity *parent)
Definition: functions.cpp:532
CreateMesh
Mesh * CreateMesh(Entity *parent)
Definition: functions.cpp:510
Surface
Definition: surface.h:19
RotateMesh
void RotateMesh(Mesh *mesh, float pitch, float yaw, float roll)
Definition: functions.cpp:1332
UpdateNormals
void UpdateNormals(Mesh *mesh)
Definition: functions.cpp:1603
Bone
Definition: bone.h:18
CSG::MeshCSG
Mesh * MeshCSG(Mesh *m1, Mesh *m2, int method)
Definition: csg.cpp:914
MeshGreen
void MeshGreen(Mesh *obj, float g)
Definition: methods.cpp:276
LoadMesh
Mesh * LoadMesh(char *file, Entity *parent)
Definition: functions.cpp:1052
Mesh::min_z
float min_z
Definition: mesh.h:54
GetBounds
void GetBounds(Mesh *obj)
Definition: methods.cpp:304
CopyEntity
Entity * CopyEntity(Entity *ent, Entity *parent)
Definition: functions.cpp:421
std
tree.h
ScaleMesh
void ScaleMesh(Mesh *mesh, float sx, float sy, float sz)
Definition: functions.cpp:1360
Mesh::Mesh
Mesh()
Definition: mesh.h:56
TreeCheck
void TreeCheck(Mesh *obj)
Definition: methods.cpp:312
tri_tri_intersect
int tri_tri_intersect(float V0[3], float V1[3], float V2[3], float U0[3], float U1[3], float U2[3])
Definition: collidetri.c:204
CreatePlane
Mesh * CreatePlane(int divisions, Entity *parent)
Definition: functions.cpp:528
brush.h
CreateCone
Mesh * CreateCone(int segments, bool solid, Entity *parent)
Definition: functions.cpp:483
TransformMesh
void TransformMesh(Mesh *obj, Matrix &mat)
Definition: methods.cpp:300
texture.h
MeshDepth
float MeshDepth(Mesh *mesh)
Definition: functions.cpp:1085
MeshColor
void MeshColor(Mesh *obj, float r, float g, float b, float a)
Definition: methods.cpp:268
FreeEntity
void FreeEntity(Entity *ent)
Definition: functions.cpp:882
MeshCollider
Definition: tree.h:14
GetSurface
Surface * GetSurface(Mesh *mesh, int surf_no)
Definition: functions.cpp:954
CountSurfaces
int CountSurfaces(Mesh *mesh)
Definition: functions.cpp:435
Entity
Definition: entity.h:27
MeshBlue
void MeshBlue(Mesh *obj, float b)
Definition: methods.cpp:280
AddMesh
void AddMesh(Mesh *mesh1, Mesh *mesh2)
Definition: functions.cpp:110
bone.h
Mesh::reset_bounds
int reset_bounds
Definition: mesh.h:52
CreateCylinder
Mesh * CreateCylinder(int segments, bool solid, Entity *parent)
Definition: functions.cpp:490
UpdateShadow
void UpdateShadow(Mesh *obj)
Definition: methods.cpp:320
PaintMesh
void PaintMesh(Mesh *mesh, Brush *brush)
Definition: functions.cpp:1143
PositionMesh
void PositionMesh(Mesh *mesh, float px, float py, float pz)
Definition: functions.cpp:1264
MeshHeight
float MeshHeight(Mesh *mesh)
Definition: functions.cpp:1099
Mesh::Update
void Update()
Definition: mesh.h:116
Mesh::reset_col_tree
int reset_col_tree
Definition: mesh.h:49
SkinMesh
void SkinMesh(Mesh *mesh, int surf_no_get, int vid, int bone1, float weight1=1.0, int bone2=0, float weight2=0, int bone3=0, float weight3=0, int bone4=0, float weight4=0)
Definition: functions.cpp:1420
CopyBonesList
void CopyBonesList(Entity *ent, vector< Bone *> &bones)
Definition: methods.cpp:288
MeshRed
void MeshRed(Mesh *obj, float r)
Definition: methods.cpp:272
CollapseChildren
Mesh * CollapseChildren(Mesh *obj, Entity *ent0, Mesh *mesh)
Definition: methods.cpp:296
CreateBone
Bone * CreateBone(Mesh *mesh, Entity *parent_ent)
Definition: functions.cpp:457
Matrix
Definition: matrix.h:18
load3ds::mesh
Mesh * mesh
Definition: 3ds.cpp:46
FitMesh
void FitMesh(Mesh *mesh, float x, float y, float z, float width, float height, float depth, bool uniform)
Definition: functions.cpp:845
surface.h
MeshAlpha
void MeshAlpha(Mesh *obj, float a)
Definition: methods.cpp:284
CreateSphere
Mesh * CreateSphere(int segments, Entity *parent)
Definition: functions.cpp:548
CopyMesh
Mesh * CopyMesh(Mesh *mesh, Entity *parent)
Definition: functions.cpp:428
Mesh::c_col_tree
MeshCollider * c_col_tree
Definition: mesh.h:48
MeshesIntersect
int MeshesIntersect(Mesh *mesh1, Mesh *mesh2)
Definition: functions.cpp:1092
Mesh::bones
vector< Bone * > bones
Definition: mesh.h:44
Mesh::no_surfs
int no_surfs
Definition: mesh.h:38
Mesh::surf_list
list< Surface * > surf_list
Definition: mesh.h:40
Mesh::mat_sp
Matrix mat_sp
Definition: mesh.h:46
CreateSurface
Surface * CreateSurface(Mesh *mesh, Brush *brush)
Definition: functions.cpp:562
Brush
Definition: brush.h:21
MeshWidth
float MeshWidth(Mesh *mesh)
Definition: functions.cpp:1106
CreateCube
Mesh * CreateCube(Entity *parent)
Definition: functions.cpp:497
FlipMesh
void FlipMesh(Mesh *mesh)
Definition: functions.cpp:852
NULL
#define NULL
Definition: tree.cpp:4
CollapseAnimMesh
Mesh * CollapseAnimMesh(Mesh *obj, Mesh *mesh)
Definition: methods.cpp:292
Mesh::anim_surf_list
list< Surface * > anim_surf_list
Definition: mesh.h:41