Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/ship.cc')
-rw-r--r--src/game/base/ship.cc144
1 files changed, 18 insertions, 126 deletions
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 0b31a91..726729a 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -30,20 +30,33 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable(
entity_moduletypeid = ship_enttype;
+ set_radius(0);
+
// apply template settings
if (shipmodel->model_template()) {
- shipmodel->model_template();
+ shipmodel->model_template()->apply(this);
}
// apply ship model settings
- // ship model overrides template model
+ // shipmodel overrides template model and radius
if (shipmodel->modelname().size()) {
set_modelname(shipmodel->modelname());
}
- set_name(shipmodel->name());
- set_info(shipmodel);
+ if (shipmodel->radius()) {
+ set_radius(shipmodel->radius());
+ }
+ if (!radius()) {
+ if (model()) {
+ set_radius(model()->radius());
+ }
+ }
+ if (!radius()) {
+ set_radius(0.5f);
+ }
ship_shipmodel = shipmodel;
+ set_info(shipmodel);
+ set_name(shipmodel->name());
ship_jumpdrive = shipmodel->jumpdrive();
ship_impulsedrive_timer = 0;
ship_jumpdrive_timer = 0;
@@ -61,8 +74,7 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable(
// add an inventory
set_inventory(new core::Inventory());
- inventory()->set_capacity(shipmodel->maxcargo());
-
+ inventory()->set_capacity(shipmodel->maxcargo());
} else {
set_name(shipmodel->name());
set_label(shipmodel->label());
@@ -624,127 +636,7 @@ void Ship::frame(float seconds)
if (current_target_roll < target_roll)
current_target_roll = target_roll;
}
-
- /*
- // -- BULLET
-
- // apply thrust
- body()->applyCentralForce(math::to_btVector3(axis().forward() * (actual_thrust * actual_acceleration)));
-
- // apply strafe
- body()->applyCentralForce(math::to_btVector3(axis().left() * (current_target_strafe * 0.15f * actual_acceleration)));
- body()->applyCentralForce(math::to_btVector3(axis().up() * (current_target_vstrafe * 0.15f * actual_acceleration)));
-
- // FIXME get movement state from linear/angular velocity
- entity_movement = target_thrust;
- entity_movement = math::max(entity_movement, fabs(current_target_pitch));
- entity_movement = math::max(entity_movement, fabs(current_target_direction));
- entity_movement = math::max(entity_movement, fabs(current_target_roll));
- entity_movement = math::max(entity_movement, fabs(current_target_afterburner));
- entity_movement = math::max(entity_movement, fabs(current_target_strafe));
- entity_movement = math::max(entity_movement, fabs(current_target_vstrafe));
-
- if (entity_movement > 0) {
- set_dirty();
- }
-
- EntityDynamic::frame(seconds);
-
-
- // apply direction rotation to target axis
- if (fabs(current_target_direction) > MIN_DELTA) {
- math::clamp(current_target_direction, -1.0f, 1.0f);
- target_axis.change_direction(actual_turnspeed * current_target_direction);
- } else {
- current_target_direction = 0.0f;
- }
-
- // apply pitch rotation to target axis
- if (fabs(current_target_pitch) > MIN_DELTA) {
- math::clamp(current_target_pitch, -1.0f, 1.0f);
- target_axis.change_pitch(actual_turnspeed * current_target_pitch);
- } else {
- current_target_pitch = 0.0f;
- }
-
- // apply roll rotation to axis
- if (fabs(current_target_roll) > MIN_DELTA) {
- math::clamp(current_target_roll, -1.0f, 1.0f);
- get_axis().change_roll(actual_turnspeed * current_target_roll * seconds);
- } else {
- current_target_roll = 0.0f;
- }
-
- // update axis
- float cosangle; // cosine of an angle
- float angle; // angle in radians
-
- n.assign(math::crossproduct(axis().forward(), target_axis.forward()));
- if (!(n.length() < MIN_DELTA)) {
- n.normalize();
- cosangle = math::dotproduct(axis().forward(), target_axis.forward());
- angle = acos(cosangle) * seconds; // * 180.0f / M_PI;
- if (angle > MIN_DELTA)
- get_axis().rotate(n, -angle);
- }
-
- // update speed
- if ((entity_state == core::Entity::ImpulseInitiate) || (entity_state == core::Entity::Impulse)) {
- actual_thrust = 1.0f;
- } else {
- actual_thrust = entity_thrust + current_target_afterburner * 0.15f;
- }
-
- const float max = actual_thrust * actual_maxspeed;
- if (entity_speed < max) {
- entity_speed += actual_acceleration * seconds;
- if (entity_speed > max) {
- entity_speed = max;
- }
- } else if (entity_speed > max) {
- entity_speed -= actual_acceleration * seconds;
- if (entity_speed < max) {
- entity_speed = max;
- }
- }
- // apply strafe to location
- if (fabs(current_target_strafe) > MIN_DELTA) {
- get_location() += axis().left() * (current_target_strafe * 0.15f * actual_maxspeed) * seconds;
- }
-
- // apply vstrafe to location
- if (fabs(current_target_vstrafe) > MIN_DELTA) {
- get_location() += axis().up() * (current_target_vstrafe * 0.15f * actual_maxspeed) * seconds;
- }
-
- // apply speed to location
- if (fabs(speed()) > MIN_DELTA) {
- get_location() += axis().forward() * speed() * seconds;
- }
-
- entity_movement = target_thrust;
- entity_movement = math::max(entity_movement, fabs(current_target_pitch));
- entity_movement = math::max(entity_movement, fabs(current_target_direction));
- entity_movement = math::max(entity_movement, fabs(current_target_roll));
- entity_movement = math::max(entity_movement, fabs(current_target_afterburner));
- entity_movement = math::max(entity_movement, fabs(current_target_strafe));
- entity_movement = math::max(entity_movement, fabs(current_target_vstrafe));
-
- if ((entity_movement > 0) || (entity_speed > 0)) {
- set_dirty();
- }
-
- // transfer entity location to motion state
- btTransform t;
- t.setIdentity();
- t.setOrigin(math::to_btVector3(location()));
- t.setBasis(math::to_btMatrix3x3(axis()));
- entity_body->setWorldTransform(t);
-
- if (zone())
- zone()->physics()->synchronizeSingleMotionState(entity_body);
- */
EntityControlable::frame(seconds);
}