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>2014-12-07 16:12:49 +0000
committerStijn Buys <ingar@osirion.org>2014-12-07 16:12:49 +0000
commit2c98d3eef488233b99a76ca44d69c1c9d53404af (patch)
tree9259bad9533d1de7381b291eee19fd319b8366eb /src/render
parentacb236d0df275394095ab43e8519aebc4811865d (diff)
Cleanup of the slots code, unified model weapon and dock tags into a single slots list,
load dock tags into entity slots, represent entity slot locations in entity coordinate space, have r_slots render fixed-size slot indicators regardless of model scale.
Diffstat (limited to 'src/render')
-rw-r--r--src/render/draw.cc106
1 files changed, 52 insertions, 54 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 2428735..47fcb40 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -824,10 +824,6 @@ void draw_pass_model_fragments()
ext_render(entity)->power(),
ext_render(entity)->thrust()
);
-
- if (r_slots && r_slots->value()) {
- draw_slots(entity);
- }
if (r_bbox->value()) {
gl::disable(GL_DEPTH_TEST);
@@ -847,8 +843,18 @@ void draw_pass_model_fragments()
draw_inidicators(static_cast<const core::EntityControlable *>(entity));
}
+ if (entity->slots() && r_slots && r_slots->value()) {
+ gl::pop();
+
+ gl::push();
+ gl::translate(entity->location());
+ gl::multmatrix(entity->axis());
+
+ // not scaled through modelscale
+ draw_slots(entity);
+ }
gl::pop();
- }
+ }
}
}
@@ -1393,80 +1399,72 @@ void draw_inidicators(const core::EntityControlable *entity)
void draw_slots(const core::Entity *entity)
{
- if (!entity->model()) {
- return;
- }
-
- if (entity->model()->docks().size()) {
+ if (entity->slots())
+ {
+ const float r = 0.025f;
- // draw docks: pass 1 - background with GL_DEPTH_TEST disabled
+ // draw slots: pass 1 - background with GL_DEPTH_TEST disabled
gl::disable(GL_DEPTH_TEST);
- gl::color(0.0f, 0.5f, 0.5f, 0.25f);
-
- 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;
- }
-
- draw_box(minbox, maxbox);
- }
-
- // draw docks: pass 2 - highlight with GL_DEPTH_TEST enabled
- gl::enable(GL_DEPTH_TEST);
- gl::color(0.0f, 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;
- }
-
- draw_box(minbox, maxbox);
- }
- }
-
- if (entity->slots()) {
-
- // draw weapon slots: pass 1 - background with GL_DEPTH_TEST disabled
- gl::disable(GL_DEPTH_TEST);
- gl::color(0.5f, 0.0f, 0.0f, 0.25f);
for(core::Slots::iterator it = entity->slots()->begin(); it != entity->slots()->end(); ++it) {
core::Slot *slot = (*it);
+ switch (slot->type()) {
+ case model::Slot::Cannon:
+ case model::Slot::Turret:
+ // red for weapons
+ gl::color(0.5f, 0.0f, 0.0f, 0.25f);
+ break;
+ case model::Slot::Dock:
+ // cyan for docks
+ gl::color(0.0f, 0.5f, 0.5f, 0.25f);
+ break;
+ case model::Slot::None:
+ // gray for unkown
+ gl::color(0.25f, 0.25f, 0.25f, 0.25f);
+ break;
+ }
+
math::Vector3f maxbox(slot->location());
math::Vector3f minbox(slot->location());
for (size_t i = 0; i < 3; i++) {
- maxbox[i] += 0.025;
- minbox[i] -= 0.025;
+ maxbox[i] += r;
+ minbox[i] -= r;
}
draw_box(minbox, maxbox);
}
- // draw weapon slots: pass 2 - highlight with GL_DEPTH_TEST enabled
+ // draw slots: pass 2 - highlight with GL_DEPTH_TEST enabled
gl::enable(GL_DEPTH_TEST);
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);
+ switch (slot->type()) {
+ case model::Slot::Cannon:
+ case model::Slot::Turret:
+ // red for weapons
+ gl::color(1.0f, 0.0f, 0.0f, 1.0f);
+ break;
+ case model::Slot::Dock:
+ // cyan for docks
+ gl::color(0.0f, 1.0f, 1.0f, 1.0f);
+ break;
+ case model::Slot::None:
+ // gray for unkown
+ gl::color(0.5f, 0.5f, 0.5f, 1.0f);
+ break;
+ }
+
math::Vector3f maxbox(slot->location());
math::Vector3f minbox(slot->location());
for (size_t i = 0; i < 3; i++) {
- maxbox[i] += 0.025;
- minbox[i] -= 0.025;
+ maxbox[i] += r;
+ minbox[i] -= r;
}
draw_box(minbox, maxbox);