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>2010-10-30 12:38:41 +0000
committerStijn Buys <ingar@osirion.org>2010-10-30 12:38:41 +0000
commit37a8c7aa64bdded36f452e6f95c829165d44e792 (patch)
tree61b428a69222b1942db6b996ef07903bf3a7ecbb /src/render/renderext.cc
parentdda07be1e679458aad9a82a7a2af5af13e733b32 (diff)
moved clientside thrust and power state into render::RenderExt, added engine spawnflag to func_rotate
Diffstat (limited to 'src/render/renderext.cc')
-rw-r--r--src/render/renderext.cc90
1 files changed, 60 insertions, 30 deletions
diff --git a/src/render/renderext.cc b/src/render/renderext.cc
index 989a892..197ca6d 100644
--- a/src/render/renderext.cc
+++ b/src/render/renderext.cc
@@ -8,6 +8,7 @@
#include <iomanip>
#include "math/functions.h"
+#include "core/application.h"
#include "core/range.h"
#include "model/model.h"
#include "render/renderext.h"
@@ -23,8 +24,7 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re
state_visible = false;
state_detailvisible = false;
state_fuzz = math::randomf();
-
- //state_engine_trail_offset = 0;
+ state_enginetime = state_fuzz * core::application()->time();
if (!entity->model() && entity->modelname().size()) {
entity->set_modelname(entity->modelname());
@@ -56,6 +56,8 @@ RenderExt::RenderExt(core::Entity *entity) : core::Extension(core::Extension::Re
for (model::Model::ParticleSystems::iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) {
model::Particles *particlesystem = (*pit);
+ // TODO multiple particlesystems per script
+
// load particle systems
ParticleScript *script = ParticleScript::load(particlesystem->script());
if (script) {
@@ -104,55 +106,83 @@ void RenderExt::frame(float elapsed)
state_visible = entity()->visible();
state_detailvisible = false;
state_behind = false;
+ state_power = true;
+ state_thrust = 0.0f;
if (!state_visible)
return;
- if ((entity()->type() == core::Entity::Controlable)) {
- if (static_cast<core::EntityDynamic *>(entity())->state() == core::Entity::Docked) {
+ if (entity()->type() == core::Entity::Dynamic) {
+
+ int state = static_cast<core::EntityDynamic *>(entity())->state();
+
+ if ((state == core::Entity::NoPower) || (state == core::Entity::Destroyed)) {
+ state_power = false;
+ }
+
+ state_enginetime += elapsed;
+
+ } else if ((entity()->type() == core::Entity::Controlable)) {
+
+ core::EntityControlable *controlable = static_cast<core::EntityControlable *>(entity());
+
+ if (controlable->state() == core::Entity::Docked) {
state_visible = false;
return;
}
+
+ if ((controlable->state() == core::Entity::NoPower) || (controlable->state() == core::Entity::Destroyed)) {
+ state_power = false;
+ }
+
+ if ((controlable->state() == core::Entity::Impulse) || (controlable->state() == core::Entity::ImpulseInitiate)) {
+ state_thrust = 1.0f;
+ } else {
+ state_thrust = controlable->thrust();
+ }
+
+ state_enginetime += elapsed * state_thrust;
+
+ } else {
+
+ state_enginetime += elapsed;
}
- if (!entity()->model())
- return;
+ if (entity()->model()) {
+
+ if (distance() < core::range::fxdistance) {
+ // entity within detail range
+ state_visible = true;
+ state_detailvisible = true;
- if (distance() < core::range::fxdistance) {
- // entity within detail range
- state_visible = true;
- state_detailvisible = true;
+ } else if (distance() < core::range::maxdistance) {
- } else if (distance() < core::range::maxdistance) {
+ // funky radius factor
+ float r = entity()->model()->radius();
+ math::clamp(r, entity()->model()->radius(), core::range::maxdistance / core::range::fxdistance);
- // funky radius factor
- float r = entity()->model()->radius();
- math::clamp(r, entity()->model()->radius(), core::range::maxdistance / core::range::fxdistance);
+ if (distance() < core::range::fxdistance * r) {
+ // entity within drawing distance, outside detail range
+ state_visible = true;
+ state_detailvisible = false;
- if (distance() < core::range::fxdistance * r) {
- // entity within drawing distance, outside detail range
- state_visible = true;
- state_detailvisible = false;
+ } else {
+ // entity within drawing distance, outside detail range
+ state_visible = true;
+ state_detailvisible = false;
+ }
} else {
- // entity within drawing distance, outside detail range
- state_visible = true;
+ // entity out of range
+ state_visible = false;
state_detailvisible = false;
+ return;
}
-
- } else {
- // entity out of range
- state_visible = false;
- state_detailvisible = false;
- return;
}
-
+
if (math::dotproduct(Camera::axis().forward(), entity()->location() + Camera::axis().forward() * entity()->radius() - Camera::eye()) < 0.0f) {
state_behind = true;
}
-
-
-
}
} // namespace render