Subversion Repositories gelsvn

Rev

Rev 178 | Rev 375 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 178 Rev 338
1
#ifndef __MINI_MESH_H
1
#ifndef __MINI_MESH_H
2
#define __MINI_MESH_H
2
#define __MINI_MESH_H
3
 
3
 
4
#include "IndexedFaceSet.h"
4
#include "IndexedFaceSet.h"
5
#include "Material.h"
5
#include "Material.h"
6
 
6
 
7
namespace Geometry
7
namespace Geometry
8
{
8
{
9
 
9
 
10
 
10
 
11
	/** \brief A Triangle Mesh struct. 
11
	/** \brief A Triangle Mesh struct. 
12
 
12
 
13
	    This struct contains three indexed face sets, one for geometry,
13
	    This struct contains three indexed face sets, one for geometry,
14
			textures, and normals. It also contains a vector of materials and a
14
			textures, and normals. It also contains a vector of materials and a
15
			vector of texture maps.
15
			vector of texture maps.
16
 
16
 
17
			A number of functions are defined allowing for rendering of the triangle
17
			A number of functions are defined allowing for rendering of the triangle
18
			mesh. */
18
			mesh. */
19
	struct TriMesh 
19
	class TriMesh 
20
	{
20
	{
-
 
21
		public:
-
 
22
		
21
		// ------- DATA -------
23
		// ------- DATA -------
22
 
24
 
23
		/// Name of model
25
		/// Name of model
24
		std::string name;
26
		std::string name;
25
		
27
		
26
		/// Indexed face set for the actual geometry
28
		/// Indexed face set for the actual geometry
27
		IndexedFaceSet geometry;
29
		IndexedFaceSet geometry;
28
 
30
 
29
		/// Indexed face set for the normals
31
		/// Indexed face set for the normals
30
		IndexedFaceSet normals;
32
		IndexedFaceSet normals;
31
 
33
 
32
		/// Indexed face set for the texture coordinates.
34
		/// Indexed face set for the texture coordinates.
33
		IndexedFaceSet texcoords;
35
		IndexedFaceSet texcoords;
34
 
36
 
35
		/// Material indices for all faces
37
		/// Material indices for all faces
36
		std::vector<int> mat_idx;
38
		std::vector<int> mat_idx;
37
 
39
 
38
		/// Texture indices for all faces
40
		/// Texture indices for all faces
39
		std::vector<int> tex_idx;
41
		std::vector<int> tex_idx;
40
 
42
 
41
		/// Vector of materials
43
		/// Vector of materials
42
		std::vector<Material> materials;
44
		std::vector<Material> materials;
43
 
45
 
44
		// -------- FUNCTIONS -----------
46
		// -------- FUNCTIONS -----------
45
 
47
 
46
		/// Get an axis aligned bounding box for the model.
48
		/// Get an axis aligned bounding box for the model.
47
		void get_bbox(CGLA::Vec3f& p0, CGLA::Vec3f& p7) const;
49
		void get_bbox(CGLA::Vec3f& p0, CGLA::Vec3f& p7) const;
48
 
50
 
49
		/// Get a bounding sphere for the model.
51
		/// Get a bounding sphere for the model.
50
		void get_bsphere(CGLA::Vec3f& c, float& r) const;
52
		void get_bsphere(CGLA::Vec3f& c, float& r) const;
51
 
53
 
52
		/// Returns true if at least one normal has been defined.
54
		/// Returns true if at least one normal has been defined.
53
		bool has_normals() const 
55
		bool has_normals() const 
54
		{
56
		{
55
			return normals.no_faces()>0;
57
			return normals.no_faces()>0;
56
		}
58
		}
57
		
59
		
58
		/// Find a material from its name
60
		/// Find a material from its name
59
		int find_material(const std::string&) const;
61
		int find_material(const std::string&) const;
60
 
62
 
61
		/// Compute normals for the mesh. Does not check if there are normals.
63
		/// Compute normals for the mesh. Does not check if there are normals.
62
		void compute_normals();
64
		void compute_normals();
63
 
65
 
64
	};
66
	};
65
 
67
 
66
 
68
 
67
}
69
}
68
#endif
70
#endif
69
 
71