/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* E.P. Scene Graph Viewer
* Developed by:
*       - Eduardo Ribeiro (eribeiro @ tecgraf . puc-rio . br)
*       - Peter Dam (peter @ tecgraf . puc-rio . br)
* File: Mesh.h
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef _EPSG_MESH_
#define _EPSG_MESH_

#include "EPSG/Shape.h"
#include "EPSG/vector.h"

namespace EPSG
{
	typedef struct BoundingBoxStruct
	{
		float xmin, xmax, ymin, ymax, zmin, zmax;
	} BoundingBox;

	typedef struct VertexStruct
	{
		VVector pos;
		VVector normal;
	} Vertex;

	typedef struct TriangleStruct
	{
		int id;
		Vertex* v1;
		Vertex* v2;
		Vertex* v3;
		VVector normal;
	} Triangle;

	class Mesh : public Shape
	{
	public:
		Mesh( const char* filename );
		virtual		~Mesh();

		void		setSmooth( bool smooth );
		void		getBBox( float* xmin, float* xmax,
							 float* ymin, float* ymax,
							 float* zmin, float* zmax );
		void		draw();

	private:
		VVector		calcNormal( Triangle* t );

		bool		_smooth;
		bool		_weighted;

		int			_nVertices;
		Vertex*		_vertices;
		Vertex*		_vertexArray;

		int			_nTriangles;
		Triangle*	_triangles;

		BoundingBox	_bBox;
	};
}

#endif