diff options
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r-- | src/render/draw.cc | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 2752030..d440706 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -403,7 +403,6 @@ void pass_prepare(float seconds) Light *light = (*lit); // load light texture - // FIXME optimize std::stringstream flarename; flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << light->flare(); light->render_texture = Textures::load(flarename.str()); @@ -415,7 +414,6 @@ void pass_prepare(float seconds) if (!engine->flare()) engine->engine_flare = 1; // load engine texture - // FIXME optimize std::stringstream flarename; flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << engine->flare(); engine->render_texture = Textures::load(flarename.str()); @@ -425,7 +423,6 @@ void pass_prepare(float seconds) Flare *flare = (*flit); // load flare texture - // FIXME optimize std::stringstream flarename; flarename << "bitmaps/fx/flare" << std::setfill('0') << std::setw(2) << flare->flare(); flare->render_texture = Textures::load(flarename.str()); @@ -461,7 +458,8 @@ void pass_prepare(float seconds) entity->state()->state_visible = true; if (entity->type() == core::Entity::Globe) { - core::EntityGlobe *globe = (core::EntityGlobe *) entity; + + core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity); if (flag_is_set(globe->flags(), core::Entity::Bright)) { @@ -472,7 +470,7 @@ void pass_prepare(float seconds) GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; for (size_t i=0; i <3; i++) { - light_position[i] = globe->location()[i] - render::Camera::eye()[i]; + light_position[i] = globe->location()[i]; diffuse_light[i] = globe->color()[i] * 0.4; } light_position[3] = 1.0f; @@ -486,11 +484,12 @@ void pass_prepare(float seconds) } else { // load globe textures - // FIXME optimize - if (globe->texture().size()) { + if (!globe->render_texture && globe->texture().size()) { std::stringstream texname; texname << "textures/" << globe->texture(); globe->render_texture = Textures::load(texname.str()); + if (!globe->render_texture) + globe->entity_texture.clear(); } } } @@ -507,7 +506,7 @@ void draw_pass_default() // draw entities without model if (!entity->model()) { gl::push(); - gl::translate(entity->state()->location() - Camera::eye()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->state()->axis()); if (flag_is_set(entity->flags(), core::Entity::Bright)) { @@ -548,7 +547,7 @@ void draw_pass_default() gl::color(entity->color()); gl::push(); - gl::translate(entity->state()->location() - Camera::eye()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->state()->axis()); // top @@ -592,7 +591,7 @@ void draw_pass_model_fragments() if (entity->model() && entity->state()->visible()) { gl::push(); - gl::translate(entity->state()->location() - Camera::eye()); + gl::translate(entity->state()->location()); gl::multmatrix(entity->state()->axis()); draw_model_fragments(entity); @@ -645,7 +644,7 @@ void draw_pass_model_fx(float elapsed) if (light->strobe()) t = (core::application()->time() + entity->state()->fuzz() - light->offset()) * light->frequency(); if ((!light->strobe()) || (( t - floorf(t)) <= light->time())) { - location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * light->location())); + location.assign(entity->state()->location() + (entity->state()->axis() * light->location())); light_size = 0.0625 * light->radius(); if (current_texture != light->texture()) { @@ -688,7 +687,7 @@ void draw_pass_model_fx(float elapsed) if (flare->angle()) flare_axis.change_direction(flare->angle()); - location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * flare->location())); + location.assign(entity->state()->location() + (entity->state()->axis() * flare->location())); light_size = 0.0625 * flare->radius(); if (current_texture != flare->texture()) { @@ -740,7 +739,7 @@ void draw_pass_model_fx(float elapsed) for(model::Model::Engines::iterator eit = entity->model()->engines().begin(); eit != entity->model()->engines().end(); eit++) { engine = (*eit); - location.assign(entity->state()->location() - Camera::eye() + (entity->state()->axis() * engine->location())); + location.assign(entity->state()->location() + (entity->state()->axis() * engine->location())); engine_size = 0.0625 * engine->radius(); if (current_texture != engine->texture() ) { @@ -833,7 +832,7 @@ void draw_pass_model_corona() if (entity->model() && entity->state()->visible()) { gl::push(); - gl::translate(entity->state()->location() - Camera::eye()); + gl::translate(entity->state()->location()); math::Color color = entity->color(); color.a = 0.25f; draw_sphere(color, entity->model()->radius()); @@ -867,8 +866,8 @@ void draw_pass_sky() gl::enable(GL_TEXTURE_2D); gl::push(); - //gl::translate(Camera::eye()); - draw_sphere_inside(math::Color(), 128); + gl::translate(Camera::eye()); + draw_sphere_inside(math::Color(), 1016.0f); gl::pop(); gl::disable(GL_TEXTURE_2D); @@ -887,7 +886,7 @@ void draw_pass_spacegrid() float dy = Camera::target().y - floorf(Camera::target().y); gl::push(); - gl::translate(Camera::target() - Camera::eye()); + gl::translate(Camera::target()); gl::color(0,0, 1.0f); gl::normal(0, 0, 1.0f); |