/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/graphics/sgxprimitives.hpp

*/

#ifndef SGX_GRAPHICS_PRIMITIVES_HPP
#define SGX_GRAPHICS_PRIMITIVES_HPP		1

class sgxGfxPolygon : public sgxPrimitivePolygon
{
public:
	const CSGXTexture		*pTexture;
	CPlatformData			*m_pPlatformData;

// TODO: CALL BASE CLASS
	sgxGfxPolygon() : sgxPrimitivePolygon() { m_pPlatformData = NULL; pTexture = NULL; }
	sgxGfxPolygon(const sgxVector3 &pv1, const sgxVector3 &pv2, const sgxVector3 &pv3) :sgxPrimitivePolygon(pv1,pv2,pv3) { pTexture = NULL; m_pPlatformData = NULL; }
	sgxGfxPolygon(const sgxPolyVtx &pv1, const sgxPolyVtx &pv2, const sgxPolyVtx &pv3) :sgxPrimitivePolygon(pv1,pv2,pv3) { pTexture = NULL; m_pPlatformData = NULL; }
	~sgxGfxPolygon() { delete m_pPlatformData; /* We do not take ownership of the pTexture ptr */ }

	void	draw(const sgxMatrix43 &transform) const;

};

class sgxGfxSphere : public sgxPrimitiveSphere
{
public:
	sgxGfxSphere() : sgxPrimitiveSphere(1) {}
	sgxGfxSphere(tREAL32 r) : sgxPrimitiveSphere(r) {}

};

class CStaticMesh : public sgxPrimitiveBase
{
public:
	sgxVector<sgxGfxPolygon>	m_Polygons;
	CPlatformData			*m_pPlatformData;

	CStaticMesh();
	~CStaticMesh();
	void	Clear();
	void	draw(const sgxMatrix43 &transform) const;
	void	addPolygon(const sgxGfxPolygon &poly);
	void	addPolygon(const sgxVector3 &v1, const sgxVector3 &v2, const sgxVector3 &v3);
	void	addPolygon(const sgxPolyVtx &v1, const sgxPolyVtx &v2, const sgxPolyVtx &v3);
	void	addPolygon(const CSGXTexture &texture, const sgxVector3 &v1, const sgxVector3 &v2, const sgxVector3 &v3);
};

class sgxCuboidFace
{
public:
	const CSGXTexture	*pTexture;
	sgxUV				uv;
	sgxColorRGBA		color[4];
};

class sgxGfxCuboid : public sgxPrimitiveCuboid
{
public:
	sgxCuboidFace	face[6];

	void	setCuboidColor(const sgxColorRGB &col);
	void	setCuboidColor(const sgxColorRGBA &col);
	void	setCuboidAlpha(const tREAL32 &alpha);
	void	setCuboidTexture(const CSGXTexture *pTexture);
};

class CAnimatedMesh : public sgxPrimitiveBase
{
public:
	CAnimatedMesh(const sgxString &md2);
	void	update(const tREAL32 telaps);
	void	draw(const sgxMatrix43 &transform) const;

//protected:
	CPlatformData	*m_pPlatformAnim;

private:
	CAnimatedMesh() { sgxError("You must construct this object with"); }

};

#endif /* SGX_GRAPHICS_PRIMITIVES_HPP */
