/*****************************************************************************

File: Vector2i.h
Desc: A vertex primitive for the planetary data
		
Date: 2005/01/01

Author: Wim Lemkens

*****************************************************************************/

#ifndef VERTEX_H
#define VERTEX_H

#include <OgreVector3.h>
#include "ClipmapConfig.h"

namespace Ogre {

class Vertex{
public:

/// Default constructor and destructor
Vertex(){}
~Vertex(){}

	/**
	 * Constructor with initialisation
	 * @param	Vector3& vertex
	 * 			The position of the vertex in world coordinates
	 * @param	Vector3 &normal
	 * 			The normal of the vertex
	 * @param	Real height=0
	 * 			The height above the sphere
	 */
#if USE_NORMALS
	Vertex(Vector3& vertex, Vector3 &normal, Real height=0){
		setVertex(vertex);
		setNormal(normal);
		setHeight(height);
	}
#else
	Vertex(Vector3& vertex,Real height=0){
		setVertex(vertex);
		setHeight(height);
	}
#endif

	/**
	 * Set the vertexcoordinates
	 * @param	Vector3& vertex
	 * 			The position of the vertex in world coordinates
	 */
	void setVertex(Vector3& vertex){
		this->vertex = vertex;
	}

	/**
	 * Return the vertexcoordinates
	 */
	Vector3 getVertex(){
		return vertex;
	}


#if USE_NORMALS
	/**
	 * Set the normal
	 * @param	Vector3 &normal
	 * 			The normal of the vertex
	 */
	void setNormal(Vector3& normal){
		this->normal = normal;
	}
	/**
	 * Return the normal
	 */
	Vector3 getNormal(){
		return normal;
	}
#endif

#if USE_TEXTURES
	/**
	 * Set the texturecoordinates
	 * @param	Real x
	 * 			the x-component of the texturecoordinate
	 * @param	Real y
	 * 			the y-component of the texturecoordinate
	 */
	void setTextureCoordinates(Real x, Real y){
		tx = x;
		ty = y;
	}
	/**
	 * Returns the texturecoordinates in the given parameters
	 * @param	Real &x
	 * 			the x-component of the texturecoordinate
	 * @param	Real &y
	 * 			the y-component of the texturecoordinate
	 */
	void fillTextureCoordinates(Real &x, Real &y){
		x = tx;
		y = ty;
	}
	
#endif

	/**
	 * Sets the height of the vertex above the sphere
	 * @param	Real height
	 * 			The height above the sphere
	 */
	void setHeight(Real height){
		this->height = height;
	}

	/**
	 * Returns the height of the vertex above the sphere
	 */
	Real getHeight(){
		return height;
	}

private:
	///	The position of the vertex
	Vector3 vertex;
	/// The height above the sphere of the vertex
	Real height;	

#if USE_NORMALS
	///	The normal of the vertex
	Vector3 normal;
#endif
#if USE_TEXTURES
	/// The texture coordinates
	Real tx,ty;
#endif
	
};

} // namespace Ogre

#endif // VERTEX_H

