/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///																																  ///
///		FICHIER :	ZooMesh.h																									  ///
///																																  ///
///		NATURE	:	Management of the mesh, the face and the vertex (topology of a ZObject) for the 3D scene																		  ///
///																																  ///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __ZOOMESH_H__
#define __ZOOMESH_H__


#include	"..\Basic\ZooStd.h"
#include	"..\Collision\rapid.h"
#include	"..\Datas\ZooMaterial.h"


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZVert Class
///
///		- Classe des vertices d'un objet
///		- Méthodes de setting de position en Cartésienne ou en Sphérique
///		- Normale au vertex
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZVert : public ZVector3
{
public:

	
	// Position referenced by the center of world 
	// - without object translation & translation -
	ZVector3	Normal;				// Normal of the vertex
	ZVector3	color1;				// RGB for the primary texture - Alpha for the transparent faces
	ZVector3	color2;				// RGB for the second texture  - Alpha for the multitex blendingsss
	float		weight1 ;
	float		weight2 ;
	float			ID1 ;
	float			ID2 ;

	
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZFace Class
///
///		- Classe des faces d'un objet
///		- Méthode de setting des références aux vertices de l'objet
///		- Normale à la face, des normales aux points, des coordonnées de texture des vertices,
///		  et identité de la texture à afficher pour cette face
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZFace
{
protected:

	ZMaterial	*material;							// Material of the face


public:
	
	int			VertRef[3];							// Index in the object array of vertices

	ZUV			UV1[3];								// Texture coordinates of these vertices
	ZUV			UV2[3];								// Texture coordinates of these vertices
	ZUV			UV3[3];								// Texture coordinates of these vertices
	ZUV			UV4[3];								// Texture coordinates of these vertices
	
	bool		clampU1, clampV1;
	bool		clampU2, clampV2;
	bool		clampU3, clampV3;
	bool		clampU4, clampV4;

	ZVector3	Normal;								// Normal of the face

	bool		dependency;							// flag to design a face with shared vertices

	int			index;


	///////////////////////////////////////////////////////////////////////////
	/// Constructor & Destructor	 										///
	///////////////////////////////////////////////////////////////////////////
	// !WARNING!   IT MUST BE LIKE THIS, BECOZ OF THE DYNAMIC ARRAY OF FACES !WARNING!
	void initFace();
	void DeleteFace();


	///////////////////////////////////////////////////////////////////////////
	/// Set the vertice references of the face								///
	///////////////////////////////////////////////////////////////////////////
	void SetVertsRef(long ref0, long ref1, long ref2);
	

	///////////////////////////////////////////////////////////////////////////
	/// Set the material of the face										///
	///////////////////////////////////////////////////////////////////////////
	void SetMaterial(ZMaterial *newMat);
	ZMaterial*	GetMaterial();
};


///////////////////////////////////////////////////////////////////////////
/// Get the material of the face										///
///////////////////////////////////////////////////////////////////////////
inline ZMaterial* ZFace::GetMaterial()
{
	return material;
}


///////////////////////////////////////////////////////////////////////////
/// Structures for mesh variables definition							///
///////////////////////////////////////////////////////////////////////////
typedef vector<ZFace*>			FaceList;						// structure for the list of faces

struct FacesBySHADE
{
	FaceList		gour;		// liste des faces en gouraud
	FaceList		flat;		// liste des faces en flat
	FaceList		no;			// liste des faces avec couleur par défaut
};

struct FacesByTex
{
	ZTexture		*tex;		// texture partagée par les faces de la liste globale - tri sur les texture
	ZTexture		*tex2;		// texture partagée par les faces de la liste globale - tri sur les texture
	ZTexture		*lightMap;		// texture partagée par les faces de la liste globale - tri sur les texture
	bool			env;
	bool			multi;
	bool			colTransp;
	FacesBySHADE	ClampUV;
	FacesBySHADE	ClampU;
	FacesBySHADE	ClampV;
	FacesBySHADE	NoClamp;
};

struct FacesByMat
{
	ZMaterial		*mat;
	FaceList		faces;		// liste des faces en gouraud
};

typedef vector<FacesByTex>		ListFaceByTex;					// structure for the list of lists of faces
typedef vector<FacesByMat>		ListFaceByMat;					// structure for the list of lists of faces


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZMesh Class
///
///		- Classe des meshs
///		- Méthode d'intialisation du mesh -> nbre faces et vertices, et allocation de mémoire
///		- Méthode de libération du mesh (faces et vertices)
///		- Méthodes de création des normales aux faces et aux points
///		- Tableaux de vertices et de faces
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ZObject;

class ZMesh : public ZData
{
protected:
	int					Pass1ListID;				// IDs for the display lists of render-pass 1
	int					Pass2ListID;				// IDs for the display lists of render-pass 2
	int					PassLightMapListID;				// IDs for the display lists of render-pass LightMap
	int					Pass3ListID;				// IDs for the display lists of render-pass 3
	int					Pass4ListID;				// IDs for the display lists of render-pass 4
	/* $MS : Display list for Skinning */
	int					PassSkinningListID;				// IDs for the display lists of render-pass Skinning

public:
	int					scene3D;

	long				NbVerts;					// nb of vertices
	long				NbFaces;					// nb of faces

	vector<ZFace>		Faces;						// list of faces
	vector<ZVert>		Verts;						// list of vertices

	FacesBySHADE		FacesFlat;					// lists of flat faces						--> Tri simple suivant GOURAUD, FLAT ou DEFAULT coloring

	ListFaceByTex		FacesColTransp;				// lists of faces - primary textur & EnvMap	--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesEnv;					// lists of faces - primary textur & EnvMap	--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesTex1;					// lists of faces - primary texture			--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesTex2;					// lists of faces - secondary texture		--> Tri double : suivant la texture n°2, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesLightMap;				// lists of faces affected by  light map
	
	ListFaceByMat		FacesMatGour;				// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting
	ListFaceByMat		FacesMatFlat;				// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting
	ListFaceByMat		FacesMatNo;					// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting

	FaceList			FacesTransp;				// list of transparent faces				--> aucun tri

	bool				multiTex;					// flag modified in internal treatment
	bool				isAvatar ;

	//$LB (02/11/2004)
	WORD				texRenderMode;                // added to allow an object to change the way his material is applying
													// texRenderMode == false   ==> GL_CLAMP_TO_EDGE (default),   texRenderMode == true  ==> GL_REPEAT
													// this feature is now used by M3topoScale (user can choose to repeat the texture when scaling the object)
													// and it's processed by ZObject::RenderPass1Classic and ZObject::RenderPass2Classic

	bool				hasTopoChanged;
	bool				hasViewChanged;
	
	RAPID_model			*rapid;						// collision model (use for the culling too)
	bool				rapidCreated;

	bool				dependency;					// flag to design a mesh with partaged vertices
	bool				displayListCreate;			// flag to enable or disable the creation of the display lists

	float				xmin, xmax, ymin, ymax, zmin, zmax;			// coordinates of the BBOX
	
	bool				saved;						// flag pour la sauvegarde non redondante des meshes

	/////////////////////////
	// Pour les shader  //////
	//////////////////////////

	/* $MS : Treatment of shader in class Mesh */
	CGcontext	cgContext;
	CGprogram	cgVertexProgram;
	CGprogram   cgFragmentProgram;
	CGprofile	cgVertexProfile;
	CGprofile   cgFragmentProfile;
	CGparameter Position,Normal,Color,TexCoord0,S,T,SxT,Weights,Indices,WorldViewProj,AvaViewProj,ModelViewProj,ModelViewInverseProj,Bones,LightVec,cgTexture;

	// Paramètre shader
		////////////////////////////////////////////
	////////////  Intégration des shaders/////////
	///////////////////////////////////////////////
	int numberOfBones ;
	void worldDebug(ZTexture *tex) ;

	/* $MS : End Treatment of shader in class Mesh */



	///////////////////////////////////////////////////////////////////////////
	/// Constructor					 										///
	///////////////////////////////////////////////////////////////////////////
	ZMesh(int s3d, int nvert, int nface);
	~ZMesh();

	///////////////////////////////////////////////////////////////////////////
	/// Ajout de face et de vertex											///
	///////////////////////////////////////////////////////////////////////////
	int	 addVert(const ZVert &vertex);
	void addFace(ZFace &face);

	///////////////////////////////////////////////////////////////////////////
	/// Creation des normales aux faces										///
	///////////////////////////////////////////////////////////////////////////
	void CreateFacesNormalsShared(ZObject	*poss);
	void CreateFacesNormals();

	///////////////////////////////////////////////////////////////////////////
	/// Creation des normales aux vertices									///
	///////////////////////////////////////////////////////////////////////////
	void CreateVertsNormals();

	///////////////////////////////////////////////////////////////////////////
	/// Creation des listes de faces										///
	///////////////////////////////////////////////////////////////////////////
	void MakeFacesList();

	///////////////////////////////////////////////////////////////////////////
	/// Create rapid model													///
	///////////////////////////////////////////////////////////////////////////
	bool CreateRapidModel();
	void DeleteRapidModel();

	/////////////////////////////////////////////////////////////////////////////
	//// Membres de la classe pour la gestion des pixels shaders //////////////
	//////////////////////////////////////////////////////////////////////////

	void SetskinningShader() ;
	void DestroySkinningShader() ;

	void CreateListPass1();
	void CreateListPass2();
	void CreateListPassLightMap();
	void CreateListPass3();
	void CreateListPass4();
	void CreateListPassSkinning();

	void CreateDisplayList();
	void DeleteDisplayList();

	void CallDisplayList1();
	void CallDisplayList2();
	void CallDisplayListLightMap();
	void CallDisplayList3();
	void CallDisplayList4();
	/* $MS : Display list for Skinning */
	void CallDisplayListSkinning();

	void ComputeOBB();
};


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList1												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList1()
{
	glCallList(Pass1ListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList2												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList2()
{
	glCallList(Pass2ListID);
}

///////////////////////////////////////////////////////////////////////////
///		CallDisplayListLightMap											///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayListLightMap()
{
	glCallList(PassLightMapListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList3												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList3()
{
	glCallList(Pass3ListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList4												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList4()
{
	glCallList(Pass4ListID);
}

///////////////////////////////////////////////////////////////////////////
///		CallDisplayListSkinning												///
///////////////////////////////////////////////////////////////////////////
/* $MS : Display list for Skinning */
inline void ZMesh::CallDisplayListSkinning()
{
	glCallList(PassSkinningListID);
}


///////////////////////////////////////////////////////////////////////////
///		addVert															///
///////////////////////////////////////////////////////////////////////////
inline int	 ZMesh::addVert(const ZVert &vertex)
{
	Verts.resize(Verts.size()+1);

	ZVert	*curVert = &(Verts[Verts.size()-1]);

	curVert->color1 = vertex.color1;
	curVert->color2 = vertex.color2;
	curVert->Normal = vertex.Normal;
	curVert->SetCoord(vertex.x, vertex.y, vertex.z);
	curVert->ID1 = vertex.ID1 ;
	curVert->weight1 = vertex.weight1 ;
	curVert->ID2 = vertex.ID2 ;
	curVert->weight2 = vertex.weight2 ;

	NbVerts++;

	hasTopoChanged = true;

	return (Verts.size()-1);
}


///////////////////////////////////////////////////////////////////////////
///		addFace															///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::addFace(ZFace &face)
{
	Faces.resize(Faces.size()+1);

	ZFace *curFace = &(Faces[Faces.size()-1]);

	curFace->initFace();
	curFace->SetMaterial(face.GetMaterial());

	curFace->SetVertsRef(face.VertRef[0], face.VertRef[1], face.VertRef[2]);
	if( (face.VertRef[0]>=NbVerts) || (face.VertRef[1]>=NbVerts) || (face.VertRef[2]>=NbVerts) )	
	{
		curFace->dependency = true;
		dependency = true;
	}
	
	curFace->UV1[0] = face.UV1[0];
	curFace->UV1[1] = face.UV1[1];
	curFace->UV1[2] = face.UV1[2];
	curFace->UV2[0] = face.UV2[0];
	curFace->UV2[1] = face.UV2[1];
	curFace->UV2[2] = face.UV2[2];
	curFace->UV3[0] = face.UV3[0];
	curFace->UV3[1] = face.UV3[1];
	curFace->UV3[2] = face.UV3[2];
	curFace->UV4[0] = face.UV4[0];
	curFace->UV4[1] = face.UV4[1];
	curFace->UV4[2] = face.UV4[2];
	
	curFace->clampU1 = face.clampU1;
	curFace->clampV1 = face.clampV1;
	curFace->clampU2 = face.clampU2;
	curFace->clampV2 = face.clampV2;
	curFace->clampU3 = face.clampU3;
	curFace->clampV3 = face.clampV3;
	curFace->clampU4 = face.clampU4;
	curFace->clampV4 = face.clampV4;
	
	curFace->index  = NbFaces;

	NbFaces++;

	hasViewChanged = true;
	hasTopoChanged = true;
}


#include	"..\Scene Graph\ZooObject.h"

#endif


/*


#ifndef __ZOOMESH_H__
#define __ZOOMESH_H__



#include	"..\Basic\ZooStd.h"
#include	"..\Collision\rapid.h"
#include	"..\Datas\ZooMaterial.h"







///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZVert Class
///
///		- Classe des vertices d'un objet
///		- Méthodes de setting de position en Cartésienne ou en Sphérique
///		- Normale au vertex
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZVert : public ZVector3
{
public:

	// Position referenced by the center of world 
	// - without object translation & translation -
	ZVector3	Normal;				// Normal of the vertex
	ZVector3	color1;				// RGB for the primary texture - Alpha for the transparent faces
	ZVector3	color2;				// RGB for the second texture  - Alpha for the multitex blending
};














///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZFace Class
///
///		- Classe des faces d'un objet
///		- Méthode de setting des références aux vertices de l'objet
///		- Normale à la face, des normales aux points, des coordonnées de texture des vertices,
///		  et identité de la texture à afficher pour cette face
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZFace
{
protected:

	ZMaterial	*material;							// Material of the face



public:
	
	int			VertRef[3];							// Index in the object array of vertices

	ZUV			UV1[3];								// Texture coordinates of these vertices
	ZUV			UV2[3];								// Texture coordinates of these vertices

	ZVector3	Normal;								// Normal of the face
	
	bool		dependency;							// flag to design a face with shared vertices

	int			index;


	///////////////////////////////////////////////////////////////////////////
	/// Constructor & Destructor	 										///
	///////////////////////////////////////////////////////////////////////////
	// !WARNING!   IT MUST BE LIKE THIS, BECOZ OF THE DYNAMIC ARRAY OF FACES !WARNING!
	void initFace();
	void DeleteFace();



	///////////////////////////////////////////////////////////////////////////
	/// Set the vertice references of the face								///
	///////////////////////////////////////////////////////////////////////////
	void SetVertsRef(long ref0, long ref1, long ref2);
	

	///////////////////////////////////////////////////////////////////////////
	/// Set the material of the face										///
	///////////////////////////////////////////////////////////////////////////
	void SetMaterial(ZMaterial *newMat);
	ZMaterial*	GetMaterial();
};


///////////////////////////////////////////////////////////////////////////
/// Get the material of the face										///
///////////////////////////////////////////////////////////////////////////
inline ZMaterial* ZFace::GetMaterial()
{
	return material;
}

















///////////////////////////////////////////////////////////////////////////
/// Structures for mesh variables definition							///
///////////////////////////////////////////////////////////////////////////



typedef vector<ZFace*>			FaceList;						// structure for the list of faces


struct FacesByTex
{
	ZTexture		*tex;		// texture partagée par les faces de la liste globale - tri sur les texture
	FaceList		gour;		// liste des faces en gouraud
	FaceList		flat;		// liste des faces en flat
	FaceList		no;			// liste des faces avec couleur par défaut
};


struct FacesByMat
{
	ZMaterial		*mat;
	FaceList		faces;		// liste des faces en gouraud
};


typedef vector<FacesByTex>		ListFaceByTex;					// structure for the list of lists of faces
typedef vector<FacesByMat>		ListFaceByMat;					// structure for the list of lists of faces





///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZMesh Class
///
///		- Classe des meshs
///		- Méthode d'intialisation du mesh -> nbre faces et vertices, et allocation de mémoire
///		- Méthode de libération du mesh (faces et vertices)
///		- Méthodes de création des normales aux faces et aux points
///		- Tableaux de vertices et de faces
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class ZObject;


class ZMesh : public ZData
{

protected:

	int					Pass1ListID;				// IDs for the display lists of render-pass 1
	int					Pass2ListID;				// IDs for the display lists of render-pass 2
	int					Pass3ListID;				// IDs for the display lists of render-pass 3
	int					Pass4ListID;				// IDs for the display lists of render-pass 3


public:

	int					scene3D;

	long				NbVerts;					// nb of vertices
	long				NbFaces;					// nb of faces

	vector<ZFace>		Faces;						// list of faces
	vector<ZVert>		Verts;						// list of vertices

	FacesByTex			FacesFlat;					// lists of flat faces						--> Tri simple suivant GOURAUD, FLAT ou DEFAULT coloring

	ListFaceByTex		FacesColTransp;				// lists of faces - primary textur & EnvMap	--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesEnv;					// lists of faces - primary textur & EnvMap	--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesTex1;					// lists of faces - primary texture			--> Tri double : suivant la texture n°1, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	ListFaceByTex		FacesTex2;					// lists of faces - secondary texture		--> Tri double : suivant la texture n°2, puis suivant GOURAUD, FLAT ou DEFAULT coloring
	
	ListFaceByMat		FacesMatGour;				// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting
	ListFaceByMat		FacesMatFlat;				// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting
	ListFaceByMat		FacesMatNo;					// lists of faces - material				--> Tri double : suivant le matériau, puis suivant GOURAUD, FLAT ou DEFAULT lighting

	
	FaceList			FacesTransp;				// list of transparent faces				--> aucun tri

	bool				multiTex;					// flag modified in internal treatment
	bool				hasTopoChanged;
	bool				hasViewChanged;
	
	RAPID_model			*rapid;						// collision model (use for the culling too)
	bool				rapidCreated;

	bool				dependency;					// flag to design a mesh with partaged vertices
	bool				displayListCreate;			// flag to enable or disable the creation of the display lists

	float				xmin, xmax, ymin, ymax, zmin, zmax;			// coordinates of the BBOX
	
	

	///////////////////////////////////////////////////////////////////////////
	/// Constructor					 										///
	///////////////////////////////////////////////////////////////////////////
	ZMesh(int s3d, int nvert, int nface);
	~ZMesh();


	///////////////////////////////////////////////////////////////////////////
	/// Ajout de face et de vertex											///
	///////////////////////////////////////////////////////////////////////////
	int	 addVert(const ZVert &vertex);
	void addFace(ZFace &face);


	///////////////////////////////////////////////////////////////////////////
	/// Creation des normales aux faces										///
	///////////////////////////////////////////////////////////////////////////
	void CreateFacesNormalsShared(ZObject	*poss);
	void CreateFacesNormals();


	///////////////////////////////////////////////////////////////////////////
	/// Creation des normales aux vertices									///
	///////////////////////////////////////////////////////////////////////////
	void CreateVertsNormals();


	///////////////////////////////////////////////////////////////////////////
	/// Creation des listes de faces										///
	///////////////////////////////////////////////////////////////////////////
	void MakeFacesList();

	
	///////////////////////////////////////////////////////////////////////////
	/// Create rapid model													///
	///////////////////////////////////////////////////////////////////////////
	bool CreateRapidModel();



	void CreateListPass1();
	void CreateListPass2();
	void CreateListPass3();
	void CreateListPass4();

	void CreateDisplayList();

	void CallDisplayList1();
	void CallDisplayList2();
	void CallDisplayList3();
	void CallDisplayList4();


	void ComputeOBB();
};



///////////////////////////////////////////////////////////////////////////
///		CallDisplayList1												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList1()
{
	glCallList(Pass1ListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList2												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList2()
{
	glCallList(Pass2ListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList3												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList3()
{
	glCallList(Pass3ListID);
}


///////////////////////////////////////////////////////////////////////////
///		CallDisplayList4												///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::CallDisplayList4()
{
	glCallList(Pass4ListID);
}



///////////////////////////////////////////////////////////////////////////
///		addVert															///
///////////////////////////////////////////////////////////////////////////
inline int	 ZMesh::addVert(const ZVert &vertex)
{
	Verts.resize(Verts.size()+1);
	
	ZVert	*curVert = &(Verts[Verts.size()-1]);
	
	curVert->color1 = vertex.color1;
	curVert->color2 = vertex.color2;
	curVert->Normal = vertex.Normal;
	curVert->SetCoord(vertex.x, vertex.y, vertex.z);

	NbVerts++;
	
	hasTopoChanged = true;

	return (Verts.size()-1);
}



///////////////////////////////////////////////////////////////////////////
///		addFace															///
///////////////////////////////////////////////////////////////////////////
inline void ZMesh::addFace(ZFace &face)
{
	Faces.resize(Faces.size()+1);
	
	ZFace *curFace = &(Faces[Faces.size()-1]);

	curFace->initFace();
	curFace->SetMaterial(face.GetMaterial());
	
	curFace->SetVertsRef(face.VertRef[0], face.VertRef[1], face.VertRef[2]);
	if( (face.VertRef[0]>=NbVerts) || (face.VertRef[1]>=NbVerts) || (face.VertRef[2]>=NbVerts) )	
	{
		curFace->dependency = true;
		dependency = true;
	}
	
	curFace->UV1[0] = face.UV1[0];
	curFace->UV1[1] = face.UV1[1];
	curFace->UV1[2] = face.UV1[2];
	curFace->UV2[0] = face.UV2[0];
	curFace->UV2[1] = face.UV2[1];
	curFace->UV2[2] = face.UV2[2];
	curFace->index  = NbFaces;

	NbFaces++;

	hasViewChanged = true;
	hasTopoChanged = true;
}




#include	"..\Scene Graph\ZooObject.h"





#endif

  */