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/map.cc27
-rw-r--r--src/model/mapfile.cc12
-rw-r--r--src/model/mapfile.h3
-rw-r--r--src/model/model.cc9
-rw-r--r--src/model/model.h15
-rw-r--r--src/model/plane.cc1
-rw-r--r--src/model/plane.h3
7 files changed, 65 insertions, 5 deletions
diff --git a/src/model/map.cc b/src/model/map.cc
index fea98e0..4b78f762 100644
--- a/src/model/map.cc
+++ b/src/model/map.cc
@@ -102,7 +102,7 @@ Model * Map::load(std::string const &name)
mapfile.close();
- if (VertexArray::instance() && ((mapfile.class_tris.size() + mapfile.class_etris.size()) > 0)) {
+ if (VertexArray::instance() && ((mapfile.class_tris.size() + mapfile.class_etris.size() + mapfile.class_ltris.size()) > 0)) {
math::Vector3f center = (mapfile.class_minbbox + mapfile.class_maxbbox) / 2;
@@ -161,6 +161,31 @@ Model * Map::load(std::string const &name)
}
mapfile.class_etris.clear();
+ // structural ltriangles
+ model->model_first_lvertex = VertexArray::instance()->index()/3;
+ for (std::list<Triangle *>::iterator it = mapfile.class_ltris.begin(); it != mapfile.class_ltris.end(); it++) {
+ Triangle *triangle = (*it);
+ if (!triangle->detail()) {
+ VertexArray::instance()->add_vertex(triangle->triangle_v0-center, triangle->normal(), triangle->color() );
+ VertexArray::instance()->add_vertex(triangle->triangle_v1-center, triangle->normal(), triangle->color() );
+ VertexArray::instance()->add_vertex(triangle->triangle_v2-center, triangle->normal(), triangle->color() );
+ model->model_lvertex_count += 3;
+ }
+ }
+
+ // detail ltriangles
+ for (std::list<Triangle *>::iterator it = mapfile.class_ltris.begin(); it != mapfile.class_ltris.end(); it++) {
+ Triangle *triangle = (*it);
+ if (triangle->detail()) {
+ VertexArray::instance()->add_vertex(triangle->triangle_v0-center, triangle->normal(), triangle->color() );
+ VertexArray::instance()->add_vertex(triangle->triangle_v1-center, triangle->normal(), triangle->color() );
+ VertexArray::instance()->add_vertex(triangle->triangle_v2-center, triangle->normal(), triangle->color() );
+ model->model_lvertex_countdetail += 3;
+ }
+ delete triangle;
+ }
+ mapfile.class_ltris.clear();
+
// reposition light and engines
for (std::list<Engine *>::iterator eit = model->model_engine.begin(); eit != model->model_engine.end(); eit++) {
(*eit)->engine_location -= center;
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 6252886..922e2db 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -169,7 +169,7 @@ bool MapFile::getline() {
for (int i=0; i < 5; i++)
linestream >> tmp;
- // surface flags ?
+ // content flags ?
if (!(linestream >> n))
n = 0;
@@ -177,6 +177,12 @@ bool MapFile::getline() {
plane->texture() = texture;
if (n > 0)
plane->detail() = true;
+
+ // surface flags
+ if (!(linestream >> n))
+ n = 0;
+ plane->surface_flags() = n;
+
planes.push_back(plane);
}
value_current.clear();
@@ -431,6 +437,10 @@ void MapFile::make_brushface(Plane *face)
// evertices will be added to the VertexArray after normal vertices
Triangle *triangle = new Triangle(*(*vn1), *(*vn), *(*v0), n, 0, face->detail());
class_etris.push_back(triangle);
+ } else if ((face->surface_flags() & 1) == 1 ) {
+ // lvertices
+ Triangle *triangle = new Triangle(*(*vn1), *(*vn), *(*v0), n, color, face->detail());
+ class_ltris.push_back(triangle);
} else {
Triangle *triangle = new Triangle(*(*vn1), *(*vn), *(*v0), n, color, face->detail());
class_tris.push_back(triangle);
diff --git a/src/model/mapfile.h b/src/model/mapfile.h
index 4349621..e599ec0 100644
--- a/src/model/mapfile.h
+++ b/src/model/mapfile.h
@@ -95,6 +95,9 @@ public:
/// tmp lists with triangles
std::list<Triangle *> class_tris;
+ /// tmp lists with light triangles
+ std::list<Triangle *> class_ltris;
+
/// tmp lists with entity color triangles
std::list<Triangle *> class_etris;
diff --git a/src/model/model.cc b/src/model/model.cc
index c7af2e3..cf03986 100644
--- a/src/model/model.cc
+++ b/src/model/model.cc
@@ -19,11 +19,15 @@ Model::Model(std::string const & name) :
{
model_first_vertex = 0;
model_first_evertex = 0;
+ model_first_lvertex = 0;
model_vertex_count = 0;
model_vertex_countdetail = 0;
model_evertex_count = 0;
model_evertex_countdetail = 0;
+ model_lvertex_count = 0;
+ model_lvertex_countdetail = 0;
+
model_radius = 0.5f;
}
@@ -45,12 +49,13 @@ Model::~Model()
size_t Model::tris() const
{
return ((model_vertex_count + model_vertex_countdetail +
- model_evertex_count + model_evertex_countdetail)/3);
+ model_evertex_count + model_evertex_countdetail +
+ model_lvertex_count + model_lvertex_countdetail)/3);
}
size_t Model::details() const
{
- return ((model_vertex_countdetail + model_evertex_countdetail)/3);
+ return ((model_vertex_countdetail + model_evertex_countdetail + model_lvertex_countdetail)/3);
}
void Model::add_engine(Engine *engine)
diff --git a/src/model/model.h b/src/model/model.h
index f13c466..ce288df 100644
--- a/src/model/model.h
+++ b/src/model/model.h
@@ -51,7 +51,7 @@ public:
/// number of detail vertices
inline size_t vertex_detail() const { return model_vertex_countdetail; }
- /// first vertex in the global VertexArray
+ /// first evertex in the global VertexArray
inline size_t first_evertex() const { return model_first_evertex; }
/// number of structural evertices in this model
@@ -60,6 +60,15 @@ public:
/// number of detail evertices in this model
inline size_t evertex_detail() const { return model_evertex_countdetail; }
+ /// first lvertex in the global VertexArray
+ inline size_t first_lvertex() const { return model_first_lvertex; }
+
+ /// number of structural lvertices in this model
+ inline size_t lvertex_structural() const { return model_lvertex_count; }
+
+ /// number of detail evertices in this model
+ inline size_t lvertex_detail() const { return model_lvertex_countdetail; }
+
/// total number of triangles in this model
size_t tris() const;
@@ -95,6 +104,10 @@ public:
size_t model_evertex_count;
size_t model_evertex_countdetail;
+ size_t model_first_lvertex;
+ size_t model_lvertex_count;
+ size_t model_lvertex_countdetail;
+
/* ---- static functions for the Model registry -------------------- */
/// the Model registry
diff --git a/src/model/plane.cc b/src/model/plane.cc
index 761918f..a637b75 100644
--- a/src/model/plane.cc
+++ b/src/model/plane.cc
@@ -20,6 +20,7 @@ using math::Vector3f;
Plane::Plane(Vector3f const & point0, Vector3f const &point1, Vector3f const &point2)
{
plane_detail = false;
+ plane_surface_flags = 0;
plane_point[0] = point0;
plane_point[1] = point1;
diff --git a/src/model/plane.h b/src/model/plane.h
index 5fdc99f..5a8e6b6 100644
--- a/src/model/plane.h
+++ b/src/model/plane.h
@@ -43,12 +43,15 @@ public:
inline float d() const { return pd; }
/// indidcates if this plane was generated from a detail brush
inline bool & detail() { return plane_detail; }
+ /// surface flags
+ inline unsigned int & surface_flags() { return plane_surface_flags; }
private:
math::Vector3f plane_point[3];
math::Vector3f plane_normal;
std::string plane_texture;
+ unsigned int plane_surface_flags;
bool plane_detail;
float pd;
};