Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/fragment.cc4
-rw-r--r--src/model/fragment.h3
-rw-r--r--src/model/map.cc49
-rw-r--r--src/model/primitives.cc8
-rw-r--r--src/model/primitives.h8
-rw-r--r--src/model/quad.cc5
-rw-r--r--src/model/quad.h9
-rw-r--r--src/model/triangle.cc5
-rw-r--r--src/model/triangle.h9
-rw-r--r--src/model/vertexarray.cc23
-rw-r--r--src/model/vertexarray.h13
11 files changed, 53 insertions, 83 deletions
diff --git a/src/model/fragment.cc b/src/model/fragment.cc
index d8479eb..7765b7e 100644
--- a/src/model/fragment.cc
+++ b/src/model/fragment.cc
@@ -25,9 +25,9 @@ Fragment::Fragment(Type type, const Material *material)
fragment_detail_size = 0;
}
-size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Color const & color, bool detail)
+size_t Fragment::add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, bool detail)
{
- size_t n = VertexArray::instance()->add_vertex(vertex, normal, color);
+ size_t n = VertexArray::instance()->add_vertex(vertex, normal);
if (n) {
if (detail)
fragment_detail_size += n;
diff --git a/src/model/fragment.h b/src/model/fragment.h
index d9c200d..e975734 100644
--- a/src/model/fragment.h
+++ b/src/model/fragment.h
@@ -10,7 +10,6 @@
#include <list>
#include "math/axis.h"
-#include "math/color.h"
#include "math/vector3f.h"
#include "model/material.h"
@@ -28,7 +27,7 @@ public:
Fragment(Type type, const Material *material);
/// add a vertex to the fragment
- size_t add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, math::Color const & color, bool detail);
+ size_t add_vertex(math::Vector3f const & vertex, math::Vector3f const &normal, bool detail);
/// the type of primitives this fragment consists of
inline Type type() const
diff --git a/src/model/map.cc b/src/model/map.cc
index 1d1983c..c2b184f 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -434,13 +434,10 @@ void Map::make_brushface(Plane *face)
if (vl.size() > 2) {
Material *material = Material::find(face->texture());
- math::Color color(1.0, 0.0f, 1.0f);
- if (material) {
- color.assign(material->color());
- } else {
+ if (!material) {
material = new Material(face->texture());
Material::add(material);
- material->set_color(color);
+ material->set_color(math::Color(1.0, 0.0f, 1.0f));
material->set_flags(Material::Bright);
// don't show material warnings on a dedicated server
@@ -470,8 +467,12 @@ void Map::make_brushface(Plane *face)
class_minbbox[i] = (*(*it))[i];
}
}
-/* Quads are disable to use model data for bullet physics
-
+
+
+#ifndef HAVE_BULLET
+
+ // Quads are disable to use model data for bullet physics
+
// split polygon into quads
while (vl.size() > 3) {
std::vector<Vector3f *>::iterator v0 = vl.begin();
@@ -485,13 +486,13 @@ void Map::make_brushface(Plane *face)
Vector3f n(face->normal()*-1);
n.normalize();
- primitives->add_quad(*(*vn2), *(*vn1), *(*vn), *(*v0), n, color, face->detail());
+ primitives->add_quad(*(*vn2), *(*vn1), *(*vn), *(*v0), n, face->detail());
delete(*vn);
delete(*vn1);
vl.pop_back();
vl.pop_back();
}
-*/
+#endif
// split polygon into triangles
while (vl.size() > 2) {
std::vector<Vector3f *>::iterator v0 = vl.begin();
@@ -502,7 +503,7 @@ void Map::make_brushface(Plane *face)
Vector3f n(face->normal()*-1);
n.normalize();
- primitives->add_triangle(*(*vn1), *(*vn), *(*v0), n, color, face->detail());
+ primitives->add_triangle(*(*vn1), *(*vn), *(*v0), n, face->detail());
delete(*vn);
vl.pop_back();
}
@@ -677,9 +678,9 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
Triangle *triangle = (*tris_it);
if (!triangle->detail()) {
size_t count = 0;
- count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), triangle->color(), false);
- count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), triangle->color(), false);
- count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), triangle->color(), false);
+ count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), false);
+ count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), false);
+ count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), false);
if (count == 3)
model->model_tris_count++;
}
@@ -690,9 +691,9 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
Triangle *triangle = (*tris_it);
if (triangle->detail()) {
size_t count = 0;
- count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), triangle->color(), true);
- count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), triangle->color(), true);
- count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), triangle->color(), true);
+ count += fragment->add_vertex(triangle->v0()-map_center, triangle->normal(), true);
+ count += fragment->add_vertex(triangle->v1()-map_center, triangle->normal(), true);
+ count += fragment->add_vertex(triangle->v2()-map_center, triangle->normal(), true);
if (count == 3) {
model->model_tris_count++;
model->model_tris_detail_count++;
@@ -713,10 +714,10 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
Quad *quad = (*quad_it);
if (!quad->detail()) {
size_t count = 0;
- count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), quad->color(), false);
+ count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), false);
if (count == 4)
model->model_quad_count++;
}
@@ -727,10 +728,10 @@ void Map::load_fragmentgroup(Model *model, const FragmentGroup::Type class_type)
Quad *quad = (*quad_it);
if (quad->detail()) {
size_t count = 0;
- count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), quad->color(), false);
- count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), quad->color(), false);
+ count += fragment->add_vertex(quad->v0()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v1()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v2()-map_center, quad->normal(), false);
+ count += fragment->add_vertex(quad->v3()-map_center, quad->normal(), false);
if (count == 4) {
model->model_quad_count++;
model->model_quad_detail_count++;
diff --git a/src/model/primitives.cc b/src/model/primitives.cc
index a53ebcd..5e58b50 100644
--- a/src/model/primitives.cc
+++ b/src/model/primitives.cc
@@ -28,16 +28,16 @@ Primitives::~Primitives()
}
void Primitives::add_triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2,
- math::Vector3f const &normal, math::Color const &color, bool detail)
+ math::Vector3f const &normal, bool detail)
{
- Triangle *triangle = new Triangle(v0, v1, v2, normal, color, detail);
+ Triangle *triangle = new Triangle(v0, v1, v2, normal, detail);
primitives_triangles.push_back(triangle);
}
void Primitives::add_quad(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &v3,
- math::Vector3f const &normal, math::Color const &color, bool detail)
+ math::Vector3f const &normal, bool detail)
{
- Quad *quad = new Quad(v0, v1, v2, v3, normal, color, detail);
+ Quad *quad = new Quad(v0, v1, v2, v3, normal, detail);
primitives_quads.push_back(quad);
}
diff --git a/src/model/primitives.h b/src/model/primitives.h
index 2b53b5a..d113961 100644
--- a/src/model/primitives.h
+++ b/src/model/primitives.h
@@ -10,7 +10,6 @@
#include <list>
#include "math/vector3f.h"
-#include "math/color.h"
#include "model/material.h"
#include "model/triangle.h"
#include "model/quad.h"
@@ -51,12 +50,11 @@ public:
/// add a Triangle primitive
void add_triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2,
- math::Vector3f const &normal, math::Color const &color, bool detail);
-
+ math::Vector3f const &normal, bool detail);
+
/// add a Quad primitive
void add_quad(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &v3,
- math::Vector3f const &normal, math::Color const &color, bool detail);
-
+ math::Vector3f const &normal, bool detail);
private:
Triangles primitives_triangles;
Quads primitives_quads;
diff --git a/src/model/quad.cc b/src/model/quad.cc
index 0b8b208..5bed2e4 100644
--- a/src/model/quad.cc
+++ b/src/model/quad.cc
@@ -10,13 +10,12 @@ namespace model
{
Quad::Quad(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &v3,
- math::Vector3f const &normal, math::Color const &color, bool detail) :
+ math::Vector3f const &normal, bool detail) :
quad_v0(v0),
quad_v1(v1),
quad_v2(v2),
quad_v3(v3),
- quad_normal(normal),
- quad_color(color)
+ quad_normal(normal)
{
quad_detail = detail;
}
diff --git a/src/model/quad.h b/src/model/quad.h
index 42832d0..2950477 100644
--- a/src/model/quad.h
+++ b/src/model/quad.h
@@ -19,7 +19,7 @@ class Quad
public:
/// a new quad with 4 vertices, a normal, color and a detail flag
Quad(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2, math::Vector3f const &v3,
- math::Vector3f const &normal, math::Color const & color, bool detail);
+ math::Vector3f const &normal, bool detail);
/// delete quad
~Quad();
@@ -29,12 +29,6 @@ public:
return quad_normal;
}
- /// color of the quad
- inline math::Color const & color() const
- {
- return quad_color;
- }
-
/// indidcates if this quad was generated from a detail brush
inline bool detail() const
{
@@ -72,7 +66,6 @@ private:
math::Vector3f quad_v3;
math::Vector3f quad_normal;
- math::Color quad_color;
bool quad_detail;
};
diff --git a/src/model/triangle.cc b/src/model/triangle.cc
index 807d536..162b68a 100644
--- a/src/model/triangle.cc
+++ b/src/model/triangle.cc
@@ -10,12 +10,11 @@ namespace model
{
Triangle::Triangle(math::Vector3f const &v0, math::Vector3f const &v1, math::Vector3f const &v2,
- math::Vector3f const &normal, math::Color const &color, bool detail) :
+ math::Vector3f const &normal, bool detail) :
triangle_v0(v0),
triangle_v1(v1),
triangle_v2(v2),
- triangle_normal(normal),
- triangle_color(color)
+ triangle_normal(normal)
{
triangle_detail = detail;
}
diff --git a/src/model/triangle.h b/src/model/triangle.h
index 8f4a6a5..416a3e6 100644
--- a/src/model/triangle.h
+++ b/src/model/triangle.h
@@ -19,7 +19,7 @@ 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 &normal, math::Color const & color, bool detail);
+ math::Vector3f const &normal, bool detail);
/// delete triangle
~Triangle();
@@ -29,12 +29,6 @@ public:
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
{
@@ -65,7 +59,6 @@ private:
math::Vector3f triangle_v2;
math::Vector3f triangle_normal;
- math::Color triangle_color;
bool triangle_detail;
};
diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc
index dc5e23e..8509dc6 100644
--- a/src/model/vertexarray.cc
+++ b/src/model/vertexarray.cc
@@ -21,10 +21,9 @@ VertexArray::VertexArray(size_t size)
vertex_instance = this;
vertex_size = size * 1024*1024; // megabytes
vertex_size = vertex_size / sizeof(float); // sizeof float
- vertex_size = vertex_size / 4; // 4 arrays
+ vertex_size = vertex_size / 3; // 3 arrays
vertex_vertex = (float *) malloc(vertex_size * sizeof(float));
- vertex_color = (float *) malloc(vertex_size * sizeof(float));
vertex_normal = (float *) malloc(vertex_size * sizeof(float));
vertex_texture = (float *) malloc(vertex_size * sizeof(float));
@@ -38,7 +37,6 @@ VertexArray::~VertexArray()
{
free(vertex_vertex);
free(vertex_normal);
- free(vertex_color);
free(vertex_texture);
vertex_instance = 0 ;
@@ -50,7 +48,6 @@ void VertexArray::clear()
vertex_overflow = false;
memset(vertex_vertex, 0, sizeof(vertex_vertex));
- memset(vertex_color, 0, sizeof(vertex_color));
memset(vertex_normal, 0, sizeof(vertex_normal));
memset(vertex_texture, 0, sizeof(vertex_texture));
@@ -75,7 +72,6 @@ void VertexArray::add_sphere()
}
// draw body
- math::Color white(1.0f, 1.0f, 1.0f);
math::Vector3f v;
math::Vector3f n;
float texx, texy;
@@ -94,14 +90,14 @@ void VertexArray::add_sphere()
n.normalize();
texx = (float)i/(float)(SPHERESEGMENTS-1);
texy = -costable[j]/2 + 0.5f;
- add_vertex(v, n, white, texx, texy);
+ add_vertex(v, n, texx, texy);
v = math::Vector3f(r1*costable[i], r1*sintable[i], costable[j+1]);
n = v;
n.normalize();
texx = (float)i/(float)(SPHERESEGMENTS-1);
texy = -costable[j+1]/2 + 0.5f;
- add_vertex(v, n, white, texx, texy);
+ add_vertex(v, n, texx, texy);
quad_count++;
}
@@ -122,14 +118,14 @@ void VertexArray::add_sphere()
n.normalize();
texx = 1-(float)i/(float)(SPHERESEGMENTS-1);
texy = -costable[j]/2 + 0.5f;
- add_vertex(v, n, white, texx, texy);
+ add_vertex(v, n, texx, texy);
v = math::Vector3f(r1*costable[i], r1*sintable[i], costable[j+1]);
n = v;
n.normalize();
texx = 1-(float)i/(float)(SPHERESEGMENTS-1);
texy = -costable[j+1]/2 + 0.5f;
- add_vertex(v, n, white, texx, texy);
+ add_vertex(v, n, texx, texy);
}
}
@@ -138,7 +134,7 @@ void VertexArray::add_sphere()
delete[] costable;
}
-size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, float tex_x, float tex_y)
+size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, float tex_x, float tex_y)
{
if (vertex_index + 3 >= vertex_size) {
if (!vertex_overflow) {
@@ -152,14 +148,9 @@ size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n,
vertex_vertex[vertex_index+i] = v[i];
vertex_normal[vertex_index+i] = n[i];
}
-
- vertex_color[vertex_index] = color.r;
- vertex_color[vertex_index+1] = color.g;
- vertex_color[vertex_index+2] = color.b;
-
+
vertex_texture[vertex_index] = tex_x;
vertex_texture[vertex_index+1] = tex_y;
- // reserved
vertex_texture[vertex_index+2] = 0;
vertex_index += 3;
diff --git a/src/model/vertexarray.h b/src/model/vertexarray.h
index 8312789..4277442 100644
--- a/src/model/vertexarray.h
+++ b/src/model/vertexarray.h
@@ -7,13 +7,13 @@
#ifndef __INCLUDED_MODEL_VERTEXARRAY_H__
#define __INCLUDED_MODEL_VERTEXARRAY_H__
-#include "math/color.h"
#include "math/vector3f.h"
namespace model
{
-const int SPHERESEGMENTS=65;
+// number of segments in a sphere circle, must be uneven
+const int SPHERESEGMENTS = 65;
/// global vertex array
/** a VertexArray acts like a stack of model vertices, it has no knowledge of what it is holding
@@ -27,20 +27,18 @@ public:
void clear();
- size_t add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, float tex_x=0.0f, float tex_y=0.0f);
+ size_t add_vertex(math::Vector3f const &v, math::Vector3f const &n, float tex_x=0.0f, float tex_y=0.0f);
inline float *vertex()
{
return vertex_vertex;
}
- inline float *color()
- {
- return vertex_color;
- }
+
inline float *normal()
{
return vertex_normal;
}
+
inline float *texture()
{
return vertex_texture;
@@ -71,7 +69,6 @@ public:
private:
/// model vertices
float *vertex_vertex;
- float *vertex_color;
float *vertex_normal;
float *vertex_texture;