Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-24 11:08:22 +0000
committerStijn Buys <ingar@osirion.org>2008-03-24 11:08:22 +0000
commit80ad7e99b738f367eb045768d054cf74347ee1b4 (patch)
tree95e3b528ad8b2e5a8ab5b91cf7b62dd9acf745de /src/core/model.h
parent5a099735d5457298b87a33884356ff29417143e6 (diff)
merged vertex and evertex arrays
Diffstat (limited to 'src/core/model.h')
-rw-r--r--src/core/model.h47
1 files changed, 37 insertions, 10 deletions
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<Triangle *> model_tris;
+ std::list<Triangle *> model_etris;
+
size_t model_first_vertex;
size_t model_vertex_count;
size_t model_first_evertex;