diff options
author | Stijn Buys <ingar@osirion.org> | 2009-03-08 11:00:30 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-03-08 11:00:30 +0000 |
commit | e4618a1c7e5fb0629997d389cb941a61095490ac (patch) | |
tree | adbebcbd3ae487bc7642d374dfc3d9a343b111d5 | |
parent | 4c53365c16362156529c7669079e31845384589f (diff) |
changed camera settings for crash-view, map tweaks
-rw-r--r-- | src/client/map.cc | 82 | ||||
-rw-r--r-- | src/game/base/collision.cc | 1 | ||||
-rw-r--r-- | src/render/camera.cc | 13 | ||||
-rw-r--r-- | src/render/draw.cc | 16 |
4 files changed, 91 insertions, 21 deletions
diff --git a/src/client/map.cc b/src/client/map.cc index 35a1be7..6384588 100644 --- a/src/client/map.cc +++ b/src/client/map.cc @@ -9,9 +9,11 @@ #include "core/application.h" #include "client/map.h" #include "client/input.h" +#include "ui/ui.h" #include "ui/paint.h" #include "render/gl.h" #include "render/textures.h" +#include "render/text.h" namespace client { @@ -20,6 +22,7 @@ Map::Map(ui::Widget *parent) : ui::Window(parent) set_label("map"); set_border(true); set_background(true); + set_font(ui::root()->font_small()); map_target = 0; map_hover = 0; @@ -53,7 +56,12 @@ void Map::draw() const float blue = 0.8f; const float gridsize=16; + core::Entity *entity; + math::Color color; + math::Vector2f v(global_location()); + math::Vector2f l; + v.x += margin; v.y += margin; map_hover = 0; @@ -97,11 +105,13 @@ void Map::draw() gl::enable(GL_TEXTURE_2D); gl::begin(gl::Quads); + // draw map icons + bool valid_target = false; for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) { - core::Entity *entity = (*it); + entity = (*it); bool draw_icon = false; - math::Vector2f l(v); + l.assign(v); if (entity->flag_is_set(core::Entity::ShowOnMap)) { draw_icon = true; @@ -113,6 +123,7 @@ void Map::draw() } if (entity == map_target) { + valid_target = true; if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { draw_icon = false; } @@ -120,13 +131,7 @@ void Map::draw() } if (entity == core::localcontrol()) { - draw_icon = true; - l.x -= s / scale * entity->location().y; - l.y -= s / scale * entity->location().x; - - if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { - draw_icon = false; - } + draw_icon = false; } if (draw_icon) { @@ -152,8 +157,7 @@ void Map::draw() } } - - math::Color color(entity->color()); + color.assign(entity->color()); color.a = 1.0f; gl::color(color); glTexCoord2f(0.0f, 0.0f); @@ -170,7 +174,63 @@ void Map::draw() } } + + // draw localcontrol icon + entity = core::localcontrol(); + l.assign(v); + l.x -= s / scale * entity->location().y; + l.y -= s / scale * entity->location().x; + if (core::application()->time() - floorf(core::application()->time()) < 0.5f) { + if (texture_current != texture_entity) { + gl::end(); + texture_current = render::Textures::bind(texture_entity); + gl::begin(gl::Quads); + } + + math::Color color(entity->color()); + color.a = 1.0f; + gl::color(color); + glTexCoord2f(0.0f, 0.0f); + gl::vertex(l.x-r, l.y-r); + + glTexCoord2f(1.0f, 0.0f); + gl::vertex(l.x+r, l.y-r); + + glTexCoord2f(1.0f, 1.0f); + gl::vertex(l.x+r, l.y+r); + + glTexCoord2f(0.0f, 1.0f); + gl::vertex(l.x-r, l.y+r); + } + gl::end(); + + + if (!valid_target) { + map_target = 0; + } else { + l.assign(v); + + if (h > s ) { + // target information below + l.x -= s * 0.5f; + l.y += s * 0.5f; + + l.y += margin; + } else { + // target information right + l.x += s * 0.5f; + l.y -= s * 0.5f; + + l.x += margin; + } + + render::Text::setcolor('B'); + render::Text::setfont(font()->name().c_str(), font()->width(), font()->height()); + render::Text::draw(l.x, l.y, map_target->name()); + render::Text::setcolor('N'); + } + gl::disable(GL_TEXTURE_2D); } diff --git a/src/game/base/collision.cc b/src/game/base/collision.cc index 3da65d1..728ad14 100644 --- a/src/game/base/collision.cc +++ b/src/game/base/collision.cc @@ -32,6 +32,7 @@ void Collision::distance_test(core::EntityControlable *first, core::Entity *seco if ((first->moduletype() == ship_enttype) && (first->state() != core::Entity::Destroyed)) { first->owner()->send_warning("^RBOOM!^N"); static_cast<Ship *>(first)->explode(); + first->entity_speed = 0; } } else if (first->owner()->last_warning() + 5.0f < core::application()->time()) { // warning zone: star corona or planet atmosphere diff --git a/src/render/camera.cc b/src/render/camera.cc index 91a7095..ba056d0 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -230,10 +230,17 @@ void Camera::frame(float seconds) if (core::localplayer()->view()) { // player view entity - distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 3.0f; + camera_axis.assign(core::localplayer()->view()->axis()); - camera_axis.change_direction(180.0f); - camera_target.assign(core::localplayer()->view()->location() - core::localplayer()->view()->axis().left()* (math::max(core::localplayer()->view()->radius(), 1.0f)*0.5f) ); + if (core::localplayer()->view() == core::localcontrol()) { + camera_axis.change_pitch(pitch_free); + camera_target.assign(core::localplayer()->view()->location()); + distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 2.0f; + } else { + distance = math::max(core::localplayer()->view()->radius(), 1.0f) * 3.0f; + camera_axis.change_direction(180.0f); + camera_target.assign(core::localplayer()->view()->location() - core::localplayer()->view()->axis().left()* (math::max(core::localplayer()->view()->radius(), 1.0f)*0.5f) ); + } /* } else if (core::localplayer()->zone()->default_view()) { diff --git a/src/render/draw.cc b/src/render/draw.cc index a56e1dc..6629ca9 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -556,7 +556,9 @@ void draw_model_fragments(core::Entity *entity) if ((entity->type() == core::Entity::Dynamic) || (entity->type() == core::Entity::Controlable)) { - if (static_cast<core::EntityDynamic *>(entity)->state() == core::Entity::NoPower) { + int state = static_cast<core::EntityDynamic *>(entity)->state(); + + if ((state == core::Entity::NoPower) || (state == core::Entity::Destroyed)) { power = false; } else if (entity->type() == core::Entity::Controlable) { @@ -760,12 +762,12 @@ void draw_pass_model_fx(float elapsed) power = true; - if ((entity->type() == core::Entity::Dynamic) && - (static_cast<core::EntityDynamic *>(entity)->state() == core::Entity::NoPower)) { - power = false; - } else if ((entity->type() == core::Entity::Controlable) && - (static_cast<core::EntityControlable *>(entity)->state() == core::Entity::NoPower)) { - power = false; + if ((entity->type() == core::Entity::Controlable) || (entity->type() == core::Entity::Dynamic)) { + int state = static_cast<core::EntityDynamic *>(entity)->state(); + + if ((state == core::Entity::NoPower) || (state == core::Entity::Destroyed)) { + power = false; + } } if (entity->model() && ext_render(entity)->detailvisible() && power) { |