Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render/draw.cc87
-rw-r--r--src/render/draw.h3
-rw-r--r--src/render/render.cc4
-rw-r--r--src/render/render.h2
4 files changed, 90 insertions, 6 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index af9ec27..2428735 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -843,11 +843,15 @@ void draw_pass_model_fragments()
draw_model_axis(entity);
}
+ if ((ext_render(entity)->detailvisible()) && (entity->type() == core::Entity::Controlable) && (r_indicators->value())) {
+ draw_inidicators(static_cast<const core::EntityControlable *>(entity));
+ }
+
gl::pop();
- }
+ }
}
}
-
+
/* ---- Model FX --------------------------------------------------- */
void draw_model_lights(model::Model *model, const float scale,
@@ -1315,7 +1319,78 @@ void draw(float seconds)
globes_list.clear();
}
-// draw model slots: weapon slots and docking ports
+
+/* ---- Model 3D Direction indicators ------------------------------ */
+
+void draw_inidicators(const core::EntityControlable *entity)
+{
+ if (entity->thrust() == 0.0f) {
+ return;
+ }
+
+ math::Color color_reputation(0.0f, 1.0f, 0.0f);
+ if (entity != core::localcontrol()) {
+ // reputation color
+ const float reputation = core::localplayer()->reputation(entity->faction());
+ if (reputation >= core::range::reputation_friendly) {
+ color_reputation.assign(0.0f, 1.0f, 0.0f); // green
+ } else if (reputation <= core::range::reputation_hostile) {
+ color_reputation.assign(1.0f, 0.0f, 0.0f); // red
+ } else {
+ color_reputation.assign(1.0f, 1.0f, 1.0f); // white
+ }
+ }
+
+ // these are in model-space coordinates
+
+ const float r = entity->model()->radius(); // entity radius
+ const float l = r * 1.8f * entity->thrust(); // thrust indicator lenght
+ const float b = r * 0.1f; // direction box size
+
+ math::Vector3f minbox(r * 1.1f, 0.0f, 0.0f);
+ math::Vector3f maxbox(minbox.x() + l, 0.0f, 0.0f);
+
+ for (int pass = 0; pass < 2; ++pass) {
+ if (pass == 0) {
+ // pass 1 - background with GL_DEPTH_TEST disabled
+ gl::disable(GL_DEPTH_TEST);
+ color_reputation.a = 0.5f;
+ } else {
+ // pass 2 - highlight with GL_DEPTH_TEST enabled
+ gl::enable(GL_DEPTH_TEST);
+ color_reputation.a = 1.0f;
+ }
+
+ gl::color(color_reputation);
+ gl::begin(gl::Lines);
+ gl::vertex(maxbox);
+ gl::vertex(minbox);
+ gl::end();
+ }
+
+ minbox.assign(1.2f * r + l, -b * 0.5f, -b * 0.5f);
+ maxbox.assign(1.2f * r + l + b, b * 0.5f, b * 0.5f);
+
+ for (int pass = 0; pass < 2; ++pass) {
+ if (pass == 0) {
+ // pass 1 - background with GL_DEPTH_TEST disabled
+ gl::disable(GL_DEPTH_TEST);
+ color_reputation.a = 0.5f;
+ } else {
+ // pass 2 - highlight with GL_DEPTH_TEST enabled
+ gl::enable(GL_DEPTH_TEST);
+ color_reputation.a = 1.0f;
+ }
+ gl::color(color_reputation);
+ draw_box(minbox, maxbox);
+ }
+
+ //gl::enable(GL_DEPTH_TEST);
+}
+
+
+/* ---- Model weapon slots and docking ports ----------------------- */
+
void draw_slots(const core::Entity *entity)
{
if (!entity->model()) {
@@ -1328,7 +1403,7 @@ void draw_slots(const core::Entity *entity)
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++) {
+ 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());
@@ -1345,7 +1420,7 @@ void draw_slots(const core::Entity *entity)
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++) {
+ 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());
@@ -1398,7 +1473,7 @@ void draw_slots(const core::Entity *entity)
}
}
- gl::enable(GL_DEPTH_TEST);
+ //gl::enable(GL_DEPTH_TEST);
}
}
diff --git a/src/render/draw.h b/src/render/draw.h
index 4b59b63..d1c7998 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -24,6 +24,9 @@ void draw_target(const core::Entity *entity);
/// draws entity slots
void draw_slots(const core::Entity *entity);
+/// draw entity direction indicators
+void draw_inidicators(const core::EntityControlable *entity);
+
/// reset
void reset();
diff --git a/src/render/render.cc b/src/render/render.cc
index d6c8817..88b2577 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -43,6 +43,7 @@ core::Cvar *r_physics = 0;
core::Cvar *r_normals = 0;
core::Cvar *r_normalize = 0;
core::Cvar *r_slots = 0;
+core::Cvar *r_indicators = 0;
void func_list_textures(std::string const &args)
{
@@ -106,6 +107,9 @@ void init(int width, int height)
r_slots = core::Cvar::get("r_slots", "0", core::Cvar::Archive);
r_slots->set_info("[bool] render model slots");
+
+ r_indicators = core::Cvar::get("r_indicators", "1", core::Cvar::Archive);
+ r_slots->set_info("[bool] render direction indicators");
Screenshot::screenshotformat = core::Cvar::get("screenshot_format", "jpg", core::Cvar::Archive);
Screenshot::screenshotformat->set_info("[string] screenshot format: jpg png tga");
diff --git a/src/render/render.h b/src/render/render.h
index 71d05df..bcdd1e8 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -69,6 +69,8 @@ extern core::Cvar *r_mipmap;
extern core::Cvar *r_normalize;
/// render model slots (debug)
extern core::Cvar *r_slots;
+/// draw direction indicators
+extern core::Cvar *r_indicators;
inline RenderExt *ext_render(const core::Entity *entity)
{