/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     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: sgx/src/sgx/graphics/mesh/sgxmesh.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/graphics/graphics.hpp"


CStaticMesh::CStaticMesh()
{
	m_pPlatformData = NULL;
}

CStaticMesh::~CStaticMesh()
{
	if (m_pPlatformData) {
		delete m_pPlatformData;
	}
}

void 
CStaticMesh::Clear()
{
	m_Polygons.clear();
}

void 
CStaticMesh::draw(const sgxMatrix43 &transform) const
{
	CSGXGraphicsEngine::get()->drawMesh(*this, transform);
}

void 
CStaticMesh::addPolygon(const sgxGfxPolygon &poly)
{
	m_Polygons.push_back(poly);
}

void 
CStaticMesh::addPolygon(const sgxVector3 &v1, const sgxVector3 &v2, const sgxVector3 &v3)
{
	sgxGfxPolygon poly(sgxPolyVtx(v1,0,0), sgxPolyVtx(v2,1,0), sgxPolyVtx(v3,1,1));
	poly.pTexture = NULL;
	addPolygon(poly);
}

void 
CStaticMesh::addPolygon(const sgxPolyVtx &v1, const sgxPolyVtx &v2, const sgxPolyVtx &v3)
{
	sgxGfxPolygon poly(v1, v2, v3);
	poly.pTexture = NULL;
	addPolygon(poly);
}

void 
CStaticMesh::addPolygon(const CSGXTexture &texture, const sgxVector3 &v1, const sgxVector3 &v2, const sgxVector3 &v3)
{
	sgxGfxPolygon poly(v1, v2, v3);
	poly.pTexture = &texture;
	addPolygon(poly);
}

