Subversion Repositories gelsvn

Rev

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

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