Subversion Repositories gelsvn

Rev

Rev 178 | Details | Compare with Previous | Last modification | View Log | RSS feed

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