diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 12:06:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 12:06:13 +0000 |
commit | d8be908233fd7b85492d7a9e87f07bb207173990 (patch) | |
tree | 70d9103a867688838fc517290bb370366c69fedb /src/render/draw.cc | |
parent | edc5ddce817244111b302e449c28a052f2746cc4 (diff) |
Moved core::EntityGlobe into a separate file,
added various methods to core::Item and core::Slot,
added r_slots cvar to draw entity slots and docks,
added game methods for mounting and umounting of weapons,
added playerlist to chat window.
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r-- | src/render/draw.cc | 135 |
1 files changed, 93 insertions, 42 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 12a64ad..dea0c6b 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -8,6 +8,8 @@ #include <iomanip> #include "core/application.h" +#include "core/entity.h" +#include "core/entityglobe.h" #include "core/gameinterface.h" #include "core/range.h" @@ -727,7 +729,9 @@ void draw_model_axis(const core::Entity *entity) void draw_pass_model_fragments() { /* - * FIXME + * FIXME + * fragmentgroups with movement tied to engine activity can not be synchronized with server-side collision + * * For moving and rotating fragmentgroups, the enginetime must match * the time used by core:: to calculate the rotation or movement * of the asssociated collision models. @@ -756,8 +760,9 @@ void draw_pass_model_fragments() ext_render(entity)->thrust() ); - if (entity->slots()) + if (r_slots && r_slots->value()) { draw_slots(entity); + } if (r_bbox->value()) { gl::color(entity->color()); @@ -979,7 +984,6 @@ void draw_pass_model_fx(float elapsed) ); } - // draw particle systems if (draw_particles && ext_render(entity)->particles().size()) { gl::disable(GL_CULL_FACE); @@ -1227,60 +1231,106 @@ void draw(float seconds) globes_list.clear(); } -// draw weapon slots -// weapons are drawn in model space coordinate, model transformations +// draw model slots: weapon slots and docking ports void draw_slots(const core::Entity *entity) { - assert(entity->slots() && entity->model()); - - gl::disable(GL_DEPTH_TEST); + if (!entity->model()) { + return; + } + gl::disable(GL_DEPTH_TEST); //const float modelscale = entity->radius() / entity->model()->radius(); + + // draw docks + if (entity->model()->docks().size()) { + gl::color(0, 1.0f, 1.0f, 1.0f); + + for (model::Model::Docks::iterator dit = entity->model()->docks().begin(); dit != entity->model()->docks().end(); dit++) { + model::Dock *dock = (*dit); + math::Vector3f maxbox(dock->location()); + math::Vector3f minbox(dock->location()); + + for (size_t i = 0; i < 3; i++) { + maxbox[i] += 0.025; + minbox[i] -= 0.025; + } - gl::color(1.0f, 0.0f, 0.0f, 1.0f); + // top + gl::begin(gl::LineLoop); + gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), minbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); + gl::end(); - for(core::Slots::iterator it = entity->slots()->begin(); it != entity->slots()->end(); ++it) { - core::Slot *slot = (*it); - - math::Vector3f maxbox(slot->location()); - math::Vector3f minbox(slot->location()); + // bottom + gl::begin(gl::LineLoop); + gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), minbox.y(), minbox.z()); + gl::vertex(maxbox.x(), minbox.y(), minbox.z()); + gl::end(); - for (size_t i = 0; i < 3; i++) { - maxbox[i] += 0.025; - minbox[i] -= 0.025; + gl::begin(gl::Lines); + gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), minbox.y(), maxbox.z()); + gl::vertex(minbox.x(), minbox.y(), minbox.z()); + gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), minbox.y(), minbox.z()); + gl::end(); } + } + + // draw weapon slots + if (entity->slots()) { + gl::color(1.0f, 0.0f, 0.0f); + + for(core::Slots::iterator it = entity->slots()->begin(); it != entity->slots()->end(); ++it) { + core::Slot *slot = (*it); + + math::Vector3f maxbox(slot->location()); + math::Vector3f minbox(slot->location()); - // top - gl::begin(gl::LineLoop); - gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); - gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); - gl::vertex(minbox.x(), minbox.y(), maxbox.z()); - gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); - gl::end(); + for (size_t i = 0; i < 3; i++) { + maxbox[i] += 0.025; + minbox[i] -= 0.025; + } - // bottom - gl::begin(gl::LineLoop); - gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); - gl::vertex(minbox.x(), maxbox.y(), minbox.z()); - gl::vertex(minbox.x(), minbox.y(), minbox.z()); - gl::vertex(maxbox.x(), minbox.y(), minbox.z()); - gl::end(); + // top + gl::begin(gl::LineLoop); + gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), minbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); + gl::end(); - gl::begin(gl::Lines); - gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); - gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); - gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); - gl::vertex(minbox.x(), maxbox.y(), minbox.z()); - gl::vertex(minbox.x(), minbox.y(), maxbox.z()); - gl::vertex(minbox.x(), minbox.y(), minbox.z()); - gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); - gl::vertex(maxbox.x(), minbox.y(), minbox.z()); - gl::end(); + // bottom + gl::begin(gl::LineLoop); + gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), minbox.y(), minbox.z()); + gl::vertex(maxbox.x(), minbox.y(), minbox.z()); + gl::end(); + + gl::begin(gl::Lines); + gl::vertex(maxbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), maxbox.y(), maxbox.z()); + gl::vertex(minbox.x(), maxbox.y(), minbox.z()); + gl::vertex(minbox.x(), minbox.y(), maxbox.z()); + gl::vertex(minbox.x(), minbox.y(), minbox.z()); + gl::vertex(maxbox.x(), minbox.y(), maxbox.z()); + gl::vertex(maxbox.x(), minbox.y(), minbox.z()); + gl::end(); + } } gl::enable(GL_DEPTH_TEST); } - +/* // draw HUD target world space geometry, like dock indicators void draw_target(const core::Entity *entity) { @@ -1344,5 +1394,6 @@ void draw_target(const core::Entity *entity) gl::pop(); gl::disable(GL_DEPTH_TEST); } +*/ } |