Files
Webcam/include/engine/core/geometry_template.h
2026-06-22 11:49:35 +02:00

92 lines
1.8 KiB
C++

/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NGEOMETRYTEMPLATE__
#define __NGEOMETRYTEMPLATE__
#include "core/geometry.h"
#include "container/nlist.h"
namespace GS {
namespace Core {
/*!
@short Geometry template class.
@author Thomas Simonnet (scorpheus)
@author Emmanuel Julien (ejulien@nworks.fr)
*/
class GeometryTemplate
{
/// Polygon template.
struct Polygon
{
List <Vector4> vertex;
List <Vector4> normal;
List <Color> color;
List <Vector2> uv[__UV_PER_GEOMETRY__];
ushort material;
};
/// Polygon vertex.
struct PolygonVertex
{
uint ipoly;
uint ivertex;
};
Vector4 GetVertex(const PolygonVertex &);
Vector4 GetNormal(const PolygonVertex &);
Vector2 GetUV(uint channel, const PolygonVertex &);
Color GetColor(const Color &);
float merge_threshold;
AutoPtr <Polygon> polygon;
AutoList <Polygon *> polygons;
List <String> materials;
public:
/*!
@name Polygon declaration.
@{
*/
void Clear();
void BeginPolygon();
void PushVertex(const Vector4 &);
void PushNormal(const Vector4 &);
void PushUV(uint channel, const Vector2 &);
void PushColor(const Color &);
void EndPolygon(ushort material_index);
/*!
@}
@name Material table declaration.
@{
*/
void ClearMaterials();
void PushMaterial(const char *uri);
/// @}
/// Set the vertex merge threshold.
void SetVertexMergeThreshold(float threshold)
{ merge_threshold = threshold; }
/// Instantiate the current template description.
Geometry *Instantiate(const char *name);
GeometryTemplate();
};
} // Core
} // GS
#endif // __NGEOMETRYTEMPLATE__