SuperTuxKart
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
KartProperties Class Reference

This class stores the properties of a kart. More...

#include <kart_properties.hpp>

Public Types

enum  TerrainImpulseType { IMPULSE_NONE , IMPULSE_NORMAL , IMPULSE_TO_DRIVELINE }
 STK can add an impulse to push karts away from the track in case of a kart-track collision. More...
 

Public Member Functions

 KartProperties (const std::string &filename="")
 The constructor initialises all values with invalid values.
 
 ~KartProperties ()
 Destructor, dereferences the kart model.
 
void copyForPlayer (const KartProperties *source, HandicapLevel h=HANDICAP_NONE)
 Copies this KartProperties to another one.
 
void adjustForOnlineAddonKart (const KartProperties *source)
 Change the graphical properties (icon, shadow..) for addon kart using in online mode.
 
void updateForOnlineKart (const std::string &id, const Vec3 &gravity_shift, float kart_length)
 
void copyFrom (const KartProperties *source)
 Copies this KartProperties to another one.
 
void getAllData (const XMLNode *root)
 Actually reads in the data from the xml file.
 
void checkAllSet (const std::string &filename)
 Checks if all necessary physics values are indeed defines.
 
bool isInGroup (const std::string &group) const
 
bool operator< (const KartProperties &other) const
 
void initKartWithDifferentType (const std::string &type)
 
const AbstractCharacteristicgetCharacteristic () const
 Returns the characteristics for this kart.
 
const AbstractCharacteristicgetCombinedCharacteristic () const
 Returns the characteristics for this kart combined with the base characteristic.
 
MaterialgetIconMaterial () const
 Returns the material for the kart icons.
 
video::ITexture * getMinimapIcon () const
 Returns the texture to use in the minimap, or NULL if not defined.
 
KartModelgetKartModelCopy (std::shared_ptr< GE::GERenderInfo > ri=nullptr) const
 Returns a pointer to the KartModel object.
 
const KartModelgetMasterKartModel () const
 Returns a pointer to the main KartModel object.
 
void setHatMeshName (const std::string &hat_name)
 Sets the name of a mesh to be used for this kart.
 
core::stringw getName () const
 Returns the name of this kart.
 
const std::string getNonTranslatedName () const
 
const std::string & getIdent () const
 Returns the internal identifier of this kart.
 
const std::string & getKartType () const
 Returns the type of this kart.
 
MaterialgetShadowMaterial () const
 Returns the shadow texture to use.
 
const std::string & getAbsoluteIconFile () const
 Returns the absolute path of the icon file of this kart.
 
const int getCustomSfxId (int type) const
 Returns custom sound effects for this kart.
 
int getVersion () const
 Returns the version of the .kart file.
 
const video::SColor & getColor () const
 Returns the dot color to use for this kart in the race gui.
 
int getShape () const
 Returns the number of edges for the polygon used to draw the dot of this kart on the mini map of the race gui.
 
const std::vector< std::string > & getGroups () const
 Returns the list of groups this kart belongs to.
 
const std::string & getEngineSfxType () const
 Returns the engine type (used to change sfx depending on kart size).
 
const std::string & getSkidSound () const
 Returns the skid sound.
 
float getFrictionSlip () const
 Returns friction slip.
 
float getWheelBase () const
 Returns the wheel base (distance front to rear axis).
 
const Vec3getGravityCenterShift () const
 Returns a shift of the center of mass (lowering the center of mass makes the karts more stable.
 
float getCollisionTerrainImpulse () const
 Returns an artificial impulse to push karts away from the terrain it hits.
 
TerrainImpulseType getTerrainImpulseType () const
 Returns what kind of impulse STK should use in case of a kart-track collision.
 
float getCollisionImpulse () const
 Returns the (artificial) collision impulse this kart will apply to another kart in case of a non-frontal collision.
 
float getCollisionImpulseTime () const
 Returns how long the collision impulse should be applied.
 
float getRestitution (float speed) const
 Returns the restitution factor for this kart.
 
const AIPropertiesgetAIPropertiesForDifficulty () const
 Returns a pointer to the AI properties.
 
const std::string & getKartDir () const
 Returns the full path where the files for this kart are stored.
 
const Vec3getBevelFactor () const
 Returns the bevel factor (!=0 indicates to use a bevelled box).
 
const float getPhysicalWheelPosition () const
 Returns position of the physical wheel is a weighted average of the two ends of the beveled shape.
 
float getAccelerationEfficiency () const
 This function returns a weighted average of engine power divide by mass for use as a single number summing-up acceleration's efficiency, e.g.
 
int8_t getNitroMinConsumptionTicks () const
 Returns minimum time during which nitro is consumed when pressing nitro key, to prevent using nitro in very short bursts.
 
bool isAddon () const
 
float getSuspensionStiffness () const
 
float getSuspensionRest () const
 
float getSuspensionTravel () const
 
bool getSuspensionExpSpringResponse () const
 
float getSuspensionMaxForce () const
 
float getStabilityRollInfluence () const
 
float getStabilityChassisLinearDamping () const
 
float getStabilityChassisAngularDamping () const
 
float getStabilityDownwardImpulseFactor () const
 
float getStabilityTrackConnectionAccel () const
 
std::vector< float > getStabilityAngularFactor () const
 
float getStabilitySmoothFlyingImpulse () const
 
InterpolationArray getTurnRadius () const
 
float getTurnTimeResetSteer () const
 
InterpolationArray getTurnTimeFullSteer () const
 
float getEnginePower () const
 
float getEngineMaxSpeed () const
 
float getEngineGenericMaxSpeed () const
 
float getEngineBrakeFactor () const
 
float getEngineBrakeTimeIncrease () const
 
float getEngineMaxSpeedReverseRatio () const
 
std::vector< float > getGearSwitchRatio () const
 
std::vector< float > getGearPowerIncrease () const
 
float getMass () const
 
float getWheelsDampingRelaxation () const
 
float getWheelsDampingCompression () const
 
float getJumpAnimationTime () const
 
float getLeanMax () const
 
float getLeanSpeed () const
 
float getAnvilDuration () const
 
float getAnvilWeight () const
 
float getAnvilSpeedFactor () const
 
float getParachuteFriction () const
 
float getParachuteDuration () const
 
float getParachuteDurationOther () const
 
float getParachuteDurationRankMult () const
 
float getParachuteDurationSpeedMult () const
 
float getParachuteLboundFraction () const
 
float getParachuteUboundFraction () const
 
float getParachuteMaxSpeed () const
 
float getFrictionKartFriction () const
 
float getBubblegumDuration () const
 
float getBubblegumSpeedFraction () const
 
float getBubblegumTorque () const
 
float getBubblegumFadeInTime () const
 
float getBubblegumShieldDuration () const
 
float getZipperDuration () const
 
float getZipperForce () const
 
float getZipperSpeedGain () const
 
float getZipperMaxSpeedIncrease () const
 
float getZipperFadeOutTime () const
 
float getSwatterDuration () const
 
float getSwatterDistance () const
 
float getSwatterSquashDuration () const
 
float getSwatterSquashSlowdown () const
 
float getPlungerBandMaxLength () const
 
float getPlungerBandForce () const
 
float getPlungerBandDuration () const
 
float getPlungerBandSpeedIncrease () const
 
float getPlungerBandFadeOutTime () const
 
float getPlungerInFaceTime () const
 
std::vector< float > getStartupTime () const
 
std::vector< float > getStartupBoost () const
 
float getRescueDuration () const
 
float getRescueVertOffset () const
 
float getRescueHeight () const
 
float getExplosionDuration () const
 
float getExplosionRadius () const
 
float getExplosionInvulnerabilityTime () const
 
float getNitroDuration () const
 
float getNitroEngineForce () const
 
float getNitroEngineMult () const
 
float getNitroConsumption () const
 
float getNitroSmallContainer () const
 
float getNitroBigContainer () const
 
float getNitroMaxSpeedIncrease () const
 
float getNitroFadeOutTime () const
 
float getNitroMax () const
 
float getSlipstreamDurationFactor () const
 
float getSlipstreamBaseSpeed () const
 
float getSlipstreamLength () const
 
float getSlipstreamWidth () const
 
float getSlipstreamInnerFactor () const
 
float getSlipstreamMinCollectTime () const
 
float getSlipstreamMaxCollectTime () const
 
float getSlipstreamAddPower () const
 
float getSlipstreamMinSpeed () const
 
float getSlipstreamMaxSpeedIncrease () const
 
float getSlipstreamFadeOutTime () const
 
float getSkidIncrease () const
 
float getSkidDecrease () const
 
float getSkidMax () const
 
float getSkidTimeTillMax () const
 
float getSkidVisual () const
 
float getSkidVisualTime () const
 
float getSkidRevertVisualTime () const
 
float getSkidMinSpeed () const
 
std::vector< float > getSkidTimeTillBonus () const
 
std::vector< float > getSkidBonusSpeed () const
 
std::vector< float > getSkidBonusTime () const
 
std::vector< float > getSkidBonusForce () const
 
float getSkidPhysicalJumpTime () const
 
float getSkidGraphicalJumpTime () const
 
float getSkidPostSkidRotateFactor () const
 
float getSkidReduceTurnMin () const
 
float getSkidReduceTurnMax () const
 
bool getSkidEnabled () const
 

Static Public Member Functions

static std::string getHandicapAsString (HandicapLevel h)
 Returns the string representation of a handicap level.
 

Private Member Functions

void load (const std::string &filename, const std::string &node)
 Loads the kart properties from a file.
 
void combineCharacteristics (HandicapLevel h)
 
void setWheelBase (float kart_length)
 
void handleOnDemandLoadTexture ()
 

Private Attributes

std::string m_root
 Base directory for this kart.
 
std::string m_root_absolute_path
 
std::shared_ptr< AIPropertiesm_ai_properties [RaceManager::DIFFICULTY_COUNT]
 AI Properties for this kart, as a separate object in order to reduce dependencies (and therefore compile time) when changing any AI property.
 
Materialm_icon_material
 The absolute path of the icon texture to use.
 
std::string m_minimap_icon_file
 The minimap icon file.
 
video::ITexture * m_minimap_icon
 The texture to use in the minimap.
 
std::shared_ptr< KartModelm_kart_model
 The kart model and wheels.
 
std::vector< std::string > m_groups
 List of all groups the kart belongs to.
 
int m_version
 Version of the .kart file.
 
std::vector< int > m_custom_sfx_id
 Vector of custom SFX ids.
 
std::string m_name
 The human readable Name of the kart driver.
 
std::string m_ident
 The computer readable-name of the kart driver.
 
std::string m_icon_file
 Filename of icon that represents the kart in the statusbar and the character select screen.
 
std::string m_shadow_file
 Filename of the image file that contains the shadow for this kart.
 
float m_shadow_scale
 Scale of the shadow plane for this kart.
 
float m_shadow_x_offset
 X offset of the shadow plane for this kart.
 
float m_shadow_z_offset
 Z offset of the shadow plane for this kart.
 
Materialm_shadow_material
 The texture with the shadow.
 
video::SColor m_color
 Color the represents the kart in the status bar and on the track-view.
 
int m_shape
 Number of vertices in polygon when drawing the dot on the mini map.
 
std::shared_ptr< AbstractCharacteristicm_characteristic
 The physical, item, etc.
 
std::shared_ptr< CombinedCharacteristicm_combined_characteristic
 The base characteristics combined with the characteristics of this kart.
 
std::shared_ptr< CachedCharacteristicm_cached_characteristic
 The cached combined characteristics.
 
Vec3 m_bevel_factor
 If != 0 a bevelled box shape is used by using a point cloud as a collision shape.
 
float m_physical_wheel_position
 The position of the physical wheel is a weighted average of the two ends of the beveled shape.
 
int8_t m_nitro_min_consumption
 Minimum time during which nitro is consumed when pressing the nitro key (to prevent using in very small bursts)
 
bool m_is_addon
 
std::string m_kart_type
 Type of the kart (for the properties)
 
std::string m_wheel_filename [4]
 Filename of the wheel models.
 
float m_wheel_base
 Wheel base of the kart.
 
std::string m_engine_sfx_type
 Engine sound effect.
 
std::string m_skid_sound
 
float m_friction_slip
 
Vec3 m_gravity_center_shift
 Shift of center of gravity.
 
TerrainImpulseType m_terrain_impulse_type
 
float m_collision_terrain_impulse
 An additional impulse to push a kart away if it hits terrain.
 
float m_collision_impulse
 An additiojnal artificial impulse that pushes two karts in a side-side collision away from each other.
 
float m_collision_impulse_time
 How long the collision impulse should be applied.
 
InterpolationArray m_restitution
 Restitution depending on speed.
 

Static Private Attributes

static float UNDEFINED = -99.9f
 Dummy value to detect unset properties.
 

Detailed Description

This class stores the properties of a kart.

This includes size, name, identifier, physical properties etc. It is atm also the base class for STKConfig, which stores the default values for all physics constants. Note that KartProperties is copied (when setting the default values from stk_config.

Member Enumeration Documentation

◆ TerrainImpulseType

STK can add an impulse to push karts away from the track in case of a kart-track collision.

This can be done in two ways: either apply the impulse in the direction of the normal, or towards the driveline. The later works nice as long as the kart is driving on the main track, but can work very bad if the kart is drivling off-track (and a wrong driveline is selected).

Constructor & Destructor Documentation

◆ KartProperties()

KartProperties::KartProperties ( const std::string &  filename = "")

The constructor initialises all values with invalid values.

It can later then be checked (for STKConfig) that all values are indeed defined. Otherwise the defaults are taken from STKConfig (and since they are all defined, it is guaranteed that each kart has well defined physics values).

Member Function Documentation

◆ adjustForOnlineAddonKart()

void KartProperties::adjustForOnlineAddonKart ( const KartProperties source)

Change the graphical properties (icon, shadow..) for addon kart using in online mode.

Parameters
sourceThe source kart properties from which to copy this objects' values.

◆ checkAllSet()

void KartProperties::checkAllSet ( const std::string &  filename)

Checks if all necessary physics values are indeed defines.

This helps finding bugs early, e.g. missing default in stk_config.dat file.

Parameters
filenameFile from which the data was read (only used to print meaningful error messages).

◆ copyForPlayer()

void KartProperties::copyForPlayer ( const KartProperties source,
HandicapLevel  h = HANDICAP_NONE 
)

Copies this KartProperties to another one.

Important: if you add any pointers to kart_properties, the data structure they are pointing to need to be copied here explicitely! The AIProperties won't get cloned here as they don't differ for each player. To clone this object for another kart use the copyFrom method.

Parameters
sourceThe source kart properties from which to copy this objects' values.

◆ copyFrom()

void KartProperties::copyFrom ( const KartProperties source)

Copies this KartProperties to another one.

Important: if you add any pointers to kart_properties, the data structure they are pointing to need to be copied here explicitely!

Parameters
sourceThe source kart properties from which to copy this objects' values.

◆ getAccelerationEfficiency()

float KartProperties::getAccelerationEfficiency ( ) const

This function returns a weighted average of engine power divide by mass for use as a single number summing-up acceleration's efficiency, e.g.

for use in kart selection.

◆ getAllData()

void KartProperties::getAllData ( const XMLNode root)

Actually reads in the data from the xml file.

Parameters
rootRoot of the xml tree.

◆ getCombinedCharacteristic()

const AbstractCharacteristic * KartProperties::getCombinedCharacteristic ( ) const

Returns the characteristics for this kart combined with the base characteristic.

This value isn't used for the race, because the difficulty is missing, but it can be used e.g. for the kart stats widget.

◆ getKartModelCopy()

KartModel * KartProperties::getKartModelCopy ( std::shared_ptr< GE::GERenderInfo >  ri = nullptr) const

Returns a pointer to the KartModel object.

Parameters
krtThe KartRenderType, like default, red, blue or transparent. see the RenderInfo include for details

◆ getMasterKartModel()

const KartModel & KartProperties::getMasterKartModel ( ) const
inline

Returns a pointer to the main KartModel object.

This copy should not be modified, not attachModel be called on it.

◆ getPhysicalWheelPosition()

const float KartProperties::getPhysicalWheelPosition ( ) const
inline

Returns position of the physical wheel is a weighted average of the two ends of the beveled shape.

This determines the weight: 0 = a the widest end, 1 = at the narrowest, front end. If the value is <0, the old physics position is picked, which placed the raycast wheels outside of the chassis, but gives more stable physics.

◆ load()

void KartProperties::load ( const std::string &  filename,
const std::string &  node 
)
private

Loads the kart properties from a file.

Parameters
filenameFilename to load.
nodeName of the xml node to load the data from

◆ setHatMeshName()

void KartProperties::setHatMeshName ( const std::string &  hat_name)

Sets the name of a mesh to be used for this kart.

Parameters
hat_nameName of the mesh.

Member Data Documentation

◆ m_ai_properties

std::shared_ptr<AIProperties> KartProperties::m_ai_properties[RaceManager::DIFFICULTY_COUNT]
private

AI Properties for this kart, as a separate object in order to reduce dependencies (and therefore compile time) when changing any AI property.

There is one separate object for each difficulty.

◆ m_characteristic

std::shared_ptr<AbstractCharacteristic> KartProperties::m_characteristic
private

The physical, item, etc.

characteristics of this kart that are loaded from the xml file.

◆ m_kart_model

std::shared_ptr<KartModel> KartProperties::m_kart_model
mutableprivate

The kart model and wheels.

It is mutable since the wheels of the KartModel can rotate and turn, and animations are played, but otherwise the kart_properties object is const.

◆ m_minimap_icon

video::ITexture* KartProperties::m_minimap_icon
private

The texture to use in the minimap.

If not defined, a simple color dot is used.

◆ m_physical_wheel_position

float KartProperties::m_physical_wheel_position
private

The position of the physical wheel is a weighted average of the two ends of the beveled shape.

This determines the weight: 0 = a the widest end, 1 = at the narrowest front end. If the value is < 0, the old physics settings are used which places the raycast wheels outside of the chassis - but result in a more stable physics behaviour (which is therefore atm still the default).


The documentation for this class was generated from the following files: