// cVertex.h
// 2/27/04
// Stores the position of the vertex, as well as
// a list of faces that touch the vertex.
// 3/5/04
// Forrest Briggs
// Changed vertex class so that rather than having a vector v_,
// it is a vector itself. this means a lot less uncessary typing of
// v_, but i had to go through all of the other code and take it out.
// 3/6/04 
// Forrest Briggs
// added per vertex colors
// 3 / 22 / 04 Forrest Briggs
// vertices storestexture coodinates, compute vertex normals, have a flag to prevent adding to
// a collision list multiples times 

#ifndef cvertex_h
#define cvertex_h

#include "ForwardDeclarations.h"
#include "cVector.h"
#include "cTriangle.h"
#include "cEdge.h"
#include "cTextureCoord.h"
#include <vector>

class cVertex : public cVector
{
public:
    // constructors that call super constructor
    
    // default, sets everything to 0
    cVertex() : 
        cVector(), 
        textureCoord_(0,0),
        numFaces_(0), 
        hasBeenAddedToCollisionList_(false) {}
        
    // initialize x, y, z and set everything else to 0
    cVertex(const float x, const float y, const float z) : 
        cVector(x, y, z), 
        textureCoord_(0,0),
        numFaces_(0), 
        hasBeenAddedToCollisionList_(false) {}
        
    // initialize x, y, z, u, v and set everything else to 0
    cVertex(const float x, const float y, const float z, const float u, const float v) : 
        cVector(x, y, z), 
        textureCoord_(u,v),
        numFaces_(0), 
        hasBeenAddedToCollisionList_(false) {}
    
    // copy constructor for vector
    cVertex(const cVector& toCopy) : 
        cVector(toCopy), 
        textureCoord_(0,0),
        numFaces_(0), 
        hasBeenAddedToCollisionList_(false) {}
    
    // copy constructor for vertex
    cVertex(const cVertex& toCopy) : 
        cVector(toCopy), 
        textureCoord_(toCopy.textureCoord_),
        numFaces_(0), 
        hasBeenAddedToCollisionList_(false) {}
    
    // modified the referenced variable normal and returns the number
    // of normals it averaged
    void getSumForwardFacingNormal(cVector& incident, cVector& normal);
    
    void computeVertexNormal();
    
    cVector normal_;			// vertex normal used for lighting calculations
    
    cTextureCoord textureCoord_;
    
    int numFaces_; 			// how many faces touch this vertex
    vector<cTriangle*> triangles_;	// all of the triangles touching this point
    
    bool hasBeenAddedToCollisionList_;	// used by build collision lists so vertices are never added more than once
};

#endif // end define cvertex_h