/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


#ifndef	__GEOMETRYTOTRIANGLELIST__
#define	__GEOMETRYTOTRIANGLELIST__


		#include "ntypes.h"
		#include "container/nlist.h"


namespace GS {
	namespace Core {
		class Geometry;
		struct Trilist;

/*!
	@short	Geometry to triangle list conversion object.

	Takes and convert the original polygonal representation of a geometry into a
	list of triangle list.
	Each triangle list contains the same buffers as a polygonal geometry
	(vertex, normal, UV, etc...) in the same organization and an index buffer.

	Care is taken not to duplicate homogeneous vertices (sharing the same
	properties). Triangle lists are always split by material so there is never
	more than one material per list.

	@author	Emmanuel Julien (ejulien@gsworks.fr)
*/
		namespace GeometryToTriangleList {

/*!
	@short	Convert a polygonal geometry to a triangle list representation.

	@note	You can specify the maximum of triangles per triangle list to
			this function, the function guarantees that this number is
			not exceeded (this is used by some renderer when there is
			a limit on the index data type size).

	@note	The limit is expressed in number of triangles.
			So to limit a triangle list to 65536 index you should limit
			the number of triangles to 21845 or 65536/3!

	@note	You can optionally call the triangle list optimization function
			by passing a non zero positive value to the optimize_cache
			parameter.
			@see	Optimize().
*/
bool		Convert(const Geometry &, AutoList <Trilist *> &, uint max_tri_per_list = 16384, uint vtx_cache_size = 16);

		} // GeometryToTriangleList
	} // Core
} // GS


#endif	// __GEOMETRYTOTRIANGLELIST__
