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-09 18:40:31 +0000
committerStijn Buys <ingar@osirion.org>2008-03-09 18:40:31 +0000
commit517d35b2bbaeb3ee4b7e29301cd41bb58628bf3e (patch)
tree5473c128e64029b35ecfe22c9e48628c02af5407 /src/render/draw.cc
parent289bf4b622b95b794e438ac257d75ea437e3e023 (diff)
parse of light entities in models
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 3fed4dd..1d27631 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -63,6 +63,33 @@ void draw_model_engines(core::Model *model, core::EntityControlable *entity)
}
+void draw_model_lights(math::Vector3f const & eye, math::Vector3f const & target)
+{
+ 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);
+ }
+ }
+ }
+ }
+
+ gl::end();
+ glPointSize(1);
+}
+
void draw_entity_sphere(core::Entity *entity)
{
sphere.sphere_color = entity->color();
@@ -266,7 +293,7 @@ void draw_spacegrid(math::Vector3f const &target)
gl::end();
}
-void draw(math::Vector3f const &target, float seconds)
+void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds)
{
// used for animations
angle += 180.0f * seconds;
@@ -306,6 +333,22 @@ void draw(math::Vector3f const &target, float seconds)
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