Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-24 15:38:07 +0000
committerStijn Buys <ingar@osirion.org>2008-05-24 15:38:07 +0000
commit00464c237fbd3a01137099dedf23dc44569472fd (patch)
treecc6ccf2bc4f8279b240ae20d4d26c4572029e083 /src
parent8017d60e4906a27c1dc82933593c3d5fd1c0bed4 (diff)
surface flags: light
Diffstat (limited to 'src')
-rw-r--r--src/client/view.cc16
-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
-rw-r--r--src/render/draw.cc18
9 files changed, 94 insertions, 10 deletions
diff --git a/src/client/view.cc b/src/client/view.cc
index e7cb5cc..174e1ed 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -28,6 +28,7 @@
namespace client
{
+core::Cvar *draw_ui = 0;
core::Cvar *draw_stats = 0;
core::Cvar *cl_crosshaircolor = 0;
@@ -43,6 +44,9 @@ void init()
draw_stats = core::Cvar::get("draw_stats", "0", core::Cvar::Archive);
draw_stats->set_info("[bool] draw network and render statistics");
+ draw_ui = core::Cvar::get("draw_ui", "1", core::Cvar::Archive);
+ draw_ui->set_info("[bool] draw the user interface");
+
cl_crosshaircolor = core::Cvar::get("cl_crosshaircolor", "1 1 1", core::Cvar::Archive);
cl_crosshaircolor->set_info("[r g b] crosshairs color");
}
@@ -272,12 +276,14 @@ void frame(float seconds)
Text::setfont("bitmaps/fonts/console", 12, 18);
console()->draw();
chat::draw();
+
+ if (draw_ui->value()) {
+ Text::setfont("bitmaps/fonts/gui", 16, 24);
+ draw_status();
- Text::setfont("bitmaps/fonts/gui", 16, 24);
- draw_status();
-
- // draw the mouse cursor
- draw_cursor();
+ // draw the mouse cursor
+ draw_cursor();
+ }
gl::disable(GL_TEXTURE_2D);
}
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;
};
diff --git a/src/render/draw.cc b/src/render/draw.cc
index dadd0fa..4295330 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -166,6 +166,22 @@ void draw_model_vertex(core::Entity *entity)
}
}
+void draw_model_lvertex(core::Entity *entity)
+{
+ size_t count = entity->model()->lvertex_structural();
+ if (entity->state()->detailvisible())
+ count += entity->model()->lvertex_detail();
+
+ // draw model lvertices
+ if (count) {
+ gl::disable(GL_LIGHTING);
+ size_t index = entity->model()->first_lvertex();
+ glDrawArrays(gl::Triangles, index, count);
+ Stats::tris += count/3;
+ gl::enable(GL_LIGHTING);
+ }
+}
+
void draw_model_evertex(core::Entity *entity)
{
size_t count = entity->model()->evertex_structural();
@@ -180,6 +196,7 @@ void draw_model_evertex(core::Entity *entity)
Stats::tris += count/3;
}
}
+
/*
void draw_model_engines(core::EntityControlable *entity)
{
@@ -412,6 +429,7 @@ void draw_pass_model_vertex()
gl::multmatrix(entity->state()->axis());
draw_model_vertex(entity);
+ draw_model_lvertex(entity);
gl::pop();
}