Changed the default for the physics wheels to be just at
the corners of the chassis (and not where the graphical wheels are). Improved physics settings for hexley. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2479 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b4f16ef5cf
commit
aa27ba317d
@ -46,7 +46,15 @@
|
||||
(corn-f 4 )
|
||||
(corn-r 4 )
|
||||
(wheelie-max-speed-ratio 0.7 ) ;; percentage of max speed for wheelies to work
|
||||
(gravity-center-shift 0 0 0.3)
|
||||
|
||||
;; Shift of the chassis with regards to the center of mass. E.g. with the
|
||||
;; the value commented out below the chassis will be 30 cm higher than the
|
||||
;; center of mass - or the center of mass will be 30 cm lower than the
|
||||
;; middle of the chassis. So this effectively lowers the center of mass,
|
||||
;; making the kart more stable and less likely to topple over.
|
||||
;; Default (if nothing is defined here) is that the center of the mass is
|
||||
;; at the very bottom of the chassis!
|
||||
;;(gravity-center-shift 0 0 0.3)
|
||||
(wheelie-max-pitch 45.0 ) ;; maximum pitch to use when doing a wheelie
|
||||
(wheelie-pitch-rate 60.0 ) ;; rate/sec with which the kart goes up
|
||||
(wheelie-restore-rate 90.0 ) ;; rate/sec with which the kart does down
|
||||
|
@ -461,7 +461,8 @@ void btKart::updateFriction(btScalar timeStep)
|
||||
|
||||
if (m_forwardImpulse[wheel] != btScalar(0.))
|
||||
{
|
||||
m_chassisBody->applyImpulse(m_forwardWS[wheel]*(m_forwardImpulse[wheel]),rel_pos);
|
||||
m_chassisBody->applyImpulse(m_forwardWS[wheel]*(m_forwardImpulse[wheel]),
|
||||
btVector3(0,0,0));
|
||||
}
|
||||
if (m_sideImpulse[wheel] != btScalar(0.))
|
||||
{
|
||||
|
@ -833,7 +833,22 @@ void Kart::updatePhysics (float dt)
|
||||
m_engine_sound->speed(0.6f + (float)(m_speed / max_speed)*0.7f);
|
||||
m_engine_sound->position(getXYZ());
|
||||
}
|
||||
|
||||
#ifdef XX
|
||||
printf("forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n"
|
||||
,m_vehicle->m_forwardImpulse[0]
|
||||
,m_vehicle->m_forwardImpulse[1]
|
||||
,m_vehicle->m_forwardImpulse[2]
|
||||
,m_vehicle->m_forwardImpulse[3]
|
||||
,m_vehicle->m_sideImpulse[0]
|
||||
,m_vehicle->m_sideImpulse[1]
|
||||
,m_vehicle->m_sideImpulse[2]
|
||||
,m_vehicle->m_sideImpulse[3]
|
||||
,m_body->getAngularVelocity().getX()
|
||||
,m_body->getAngularVelocity().getY()
|
||||
,m_body->getAngularVelocity().getZ()
|
||||
,getHPR().getHeading()
|
||||
);
|
||||
#endif
|
||||
} // updatePhysics
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -29,7 +29,6 @@ float KartModel::UNDEFINED = -99.9f;
|
||||
|
||||
/** The constructor reads the model file name and wheel specification from the
|
||||
* kart config file.
|
||||
* \param lisp Lisp object of the kart config file.
|
||||
*/
|
||||
KartModel::KartModel()
|
||||
{
|
||||
@ -104,16 +103,14 @@ void KartModel::loadModels()
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
if(m_wheel_graphics_position[i].getX()==UNDEFINED)
|
||||
{
|
||||
m_wheel_graphics_position[i].setX( ( i==1||i==3)
|
||||
? -0.5f*m_kart_width
|
||||
: 0.5f*m_kart_width );
|
||||
if(m_wheel_graphics_position[i].getY()==STKConfig::UNDEFINED)
|
||||
m_wheel_graphics_position[i].setY( (i<2) ? 0.5f*m_kart_length
|
||||
: -0.5f*m_kart_length);
|
||||
if(m_wheel_graphics_position[i].getZ()==STKConfig::UNDEFINED)
|
||||
m_wheel_graphics_position[i].setZ(0);
|
||||
if(m_wheel_physics_position[i].getX()==UNDEFINED)
|
||||
m_wheel_physics_position[i] = m_wheel_graphics_position[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Load the wheel models. This can't be done early, since the default
|
||||
@ -176,6 +173,35 @@ void KartModel::loadWheelInfo(const lisp::Lisp* const lisp,
|
||||
wheel->get("physics-position", m_wheel_physics_position[index] );
|
||||
} // loadWheelInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the default position for the physical wheels if they are not defined
|
||||
* in the data file. The default position is to have the wheels at the corner
|
||||
* of the chassis. But since the position is relative to the center of mass,
|
||||
* this must be specified.
|
||||
* \param center_shift Amount the kart chassis is moved relative to the center
|
||||
* of mass.
|
||||
* \param wheel_radius Radius of the physics wheels.
|
||||
*/
|
||||
void KartModel::setDefaultPhysicsPosition(const Vec3 ¢er_shift,
|
||||
float wheel_radius)
|
||||
{
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
if(m_wheel_physics_position[i].getX()==UNDEFINED)
|
||||
{
|
||||
m_wheel_physics_position[i].setX( ( i==1||i==3)
|
||||
? -0.5f*m_kart_width
|
||||
: 0.5f*m_kart_width
|
||||
+center_shift.getX( ));
|
||||
m_wheel_physics_position[i].setY( (0.5f*m_kart_length-wheel_radius)
|
||||
* ( (i<2) ? 1 : -1)
|
||||
+center_shift.getY());
|
||||
m_wheel_physics_position[i].setZ(0);
|
||||
} // if physics position is not defined
|
||||
}
|
||||
|
||||
} // setDefaultPhysicsPosition
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Rotates and turns the wheels appropriately, and adjust for suspension.
|
||||
* \param rotation How far the wheels should rotate.
|
||||
|
@ -113,6 +113,6 @@ public:
|
||||
void adjustWheels(float rotation, float steer,
|
||||
const float suspension[4]);
|
||||
void resetWheels();
|
||||
|
||||
void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius);
|
||||
}; // KartModel
|
||||
#endif
|
||||
|
@ -139,12 +139,14 @@ void KartProperties::load(const std::string &filename, const std::string &node,
|
||||
{
|
||||
m_kart_model.loadModels();
|
||||
if(m_gravity_center_shift.getX()==UNDEFINED)
|
||||
{
|
||||
m_gravity_center_shift.setX(0);
|
||||
if(m_gravity_center_shift.getY()==UNDEFINED)
|
||||
m_gravity_center_shift.setY(0);
|
||||
// Default: center at the very bottom of the kart.
|
||||
if(m_gravity_center_shift.getZ()==UNDEFINED)
|
||||
m_gravity_center_shift.setZ(m_kart_model.getHeight()*0.5f);
|
||||
}
|
||||
m_kart_model.setDefaultPhysicsPosition(m_gravity_center_shift,
|
||||
m_wheel_radius);
|
||||
// Useful when tweaking kart parameters
|
||||
if(user_config->m_print_kart_sizes)
|
||||
printf("%s:\twidth: %f\tlength: %f\theight: %f\n",getIdent().c_str(),
|
||||
|
Loading…
Reference in New Issue
Block a user