1) Added new physics properties to kart_properties
to tune kart stability. 2) Made the kart accessible in btKart (so that the physics can access the kart properties directly). 3) Removed unused tuning variable in constructor of btKart. 4) Removed jumping related code. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/physics@10147 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
dbec3ae30a
commit
b34fc058aa
@ -44,7 +44,7 @@
|
|||||||
<news max-display="10"/>
|
<news max-display="10"/>
|
||||||
|
|
||||||
<!-- If the normals (for wheel raycasts) should be smoothened -->
|
<!-- If the normals (for wheel raycasts) should be smoothened -->
|
||||||
<physics smooth-normals="false"/>
|
<physics smooth-normals="true"/>
|
||||||
|
|
||||||
<!-- The title music. -->
|
<!-- The title music. -->
|
||||||
<music title="main_theme.music"/>
|
<music title="main_theme.music"/>
|
||||||
@ -231,9 +231,12 @@
|
|||||||
<mass value="225"/>
|
<mass value="225"/>
|
||||||
|
|
||||||
<!-- Suspension related values. stiffness: kart's suspension stiffness.
|
<!-- Suspension related values. stiffness: kart's suspension stiffness.
|
||||||
rest Length of suspension when at rest. travel-cm: maximum
|
rest: Length of suspension when at rest.
|
||||||
movement of suspension - in cm!! -->
|
travel-cm: maximum movement of suspension - in cm!!
|
||||||
<suspension stiffness="248.0" rest="0.2" travel-cm="19"/>
|
exp-string-response: dampen the suspension spring reaction
|
||||||
|
exponentially -->
|
||||||
|
<suspension stiffness="50" rest="0.2" travel-cm="19"
|
||||||
|
exp-spring-response="true"/>
|
||||||
|
|
||||||
<!-- Wheel related parameters: damping-relaxation/compression: for
|
<!-- Wheel related parameters: damping-relaxation/compression: for
|
||||||
bullet, damping parameters. Radius and width of wheel.
|
bullet, damping parameters. Radius and width of wheel.
|
||||||
@ -241,7 +244,7 @@
|
|||||||
position of the physics raycast wheels relative to the center of
|
position of the physics raycast wheels relative to the center of
|
||||||
gravity. Default is to use the corners of the chassis to attach
|
gravity. Default is to use the corners of the chassis to attach
|
||||||
the wheels to. -->
|
the wheels to. -->
|
||||||
<wheels damping-relaxation="20" damping-compression="4.4" radius="0.25">
|
<wheels damping-relaxation="2.8" damping-compression="1.4" radius="0.25">
|
||||||
<front-right position="0.38 0 0.6" />
|
<front-right position="0.38 0 0.6" />
|
||||||
<front-left position="-0.38 0 0.6" />
|
<front-left position="-0.38 0 0.6" />
|
||||||
<rear-right position="0.38 0 -0.6" />
|
<rear-right position="0.38 0 -0.6" />
|
||||||
@ -253,26 +256,22 @@
|
|||||||
<friction slip="10000000"/>
|
<friction slip="10000000"/>
|
||||||
|
|
||||||
<!-- Values related to stability of the chassis: damping, and reduced
|
<!-- Values related to stability of the chassis: damping, and reduced
|
||||||
impact of roll. -->
|
impact of roll.
|
||||||
|
downward-impulse-factor: A speed proportional impulse applied each
|
||||||
|
frame that pushes the vehicle onto the ground.
|
||||||
|
track-connection-accel: An artificial force that pulls a wheel to
|
||||||
|
the ground if its off ground. Reduces the affect if a kart loses
|
||||||
|
contact with the ground (i.e. it then can't steer or accelerate
|
||||||
|
anymore). -->
|
||||||
<stability roll-influence="0.03"
|
<stability roll-influence="0.03"
|
||||||
chassis-linear-damping="0.2"
|
chassis-linear-damping="0.2"
|
||||||
chassis-angular-damping="0"/>
|
chassis-angular-damping="0"
|
||||||
|
downward-impulse-factor="0.1"
|
||||||
|
track-connection-accel="2"/>
|
||||||
|
|
||||||
<!-- Parameters for the upright constraint, which keeps karts upright. -->
|
<!-- Parameters for the upright constraint, which keeps karts upright. -->
|
||||||
<upright tolerance="0.2" max-force="30"/>
|
<upright tolerance="0.2" max-force="30"/>
|
||||||
|
|
||||||
<!-- An artificial force that pulls a wheel to the ground if its off
|
|
||||||
ground. Reduces the affect if a kart loses contact with the ground
|
|
||||||
(i.e. it then can't steer or accelerate anymore). -->
|
|
||||||
<track-connection-accel value="2"/>
|
|
||||||
|
|
||||||
<!-- jump-velocity is the z-axis velocity set when a jump is initiated.
|
|
||||||
This will cause the kart to start rising, till it is pulled back
|
|
||||||
by gravity. A higher value means higher Z velocity, meaning the
|
|
||||||
kart will rise faster and higher, and will be in the air longer.
|
|
||||||
Notice that jumps are currently disabled, so this value is ignored. -->
|
|
||||||
<jump velocity="3.0"/>
|
|
||||||
|
|
||||||
<!-- collision-side-impulse is an additional (artificial) impulse that
|
<!-- collision-side-impulse is an additional (artificial) impulse that
|
||||||
pushes the slower kart out of the way of the faster karts (i.e.
|
pushes the slower kart out of the way of the faster karts (i.e.
|
||||||
sideways to the faster kart) when a collision happens. This is
|
sideways to the faster kart) when a collision happens. This is
|
||||||
|
@ -38,6 +38,7 @@ STKConfig::~STKConfig()
|
|||||||
if(m_title_music)
|
if(m_title_music)
|
||||||
delete m_title_music;
|
delete m_title_music;
|
||||||
} // ~STKConfig
|
} // ~STKConfig
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Loads the stk configuration file. After loading it checks if all necessary
|
/** Loads the stk configuration file. After loading it checks if all necessary
|
||||||
* values are actually defined, otherwise an error message is printed and STK
|
* values are actually defined, otherwise an error message is printed and STK
|
||||||
|
@ -276,9 +276,7 @@ void Kart::createPhysics()
|
|||||||
// -------------------------
|
// -------------------------
|
||||||
m_vehicle_raycaster =
|
m_vehicle_raycaster =
|
||||||
new btKartRaycaster(World::getWorld()->getPhysics()->getPhysicsWorld());
|
new btKartRaycaster(World::getWorld()->getPhysics()->getPhysicsWorld());
|
||||||
m_tuning = new btKart::btVehicleTuning();
|
m_vehicle = new btKart(m_body, m_vehicle_raycaster, this);
|
||||||
m_tuning->m_maxSuspensionTravelCm = m_kart_properties->getSuspensionTravelCM();
|
|
||||||
m_vehicle = new btKart(*m_tuning, m_body, m_vehicle_raycaster);
|
|
||||||
//FIXMEJH m_kart_properties->getTrackConnectionAccel());
|
//FIXMEJH m_kart_properties->getTrackConnectionAccel());
|
||||||
|
|
||||||
// never deactivate the vehicle
|
// never deactivate the vehicle
|
||||||
@ -293,13 +291,16 @@ void Kart::createPhysics()
|
|||||||
btVector3 wheel_direction(0.0f, -1.0f, 0.0f);
|
btVector3 wheel_direction(0.0f, -1.0f, 0.0f);
|
||||||
btVector3 wheel_axle(-1.0f, 0.0f, 0.0f);
|
btVector3 wheel_axle(-1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
btKart::btVehicleTuning tuning;
|
||||||
|
tuning.m_maxSuspensionTravelCm = m_kart_properties->getSuspensionTravelCM();
|
||||||
|
|
||||||
for(unsigned int i=0; i<4; i++)
|
for(unsigned int i=0; i<4; i++)
|
||||||
{
|
{
|
||||||
bool is_front_wheel = i<2;
|
bool is_front_wheel = i<2;
|
||||||
btWheelInfo& wheel = m_vehicle->addWheel(
|
btWheelInfo& wheel = m_vehicle->addWheel(
|
||||||
m_kart_model->getWheelPhysicsPosition(i),
|
m_kart_model->getWheelPhysicsPosition(i),
|
||||||
wheel_direction, wheel_axle, suspension_rest,
|
wheel_direction, wheel_axle, suspension_rest,
|
||||||
wheel_radius, *m_tuning, is_front_wheel);
|
wheel_radius, tuning, is_front_wheel);
|
||||||
wheel.m_suspensionStiffness = m_kart_properties->getSuspensionStiffness();
|
wheel.m_suspensionStiffness = m_kart_properties->getSuspensionStiffness();
|
||||||
wheel.m_wheelsDampingRelaxation = m_kart_properties->getWheelDampingRelaxation();
|
wheel.m_wheelsDampingRelaxation = m_kart_properties->getWheelDampingRelaxation();
|
||||||
wheel.m_wheelsDampingCompression = m_kart_properties->getWheelDampingCompression();
|
wheel.m_wheelsDampingCompression = m_kart_properties->getWheelDampingCompression();
|
||||||
@ -416,7 +417,6 @@ Kart::~Kart()
|
|||||||
|
|
||||||
World::getWorld()->getPhysics()->removeKart(this);
|
World::getWorld()->getPhysics()->removeKart(this);
|
||||||
delete m_vehicle;
|
delete m_vehicle;
|
||||||
delete m_tuning;
|
|
||||||
delete m_vehicle_raycaster;
|
delete m_vehicle_raycaster;
|
||||||
delete m_uprightConstraint;
|
delete m_uprightConstraint;
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ bool Kart::isOnGround() const
|
|||||||
} // isOnGround
|
} // isOnGround
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** The kart is near the ground, but not necesarily on it (small jumps). This
|
/** The kart is near the ground, but not necessarily on it (small jumps). This
|
||||||
* is used to determine when to switch off the upright constraint, so that
|
* is used to determine when to switch off the upright constraint, so that
|
||||||
* explosions can be more violent, while still
|
* explosions can be more violent, while still
|
||||||
*/
|
*/
|
||||||
@ -1677,18 +1677,6 @@ void Kart::updatePhysics(float dt)
|
|||||||
}
|
}
|
||||||
} // !m_brake
|
} // !m_brake
|
||||||
} // not accelerating
|
} // not accelerating
|
||||||
#ifdef ENABLE_JUMP
|
|
||||||
if(m_controls.jump && isOnGround())
|
|
||||||
{
|
|
||||||
//Vector3 impulse(0.0f, 0.0f, 10.0f);
|
|
||||||
// getVehicle()->getRigidBody()->applyCentralImpulse(impulse);
|
|
||||||
btVector3 velocity = m_body->getLinearVelocity();
|
|
||||||
velocity.setZ( m_kart_properties->getJumpVelocity() );
|
|
||||||
|
|
||||||
getBody()->setLinearVelocity( velocity );
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (isOnGround())
|
if (isOnGround())
|
||||||
{
|
{
|
||||||
if((fabs(m_controls.m_steer) > 0.001f) && m_controls.m_drift)
|
if((fabs(m_controls.m_steer) > 0.001f) && m_controls.m_drift)
|
||||||
|
@ -38,13 +38,12 @@
|
|||||||
#include "karts/moveable.hpp"
|
#include "karts/moveable.hpp"
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
#include "physics/btKart.hpp"
|
//#include "physics/btKart.hpp"
|
||||||
#include "tracks/terrain_info.hpp"
|
#include "tracks/terrain_info.hpp"
|
||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
|
||||||
class btKart;
|
class btKart;
|
||||||
class btUprightConstraint;
|
class btUprightConstraint;
|
||||||
class btVehicleTuning;
|
|
||||||
class Camera;
|
class Camera;
|
||||||
class Item;
|
class Item;
|
||||||
class Quad;
|
class Quad;
|
||||||
@ -134,7 +133,6 @@ private:
|
|||||||
|
|
||||||
// Bullet physics parameters
|
// Bullet physics parameters
|
||||||
// -------------------------
|
// -------------------------
|
||||||
btKart::btVehicleTuning *m_tuning;
|
|
||||||
btCompoundShape m_kart_chassis;
|
btCompoundShape m_kart_chassis;
|
||||||
btVehicleRaycaster *m_vehicle_raycaster;
|
btVehicleRaycaster *m_vehicle_raycaster;
|
||||||
btKart *m_vehicle;
|
btKart *m_vehicle;
|
||||||
|
@ -72,7 +72,7 @@ KartProperties::KartProperties(const std::string &filename)
|
|||||||
m_wheel_damping_compression = m_friction_slip = m_roll_influence =
|
m_wheel_damping_compression = m_friction_slip = m_roll_influence =
|
||||||
m_wheel_radius = m_chassis_linear_damping =
|
m_wheel_radius = m_chassis_linear_damping =
|
||||||
m_chassis_angular_damping = m_suspension_rest =
|
m_chassis_angular_damping = m_suspension_rest =
|
||||||
m_max_speed_reverse_ratio = m_jump_velocity =
|
m_max_speed_reverse_ratio =
|
||||||
m_rescue_vert_offset = m_upright_tolerance = m_collision_side_impulse =
|
m_rescue_vert_offset = m_upright_tolerance = m_collision_side_impulse =
|
||||||
m_upright_max_force = m_suspension_travel_cm =
|
m_upright_max_force = m_suspension_travel_cm =
|
||||||
m_track_connection_accel =
|
m_track_connection_accel =
|
||||||
@ -93,9 +93,10 @@ KartProperties::KartProperties(const std::string &filename)
|
|||||||
m_rescue_time = m_rescue_height = m_explosion_time =
|
m_rescue_time = m_rescue_height = m_explosion_time =
|
||||||
m_explosion_radius = m_ai_steering_variation =
|
m_explosion_radius = m_ai_steering_variation =
|
||||||
m_swatter_distance2 = m_swatter_duration = m_squash_slowdown =
|
m_swatter_distance2 = m_swatter_duration = m_squash_slowdown =
|
||||||
m_squash_duration = UNDEFINED;
|
m_squash_duration = m_downward_impulse_factor = UNDEFINED;
|
||||||
|
|
||||||
m_gravity_center_shift = Vec3(UNDEFINED);
|
m_gravity_center_shift = Vec3(UNDEFINED);
|
||||||
|
m_exp_spring_response = false;
|
||||||
m_has_skidmarks = true;
|
m_has_skidmarks = true;
|
||||||
m_version = 0;
|
m_version = 0;
|
||||||
m_color = video::SColor(255, 0, 0, 0);
|
m_color = video::SColor(255, 0, 0, 0);
|
||||||
@ -384,9 +385,10 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
|
|
||||||
if(const XMLNode *suspension_node = root->getNode("suspension"))
|
if(const XMLNode *suspension_node = root->getNode("suspension"))
|
||||||
{
|
{
|
||||||
suspension_node->get("stiffness", &m_suspension_stiffness);
|
suspension_node->get("stiffness", &m_suspension_stiffness);
|
||||||
suspension_node->get("rest", &m_suspension_rest );
|
suspension_node->get("rest", &m_suspension_rest );
|
||||||
suspension_node->get("travel-cm", &m_suspension_travel_cm);
|
suspension_node->get("travel-cm", &m_suspension_travel_cm);
|
||||||
|
suspension_node->get("exp-spring-response", &m_exp_spring_response );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(const XMLNode *wheels_node = root->getNode("wheels"))
|
if(const XMLNode *wheels_node = root->getNode("wheels"))
|
||||||
@ -401,9 +403,16 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
|
|
||||||
if(const XMLNode *stability_node = root->getNode("stability"))
|
if(const XMLNode *stability_node = root->getNode("stability"))
|
||||||
{
|
{
|
||||||
stability_node->get("roll-influence", &m_roll_influence);
|
stability_node->get("roll-influence",
|
||||||
stability_node->get("chassis-linear-damping", &m_chassis_linear_damping);
|
&m_roll_influence );
|
||||||
stability_node->get("chassis-angular-damping", &m_chassis_angular_damping);
|
stability_node->get("chassis-linear-damping",
|
||||||
|
&m_chassis_linear_damping );
|
||||||
|
stability_node->get("chassis-angular-damping",
|
||||||
|
&m_chassis_angular_damping);
|
||||||
|
stability_node->get("downward-impulse-factor",
|
||||||
|
&m_downward_impulse_factor);
|
||||||
|
stability_node->get("track-connection-accel",
|
||||||
|
&m_track_connection_accel );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(const XMLNode *upright_node = root->getNode("upright"))
|
if(const XMLNode *upright_node = root->getNode("upright"))
|
||||||
@ -412,12 +421,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
upright_node->get("max-force", &m_upright_max_force);
|
upright_node->get("max-force", &m_upright_max_force);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(const XMLNode *track_connection_node = root->getNode("track-connection-accel"))
|
|
||||||
track_connection_node->get("value", &m_track_connection_accel);
|
|
||||||
|
|
||||||
if(const XMLNode *jump_node = root->getNode("jump"))
|
|
||||||
jump_node->get("velocity", &m_jump_velocity);
|
|
||||||
|
|
||||||
if(const XMLNode *collision_node = root->getNode("collision"))
|
if(const XMLNode *collision_node = root->getNode("collision"))
|
||||||
collision_node->get("side-impulse", &m_collision_side_impulse);
|
collision_node->get("side-impulse", &m_collision_side_impulse);
|
||||||
|
|
||||||
@ -567,8 +570,10 @@ void KartProperties::checkAllSet(const std::string &filename)
|
|||||||
CHECK_NEG(m_wheel_radius, "wheels radius" );
|
CHECK_NEG(m_wheel_radius, "wheels radius" );
|
||||||
CHECK_NEG(m_friction_slip, "friction slip" );
|
CHECK_NEG(m_friction_slip, "friction slip" );
|
||||||
CHECK_NEG(m_roll_influence, "stability roll-influence" );
|
CHECK_NEG(m_roll_influence, "stability roll-influence" );
|
||||||
CHECK_NEG(m_chassis_linear_damping, "stability chassis-linear-damping");
|
CHECK_NEG(m_chassis_linear_damping, "stability chassis-linear-damping" );
|
||||||
CHECK_NEG(m_chassis_angular_damping, "stability chassis-angular-damping");
|
CHECK_NEG(m_chassis_angular_damping, "stability chassis-angular-damping");
|
||||||
|
CHECK_NEG(m_downward_impulse_factor, "stability downward-impulse-factor");
|
||||||
|
CHECK_NEG(m_track_connection_accel, "stability track-connection-accel" );
|
||||||
CHECK_NEG(m_engine_power[0], "engine power[0]" );
|
CHECK_NEG(m_engine_power[0], "engine power[0]" );
|
||||||
CHECK_NEG(m_engine_power[1], "engine power[1]" );
|
CHECK_NEG(m_engine_power[1], "engine power[1]" );
|
||||||
CHECK_NEG(m_engine_power[2], "engine power[2]" );
|
CHECK_NEG(m_engine_power[2], "engine power[2]" );
|
||||||
@ -580,11 +585,10 @@ void KartProperties::checkAllSet(const std::string &filename)
|
|||||||
CHECK_NEG(m_suspension_stiffness, "suspension stiffness" );
|
CHECK_NEG(m_suspension_stiffness, "suspension stiffness" );
|
||||||
CHECK_NEG(m_suspension_rest, "suspension rest" );
|
CHECK_NEG(m_suspension_rest, "suspension rest" );
|
||||||
CHECK_NEG(m_suspension_travel_cm, "suspension travel-cm" );
|
CHECK_NEG(m_suspension_travel_cm, "suspension travel-cm" );
|
||||||
|
CHECK_NEG(m_exp_spring_response, "suspension exp-string-response");
|
||||||
CHECK_NEG(m_collision_side_impulse, "collision side-impulse" );
|
CHECK_NEG(m_collision_side_impulse, "collision side-impulse" );
|
||||||
CHECK_NEG(m_jump_velocity, "jump velocity" );
|
|
||||||
CHECK_NEG(m_upright_tolerance, "upright tolerance" );
|
CHECK_NEG(m_upright_tolerance, "upright tolerance" );
|
||||||
CHECK_NEG(m_upright_max_force, "upright max-force" );
|
CHECK_NEG(m_upright_max_force, "upright max-force" );
|
||||||
CHECK_NEG(m_track_connection_accel, "track-connection-accel" );
|
|
||||||
CHECK_NEG(m_plunger_in_face_duration[0],"plunger in-face-time[0]" );
|
CHECK_NEG(m_plunger_in_face_duration[0],"plunger in-face-time[0]" );
|
||||||
CHECK_NEG(m_plunger_in_face_duration[1],"plunger in-face-time[1]" );
|
CHECK_NEG(m_plunger_in_face_duration[1],"plunger in-face-time[1]" );
|
||||||
CHECK_NEG(m_plunger_in_face_duration[2],"plunger in-face-time[2]" );
|
CHECK_NEG(m_plunger_in_face_duration[2],"plunger in-face-time[2]" );
|
||||||
|
@ -85,7 +85,7 @@ private:
|
|||||||
|
|
||||||
// Display and gui
|
// Display and gui
|
||||||
// ---------------
|
// ---------------
|
||||||
std::string m_name; /**< The human readable Name of the kart
|
std::string m_name; /**< The human readable Name of the kart
|
||||||
* driver. */
|
* driver. */
|
||||||
std::string m_ident; /**< The computer readable-name of the
|
std::string m_ident; /**< The computer readable-name of the
|
||||||
* kart driver. */
|
* kart driver. */
|
||||||
@ -217,21 +217,41 @@ private:
|
|||||||
float m_friction_slip;
|
float m_friction_slip;
|
||||||
float m_roll_influence;
|
float m_roll_influence;
|
||||||
float m_wheel_radius;
|
float m_wheel_radius;
|
||||||
|
|
||||||
|
/** An impulse pushing the kart down which is proportional to speed. So
|
||||||
|
* the actual impulse is speed * m_downward_force_factor. Set it to
|
||||||
|
* 0 to disable completely. Based on
|
||||||
|
* http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=6059\
|
||||||
|
* &p=21240&hilit=vehicle#p21240 */
|
||||||
|
float m_downward_impulse_factor;
|
||||||
|
|
||||||
|
/** Artifical acceleration that pulls a kart down onto the track if one
|
||||||
|
* axis loses contact with the track. */
|
||||||
|
float m_track_connection_accel;
|
||||||
|
|
||||||
|
/** Linear damping of the chassis to prevent it from toppling over. */
|
||||||
float m_chassis_linear_damping;
|
float m_chassis_linear_damping;
|
||||||
|
|
||||||
|
/** Angular damping to prevent it from turning too easily. */
|
||||||
float m_chassis_angular_damping;
|
float m_chassis_angular_damping;
|
||||||
|
|
||||||
float m_max_speed[3];
|
float m_max_speed[3];
|
||||||
float m_max_speed_reverse_ratio;
|
float m_max_speed_reverse_ratio;
|
||||||
Vec3 m_gravity_center_shift; /**< Shift of center of gravity. */
|
|
||||||
float m_track_connection_accel; /**< Artifical acceleration that pulls a
|
/** Shift of center of gravity. */
|
||||||
* kart down onto the track if one axis
|
Vec3 m_gravity_center_shift;
|
||||||
* loses contact with the track. */
|
|
||||||
|
/** The suspension reaction is dampened to reach an exponential behaviour.
|
||||||
|
* See http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7369\
|
||||||
|
* &p=25236&hilit=vehicle#p25236 for details. */
|
||||||
|
bool m_exp_spring_response;
|
||||||
|
|
||||||
float m_suspension_rest;
|
float m_suspension_rest;
|
||||||
float m_suspension_travel_cm;
|
float m_suspension_travel_cm;
|
||||||
/** An additional artifical side-impulse that pushes the slower kart
|
/** An additional artifical side-impulse that pushes the slower kart
|
||||||
* out of the way of the faster kart in case of a collision. */
|
* out of the way of the faster kart in case of a collision. */
|
||||||
float m_collision_side_impulse;
|
float m_collision_side_impulse;
|
||||||
/** Vertical velocity set when jumping. */
|
|
||||||
float m_jump_velocity;
|
|
||||||
float m_upright_tolerance;
|
float m_upright_tolerance;
|
||||||
float m_upright_max_force;
|
float m_upright_max_force;
|
||||||
|
|
||||||
@ -418,6 +438,9 @@ public:
|
|||||||
float getChassisAngularDamping () const
|
float getChassisAngularDamping () const
|
||||||
{return m_chassis_angular_damping; }
|
{return m_chassis_angular_damping; }
|
||||||
|
|
||||||
|
/** Returns artificial acceleration to keep wheels on track. */
|
||||||
|
float getTrackConnectionAccel () const {return m_track_connection_accel;}
|
||||||
|
|
||||||
/** Returns the maximum speed dependent on the difficult level. */
|
/** Returns the maximum speed dependent on the difficult level. */
|
||||||
float getMaxSpeed () const {return
|
float getMaxSpeed () const {return
|
||||||
m_max_speed[race_manager->getDifficulty()];}
|
m_max_speed[race_manager->getDifficulty()];}
|
||||||
@ -456,8 +479,8 @@ public:
|
|||||||
/** Returns the amount the suspension can extend. */
|
/** Returns the amount the suspension can extend. */
|
||||||
float getSuspensionTravelCM () const {return m_suspension_travel_cm; }
|
float getSuspensionTravelCM () const {return m_suspension_travel_cm; }
|
||||||
|
|
||||||
/** Returns jump velocity (unused atm). */
|
/** Returns if the spring should be exponentially dampened. */
|
||||||
float getJumpVelocity () const {return m_jump_velocity; }
|
bool getExpSpringResponse() const {return m_exp_spring_response; }
|
||||||
|
|
||||||
/** Returns the (artificial) collision side impulse this kart will apply
|
/** Returns the (artificial) collision side impulse this kart will apply
|
||||||
* to a slower kart in case of a collision. */
|
* to a slower kart in case of a collision. */
|
||||||
@ -491,9 +514,6 @@ public:
|
|||||||
/** Returns the maximum value of the upright counteracting force. */
|
/** Returns the maximum value of the upright counteracting force. */
|
||||||
float getUprightMaxForce () const {return m_upright_max_force; }
|
float getUprightMaxForce () const {return m_upright_max_force; }
|
||||||
|
|
||||||
/** Returns artificial acceleration to keep wheels on track. */
|
|
||||||
float getTrackConnectionAccel () const {return m_track_connection_accel;}
|
|
||||||
|
|
||||||
/** Returns the maximum length of a rubber band before it breaks. */
|
/** Returns the maximum length of a rubber band before it breaks. */
|
||||||
float getRubberBandMaxLength () const {return m_rubber_band_max_length;}
|
float getRubberBandMaxLength () const {return m_rubber_band_max_length;}
|
||||||
|
|
||||||
|
@ -32,25 +32,25 @@ btRigidBody& btActionInterface::getFixedBody()
|
|||||||
return s_fixed;
|
return s_fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
btKart::btKart(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster )
|
btKart::btKart(btRigidBody* chassis, btVehicleRaycaster* raycaster,
|
||||||
:m_vehicleRaycaster(raycaster),
|
Kart *kart)
|
||||||
m_pitchControl(btScalar(0.))
|
: m_vehicleRaycaster(raycaster),
|
||||||
|
m_pitchControl(btScalar(0.))
|
||||||
{
|
{
|
||||||
m_chassisBody = chassis;
|
m_chassisBody = chassis;
|
||||||
m_indexRightAxis = 0;
|
m_indexRightAxis = 0;
|
||||||
m_indexUpAxis = 2;
|
m_indexUpAxis = 2;
|
||||||
m_indexForwardAxis = 1;
|
m_indexForwardAxis = 1;
|
||||||
defaultInit(tuning);
|
defaultInit();
|
||||||
m_num_wheels_on_ground = 0;
|
m_num_wheels_on_ground = 0;
|
||||||
|
m_kart = kart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void btKart::defaultInit(const btVehicleTuning& tuning)
|
void btKart::defaultInit()
|
||||||
{
|
{
|
||||||
(void)tuning;
|
|
||||||
m_currentVehicleSpeedKmHour = btScalar(0.);
|
m_currentVehicleSpeedKmHour = btScalar(0.);
|
||||||
m_steeringValue = btScalar(0.);
|
m_steeringValue = btScalar(0.);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ class btDynamicsWorld;
|
|||||||
#include "BulletDynamics/Dynamics/btActionInterface.h"
|
#include "BulletDynamics/Dynamics/btActionInterface.h"
|
||||||
|
|
||||||
class btVehicleTuning;
|
class btVehicleTuning;
|
||||||
|
class Kart;
|
||||||
|
|
||||||
///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
|
///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
|
||||||
class btKart : public btActionInterface
|
class btKart : public btActionInterface
|
||||||
@ -72,12 +73,18 @@ protected:
|
|||||||
int m_indexUpAxis;
|
int m_indexUpAxis;
|
||||||
int m_indexForwardAxis;
|
int m_indexForwardAxis;
|
||||||
|
|
||||||
void defaultInit(const btVehicleTuning& tuning);
|
/** The STK kart object which uses this vehicle. This is mostly used to
|
||||||
|
* get access to the kart properties, which also define physics
|
||||||
|
* properties. */
|
||||||
|
Kart *m_kart;
|
||||||
|
|
||||||
|
void defaultInit();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//constructor to create a car from an existing rigidbody
|
//constructor to create a car from an existing rigidbody
|
||||||
btKart(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster );
|
btKart(btRigidBody* chassis, btVehicleRaycaster* raycaster,
|
||||||
|
Kart *kart);
|
||||||
|
|
||||||
virtual ~btKart() ;
|
virtual ~btKart() ;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user