Subversion Repositories gelsvn

Rev

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