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-05-24 10:10:37 +0000
committerStijn Buys <ingar@osirion.org>2008-05-24 10:10:37 +0000
commita010f94390422eefa366a5f390c1f9e3ccc66fd5 (patch)
tree798f63addb6931fb08208927afff509185709c7c /src/render
parent4a4a5473b82d1f5b6f654cabac99272bce89854b (diff)
text_length functions, improved lighting, r_bbox draws bounding boxes
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc58
-rw-r--r--src/render/render.cc7
-rw-r--r--src/render/render.h1
3 files changed, 62 insertions, 4 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 9292460..8db77c1 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -235,6 +235,9 @@ void draw_model_shield(core::EntityControlable *entity)
/* calculate entity visibility */
void pass_prepare(float seconds)
{
+ // reset light state
+ gl::disable(GL_LIGHT1);
+
std::map<unsigned int, core::Entity *>::iterator it;
for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
@@ -286,11 +289,22 @@ void pass_prepare(float seconds)
// bright globes set level light
GLfloat light_position[4];
- for (size_t i=0; i <3; i++)
+ GLfloat diffuse_light[4];
+ GLfloat ambient_light[] = { 0.0f, 0.0f, 0.0f, 1.0f };
+ GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };
+
+ for (size_t i=0; i <3; i++) {
light_position[i] = entity->location()[i];
+ diffuse_light[i] = entity->color()[i] * 0.4;
+ }
light_position[3] = 1.0f;
-
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+ diffuse_light[3] = 1.0f;
+
+ glLightfv(GL_LIGHT1, GL_POSITION, light_position);
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse_light);
+ glLightfv(GL_LIGHT1, GL_SPECULAR, specular_light);
+ gl::enable(GL_LIGHT1);
}
}
@@ -337,6 +351,44 @@ void draw_pass_default()
}
gl::pop();
+ } else if (r_bbox->value()) {
+ // draw bounding box if requested
+ model::Model *model = entity->model();
+ gl::color(entity->color());
+
+ gl::push();
+ gl::translate(entity->state()->location());
+ gl::multmatrix(entity->state()->axis());
+
+ // top
+ gl::begin(gl::LineLoop);
+ gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
+ gl::end();
+
+ // bottom
+ gl::begin(gl::LineLoop);
+ gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::end();
+
+ gl::begin(gl::Lines);
+ gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_maxbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_maxbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_minbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_maxbbox.z);
+ gl::vertex(model->model_maxbbox.x, model->model_minbbox.y, model->model_minbbox.z);
+ gl::end();
+
+ gl::pop();
+
}
}
}
diff --git a/src/render/render.cc b/src/render/render.cc
index e602673..87ff64a 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -13,6 +13,7 @@
#include "render/textures.h"
#include "render/tga.h"
#include "render/render.h"
+#include "model/model.h"
#include "core/core.h"
#include "filesystem/filesystem.h"
@@ -24,7 +25,8 @@ GLuint textures[32];
core::Cvar *r_radius = 0;
core::Cvar *r_wireframe = 0;
-core::Cvar * r_arraysize = 0;
+core::Cvar *r_arraysize = 0;
+core::Cvar *r_bbox = 0;
using model::VertexArray;
@@ -80,6 +82,9 @@ void init()
r_wireframe = core::Cvar::get("r_wireframe", "0", core::Cvar::Archive);
r_wireframe->set_info("[bool] render wireframe");
+ r_bbox = core::Cvar::get("r_bbox", "0", core::Cvar::Archive);
+ r_bbox->set_info("[bool] render model bounding box");
+
Textures::init();
Text::init();
diff --git a/src/render/render.h b/src/render/render.h
index d1f79a7..68952f1 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -23,6 +23,7 @@ namespace render {
/// shutdown the render subsystem
void shutdown();
+ extern core::Cvar *r_bbox;
extern core::Cvar *r_radius;
extern core::Cvar *r_wireframe;
extern core::Cvar *r_arraysize;