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-05 17:45:30 +0000
committerStijn Buys <ingar@osirion.org>2008-05-05 17:45:30 +0000
commitc11c0174ece92b4502648ad33653975bfdfc39a0 (patch)
tree88860bfcbb7206834e61533af79f7631b5638cb2 /src/render
parent7218e3bd4616d4706090ec47d72845a2bb89c6a3 (diff)
lights with entity color, sunlight, network stats
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc69
1 files changed, 39 insertions, 30 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index c0e21cc..1017746 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -57,6 +57,10 @@ inline bool test_drawfx_distance(core::Entity *entity)
return ((entity->entity_renderstate & core::Entity::InCloseRange) == core::Entity::InCloseRange);
}
+// function to test flags
+inline bool flag_is_set(unsigned int spawnflags, unsigned int flag) {
+ return ((spawnflags & flag) == flag);
+}
/* ----- Default Entity shapes ------------------------------------- */
@@ -202,15 +206,6 @@ void draw_model_engines(core::EntityControlable *entity)
}
-void draw_model_radius(core::Entity *entity)
-{
-
- math::Color color = entity->color();
- color.a = 0.25f;
-
- draw_sphere(color, entity->model()->radius());
-}
-
void draw_model_shield(core::EntityControlable *entity)
{
// shield rotation
@@ -286,7 +281,16 @@ void pass_visibility()
// entities within drawdistance
entity->entity_renderstate = core::Entity::InRange;
}
- }
+
+ } else if ((entity->type() == core::Entity::Globe) && flag_is_set(entity->flags(), core::Entity::Bright)) {
+ // bright globes set level light
+ GLfloat light_position[4];
+ for (size_t i=0; i <3; i++)
+ light_position[i] = entity->location()[i];
+ light_position[3] = 1.0f;
+
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+ }
}
}
@@ -303,20 +307,21 @@ void draw_pass_default()
gl::translate(entity->location());
gl::multmatrix(entity->axis());
- if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright)
+ if (flag_is_set(entity->flags(), core::Entity::Bright)) {
gl::disable(GL_LIGHTING);
+ }
switch(entity->shape()) {
case core::Entity::Sphere:
draw_entity_sphere(entity);
break;
-
+
case core::Entity::Diamond:
-
+
case core::Entity::Axis:
draw_entity_axis(entity);
break;
-
+
case core::Entity::Cube:
default:
@@ -324,8 +329,10 @@ void draw_pass_default()
break;
}
- if ((entity->flags() & core::Entity::Bright) == core::Entity::Bright)
- gl::enable(GL_LIGHTING);
+ if (flag_is_set(entity->flags(), core::Entity::Bright)) {
+ gl::enable(GL_LIGHTING);
+ }
+
gl::pop();
}
}
@@ -370,8 +377,8 @@ void draw_pass_model_evertex()
}
}
-/* Draw model shields and engines */
-void draw_pass_model_fx() {
+/* Draw model shields */
+void draw_pass_model_shields() {
for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
@@ -385,7 +392,6 @@ void draw_pass_model_fx() {
gl::translate(entity->location());
gl::multmatrix(entity->axis());
-// draw_model_engines((core::EntityControlable *)entity);
draw_model_shield((core::EntityControlable *)entity);
gl::pop();
}
@@ -394,8 +400,8 @@ void draw_pass_model_fx() {
}
}
-/* draw model lights */
-void draw_pass_model_lights()
+/* draw model lights and engines */
+void draw_pass_model_fx()
{
float t;
@@ -429,7 +435,12 @@ void draw_pass_model_lights()
gl::begin(gl::Quads);
}
- math::Color color((*lit)->color());
+ math::Color color;
+ if ((*lit)->entity()) {
+ color.assign(entity->color());
+ } else {
+ color.assign((*lit)->color());
+ }
color.a = 0.8;
gl::color(color);
@@ -491,21 +502,20 @@ void draw_pass_model_lights()
gl::disable(GL_TEXTURE_2D);
}
-void draw_pass_model_radius()
+void draw_pass_model_corona()
{
if (!(r_radius && r_radius->value()))
return;
for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) {
-
core::Entity *entity = (*it).second;
if (test_draw_distance(entity)) {
gl::push();
gl::translate(entity->location());
-
- draw_model_radius(entity);
-
+ math::Color color = entity->color();
+ color.a = 0.25f;
+ draw_sphere(color, entity->model()->radius());
gl::pop();
}
}
@@ -603,13 +613,12 @@ void draw(math::Axis const &axis, math::Vector3f const &eye, math::Vector3f cons
draw_pass_spacegrid(); // draw the blue spacegrid
- draw_pass_model_fx(); // draw entity shield and engines
- draw_pass_model_lights(); // draw entity lights
+ draw_pass_model_fx(); // draw entity lights and engines
gl::enable(GL_LIGHTING);
gl::enable(GL_RESCALE_NORMAL);
- draw_pass_model_radius(); //draw entity radius
+ draw_pass_model_corona(); // draw entity radius and star corona
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);