diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 78 |
1 files changed, 53 insertions, 25 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 3e3a13e..26b1109 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -8,6 +8,7 @@ #include <iomanip> #include "core/core.h" +#include "core/range.h" #include "model/fragment.h" #include "model/material.h" #include "model/model.h" @@ -39,7 +40,7 @@ math::Vector3f v5(1, 1, -1); math::Vector3f v6(-1, 1, -1); math::Vector3f v7(-1, -1, -1); -const float drawdistance = 128.0f; +const float drawdistance = 256.0f; const float drawfxdistance = 64.0f; const float farplane = 1016.0f; @@ -133,7 +134,7 @@ void pass_prepare(float seconds) // entites within detail range entity->state()->state_visible = true; entity->state()->state_detailvisible = true; - } else if (entity->state()->distance() < drawdistance * r) { + } else if (entity->state()->distance() < drawdistance * r && entity->state()->distance() < core::range::max) { // entities within drawing distance, outside detail range entity->state()->state_visible = true; entity->state()->state_detailvisible = false; @@ -297,7 +298,13 @@ void draw_globe(core::EntityGlobe *globe) gl::translate(location); gl::multmatrix(globe->state()->axis()); + if (globe->rotationspeed()) { + float angle = core::application()->time() * globe->rotationspeed(); + angle = angle - 360.0f * floorf(angle / 360.0f); + gl::rotate(angle, math::Vector3f::Zaxis()); + } draw_sphere(globe->color(), radius); + gl::pop(); if (globe->state()->distance() > farplane) { @@ -391,6 +398,38 @@ void draw_entity_diamond(core::Entity *entity) { float radius = entity->radius()/2; + /* ---- draw axis lines ---- */ + gl::color(entity->color_second()); + gl::begin(gl::Lines); + + gl::vertex(1.25f * radius, 0, 0); + gl::vertex(2* radius, 0, 0); + + gl::vertex(0, 1.25f * radius, 0); + gl::vertex(0, 2* radius, 0); + + gl::vertex(0, 0, 1.25f * radius); + gl::vertex(0, 0, 2 * radius); + + gl::vertex(-1.25f * radius, 0, 0); + gl::vertex(-2 * radius, 0, 0); + + gl::vertex(0, -1.25f * radius, 0); + gl::vertex(0, -2 * radius, 0); + + gl::vertex(0, 0, -1.25f * radius); + gl::vertex(0, 0, -2 * radius); + + gl::end(); + + /* ---- draw rotating body lines ---- */ + float angle = (core::application()->time() + entity->state()->fuzz() ) * 45.0f; + angle = angle - 360.0f * floorf(angle / 360.0f); + gl::rotate(angle, math::Vector3f::Zaxis()); + + if (r_wireframe->value() == 0.0f) { + glPolygonMode(GL_FRONT, GL_LINE); + } gl::color(entity->color()); gl::begin(gl::TriangleFan ); @@ -430,28 +469,9 @@ void draw_entity_diamond(core::Entity *entity) gl::vertex(radius, 0.0f, 0.0f); gl::end(); - - gl::begin(gl::Lines); - - gl::vertex(radius, 0, 0); - gl::vertex(2* radius, 0, 0); - - gl::vertex(0, radius, 0); - gl::vertex(0, 2* radius, 0); - - gl::vertex(0, 0, radius); - gl::vertex(0, 0, 2 * radius); - - gl::vertex(-radius, 0, 0); - gl::vertex(-2 * radius, 0, 0); - - gl::vertex(0, -radius, 0); - gl::vertex(0, -2 * radius, 0); - - gl::vertex(0, 0, -radius); - gl::vertex(0, 0, -2 * radius); - - gl::end(); + if (r_wireframe->value() == 0.0f) { + glPolygonMode(GL_FRONT, GL_FILL); + } } void draw_entity_axis(core::Entity *entity) @@ -459,7 +479,7 @@ void draw_entity_axis(core::Entity *entity) float r = entity->radius(); gl::begin(gl::Lines); - gl::color(1.0f, 0.0f, 0.0f); + gl::color(entity->color_second()); gl::vertex(r,0.0f,0.0f); gl::color(entity->color()); gl::vertex(-r,0.0f,0.0f); @@ -483,6 +503,10 @@ void draw_pass_default() gl::translate(entity->state()->location()); gl::multmatrix(entity->state()->axis()); + if (flag_is_set(entity->flags(), core::Entity::Bright)) { + gl::disable(GL_LIGHTING); + } + switch(entity->shape()) { case core::Entity::Sphere: draw_entity_sphere(entity); @@ -503,6 +527,10 @@ void draw_pass_default() break; } + if (flag_is_set(entity->flags(), core::Entity::Bright)) { + gl::enable(GL_LIGHTING); + } + gl::pop(); } } |