From 5189168482f32d8aac630cde27fc0999e70ed57b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 25 Oct 2010 13:43:11 +0000 Subject: renamed ship torque_force to turn_force, added ship roll_force --- src/game/base/ship.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/game/base/ship.cc') diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index 0ac7461..641894e 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -78,7 +78,9 @@ Ship::Ship(core::Player *owner, ShipModel *shipmodel) : core::EntityControlable( set_impulse_force(shipmodel->impulse_force()); set_thrust_force(shipmodel->thrust_force()); set_strafe_force(shipmodel->strafe_force()); - set_torque_force(shipmodel->torque_force()); + set_turn_force(shipmodel->turn_force()); + set_roll_force(shipmodel->roll_force()); + reset(); const float linear_damp = 0.8f; @@ -275,7 +277,8 @@ void Ship::action (btScalar seconds) { float maxspeed = 0; float engine_force = 0; - float torque_force = ship_torque_force; + float turn_force = ship_turn_force; + float roll_force = ship_roll_force; btTransform t; @@ -289,7 +292,8 @@ void Ship::action (btScalar seconds) case core::Entity::Impulse: engine_force = ship_impulse_force; maxspeed = (Game::g_impulsespeed ? Game::g_impulsespeed->value() * 0.01f : 0.0f); - torque_force *= .5f; + turn_force *= .5f; + roll_force *= .5f; break; case core::Entity::JumpInitiate: @@ -321,7 +325,6 @@ void Ship::action (btScalar seconds) get_axis().assign(t.getBasis()); const float torque_scale = 0.001f; - const float roll_scale = 0.25f; // apply strafe body()->applyCentralImpulse(math::to_btVector3(axis().up() * current_target_vstrafe * ship_strafe_force)); @@ -335,11 +338,12 @@ void Ship::action (btScalar seconds) } // apply direction - body()->applyTorqueImpulse(math::to_btVector3(axis().up() * current_target_direction * torque_force * torque_scale)); + body()->applyTorqueImpulse(math::to_btVector3(axis().up() * current_target_direction * turn_force * torque_scale)); // apply pitch - body()->applyTorqueImpulse(math::to_btVector3(axis().left() * -current_target_pitch * torque_force * torque_scale)); + body()->applyTorqueImpulse(math::to_btVector3(axis().left() * -current_target_pitch * turn_force * torque_scale)); + // apply roll - body()->applyTorqueImpulse(math::to_btVector3(axis().forward() * -current_target_roll * torque_force * roll_scale * torque_scale)); + body()->applyTorqueImpulse(math::to_btVector3(axis().forward() * -current_target_roll * roll_force* torque_scale)); // limit speed entity_speed = (float) entity_body->getLinearVelocity().length(); @@ -348,6 +352,7 @@ void Ship::action (btScalar seconds) body()->setLinearVelocity(math::to_btVector3(axis().forward() * entity_speed)); } } + void Ship::frame(float seconds) { const float direction_reaction = 2.0f; // directional control reaction time -- cgit v1.2.3