Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/draw.cc')
-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);