From 80ad7e99b738f367eb045768d054cf74347ee1b4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 24 Mar 2008 11:08:22 +0000 Subject: merged vertex and evertex arrays --- src/core/model.h | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/core/model.h') diff --git a/src/core/model.h b/src/core/model.h index bdfeb86..51e9ca7 100644 --- a/src/core/model.h +++ b/src/core/model.h @@ -23,11 +23,10 @@ class Model; namespace core { -/// Global vertex array - - +/// size of the global vertex array - 32M const size_t VERTEXARRAYSIZE=65536*512; +/// global vertex array class VertexArray { public: @@ -36,19 +35,40 @@ public: static float vertex_color[VERTEXARRAYSIZE]; static float vertex_normal[VERTEXARRAYSIZE]; - /// model vertices with entity color - static float evertex[VERTEXARRAYSIZE]; - static float evertex_normal[VERTEXARRAYSIZE]; - static size_t vertex_index; - static size_t evertex_index; static void clear(); static void add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color); - static void add_evertex(math::Vector3f const &v, math::Vector3f const &n); +}; - +/// a model triangle +class Triangle +{ +public: + /// a new triangle with 3 vertices, a normal, color and a detail flag + Triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &n, + math::Color *color=0, bool detail=false); + ~Triangle(); + + /// normal of the triangle + inline math::Vector3f const & normal() const { return triangle_normal; } + /// color of the triangle + inline math::Color const & color() const { return triangle_color;} + /// indidcates if this triangle was generated from a detail brush + inline bool detail() const { return triangle_detail; } + + /// triangle vertex 0 + math::Vector3f triangle_v0; + /// triangle vertex 1 + math::Vector3f triangle_v1; + /// triangle vertex 2 + math::Vector3f triangle_v2; + +private: + math::Vector3f triangle_normal; + math::Color triangle_color; + bool triangle_detail; }; /// a spacecraft engine @@ -119,6 +139,9 @@ public: /// number of vertexes in this model inline size_t evertex_count() const { return model_evertex_count; } + /// number of triangles in this mdel + inline size_t tris() const { return (model_vertex_count + model_evertex_count)/3; } + /// radius inline float radius() const { return model_radius; } @@ -161,6 +184,10 @@ private: math::Vector3f model_maxbbox; math::Vector3f model_minbbox; + // tmp lists with triangles + std::list model_tris; + std::list model_etris; + size_t model_first_vertex; size_t model_vertex_count; size_t model_first_evertex; -- cgit v1.2.3