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-16 22:36:04 +0000
committerStijn Buys <ingar@osirion.org>2008-03-16 22:36:04 +0000
commitcb52e5bd8da01ab2e7976fcd8bfc34e190265ed5 (patch)
tree3645b53d64ca6e6068537c18efc5c9bab7673e5b /src/render
parent7d7b9324f1f0db14648fb9fe32256d7942af77b9 (diff)
r_drawradius
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc90
-rw-r--r--src/render/render.cc4
-rw-r--r--src/render/render.h3
3 files changed, 48 insertions, 49 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 1d27631..9e1e5ea 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -6,13 +6,14 @@
#include "core/core.h"
#include "core/model.h"
+#include "render/render.h"
#include "render/draw.h"
#include "render/sphere.h"
namespace render
{
-render::Sphere sphere(1);
+Sphere sphere(1);
math::Vector3f v0(1, -1, 1);
math::Vector3f v1(1, 1, 1);
@@ -24,6 +25,8 @@ math::Vector3f v5(1, 1, -1);
math::Vector3f v6(-1, 1, -1);
math::Vector3f v7(-1, -1, -1);
+const float drawdistance = 128.0f;
+math::Vector3f camera_target;
float angle = 0;
void draw_model(core::Model *model, core::Entity *entity)
@@ -45,6 +48,15 @@ void draw_model(core::Model *model, core::Entity *entity)
}
gl::end();
}
+
+ if (r_drawradius && r_drawradius->value()) {
+ sphere.sphere_color = entity->color();
+ sphere.sphere_color.a = 0.25f;
+ sphere.radius = model->radius();
+ gl::enable(GL_BLEND); // enable alpha blending again
+ sphere.draw();
+ gl::disable(GL_BLEND);
+ }
}
void draw_model_engines(core::Model *model, core::EntityControlable *entity)
@@ -63,31 +75,23 @@ void draw_model_engines(core::Model *model, core::EntityControlable *entity)
}
-void draw_model_lights(math::Vector3f const & eye, math::Vector3f const & target)
+void draw_model_lights(core::Model *model, core::Entity *entity)
{
- glPointSize(10);
- gl::begin(gl::Points);
-
- std::map<unsigned int, core::Entity *>::iterator it;
- for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
- core::Model *model = 0;
- if ((*it).second->modelname().size())
- model = core::Model::get((*it).second->modelname());
-
- if (model) {
- for (std::list<core::Light *>::iterator lit = model->model_light.begin(); lit != model->model_light.end(); lit++) {
- math::Vector3f location = (*it).second->location() + (*lit)->location();
- math::Vector3f d = location-eye;
- if ((d.lengthsquared() < 16*16) && (dotproduct(d, eye-target) < 0)) {
- gl::color((*lit)->color());
- gl::vertex(location);
- }
- }
+ if (model->model_light.size()) {
+ gl::disable(GL_LIGHTING);
+ glPointSize(10);
+ gl::begin(gl::Points);
+
+ for (std::list<core::Light *>::iterator lit = model->model_light.begin(); lit != model->model_light.end(); lit++) {
+ math::Vector3f location = (*lit)->location();
+ gl::color((*lit)->color());
+ gl::vertex(location);
}
+
+ gl::end();
+ glPointSize(1);
+ gl::enable(GL_LIGHTING);
}
-
- gl::end();
- glPointSize(1);
}
void draw_entity_sphere(core::Entity *entity)
@@ -173,8 +177,13 @@ void draw_entity_default(core::Entity *entity)
using namespace render;
core::Model *model = 0;
- if (entity->modelname().size())
+ if (entity->modelname().size()) {
model = core::Model::get(entity->modelname());
+ }
+
+ if (model && math::distancesquared(camera_target, entity->location()) > drawdistance*drawdistance*model->radius())
+ return;
+
gl::push();
gl::translate(entity->location());
@@ -182,9 +191,10 @@ void draw_entity_default(core::Entity *entity)
if (model) {
draw_model(model, entity);
+ //draw_model_lights(model, entity);
} else {
- //gl::disable(GL_LIGHTING);
- //gl::disable(GL_LIGHT0);
+ if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright)
+ gl::disable(GL_LIGHTING);
switch(entity->shape()) {
case core::Entity::Sphere:
@@ -204,8 +214,8 @@ void draw_entity_default(core::Entity *entity)
break;
}
- //gl::enable(GL_LIGHTING);
- //gl::enable(GL_LIGHT0); // disable camera light
+ if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright)
+ gl::enable(GL_LIGHTING);
}
gl::pop();
@@ -222,9 +232,10 @@ void draw_entity_controlable(core::EntityControlable *entity)
gl::translate(entity->location());
gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
- if (model) {
+ if (model ) {
draw_model(model, entity);
draw_model_engines(model, entity);
+ //draw_model_lights(model, entity);
}
// shield rotation
@@ -301,6 +312,8 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
angle -= 360.0f;
}
+ camera_target = target;
+
// draw entities
using namespace render;
@@ -308,7 +321,6 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
gl::enable(GL_CULL_FACE); // enable culling
gl::enable(GL_COLOR_MATERIAL); // enable color tracking
gl::enable(GL_LIGHTING);
- gl::enable(GL_LIGHT0);
gl::disable(GL_BLEND); // disbable alpha blending for world polys
@@ -326,29 +338,11 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds
}
}
- gl::disable(GL_LIGHT0); // disable camera light
gl::disable(GL_LIGHTING);
gl::disable(GL_COLOR_MATERIAL); // disable color tracking
gl::disable(GL_CULL_FACE); // disable culling
-
gl::enable(GL_BLEND); // enable alpha blending again
- /*
- // DEBUG target lines
- gl::push();
- gl::color(0,1, 0, .7);
- //gl::translate(target*-1);
- gl::begin(gl::Lines);
- for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
- gl::vertex(eye);
- gl::vertex((*it).second->location());
- }
- gl::end();
- gl::pop();
-
- draw_model_lights(eye, target); // second pass - draw lights
- */
-
draw_spacegrid(target); // draw the blue spacegrid
gl::disable(GL_DEPTH_TEST); // disable depth buffer writing
diff --git a/src/render/render.cc b/src/render/render.cc
index 76f2373..b5afdf0 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -13,6 +13,8 @@ namespace render {
GLuint textures[32];
+core::Cvar *r_drawradius = 0;
+
void init()
{
con_print << "Initializing renderer..." << std::endl;
@@ -32,7 +34,7 @@ void init()
core::application()->shutdown();
}
-
+ r_drawradius = core::Cvar::get("r_drawradius", "0", core::Cvar::Archive);
}
void shutdown()
diff --git a/src/render/render.h b/src/render/render.h
index c27b740..7d26a3d 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -8,6 +8,7 @@
#define __INCLUDED_RENDER_H__
#include "GL/gl.h"
+#include "core/cvar.h"
namespace render {
@@ -21,6 +22,8 @@ namespace render {
void draw(float elapsed);
extern GLuint textures[32];
+
+ extern core::Cvar *r_drawradius;
}
#include "render/draw.h"