19#ifndef HEADER_KART_MODEL_HPP
20#define HEADER_KART_MODEL_HPP
24#include <unordered_map>
27#include <IAnimatedMeshSceneNode.h>
30 namespace scene {
class IAnimatedMesh;
class IMesh;
31 class ISceneNode;
class IMeshSceneNode; }
35#include "utils/no_copy.hpp"
36#include "utils/vec3.hpp"
40namespace GE {
class GERenderInfo; }
60 void loadFromXMLNode(
const XMLNode* xml_node);
69 scene::IAnimatedMeshSceneNode *
m_node;
88typedef std::vector<SpeedWeightedObject> SpeedWeightedObjectList;
123 HeadlightObject(
const std::string& filename,
const core::matrix4& location,
124 const std::string& bone_name,
const video::SColor& color)
134 const std::string& getFilename()
const {
return m_filename; }
139 void setLight(scene::ISceneNode* parent,
float energy,
float radius);
141 const scene::ISceneNode *getLightNode()
const {
return m_node; }
143 scene::ISceneNode *getLightNode() {
return m_node; }
145 const scene::IMesh *getModel()
const {
return m_model; }
147 scene::IMesh *getModel() {
return m_model; }
149 const core::matrix4& getLocation()
const {
return m_location; }
151 const std::string& getBoneName()
const {
return m_bone_name; }
170 enum AnimationFrameType
172 AF_DEFAULT = AF_BEGIN,
179 AF_LOSE_END_STRAIGHT,
194 AF_END=AF_BACK_RIGHT,
251 std::vector<HeadlightObject> m_headlight_objects;
295 const std::string &wheel_name,
int index);
298 const std::string &emitter_name,
int index);
302 void loadHeadlights(
const XMLNode &node);
330 void configNode(scene::ISceneNode* node,
const core::matrix4& global_mat,
331 const core::matrix4& inv_mat)
333 const core::matrix4 mat = inv_mat * global_mat;
334 const core::vector3df position = mat.getTranslation();
335 const core::vector3df rotation = mat.getRotationDegrees();
336 const core::vector3df scale = mat.getScale();
337 node->setPosition(position);
338 node->setRotation(rotation);
339 node->setScale(scale);
349 void setDefaultSuspension();
350 void update(
float dt,
float distance,
float steer,
float speed,
351 float current_lean_angle,
352 int gt_replay_index = -1);
356 attachModel(
bool animatedModels,
bool human_player);
359 scene::IAnimatedMesh*
430 void setAnimation(AnimationFrameType type,
bool play_non_loop =
false);
441 scene::IAnimatedMeshSceneNode* getAnimatedNode(){
return m_animated_node; }
443 std::shared_ptr<GE::GERenderInfo> getRenderInfo();
447 void toggleHeadlights(
bool on);
450 getInverseBoneMatrix(
const std::string& bone_name)
const;
452 const std::string& getExhaustXML()
const {
return m_exhaust_xml; }
457 {
return m_kart_properties; }
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
A class to store the headlights of a kart.
Definition: kart_model.hpp:94
video::SColor m_headlight_color
The color of the real light.
Definition: kart_model.hpp:110
scene::IMesh * m_model
The mesh for the headlight.
Definition: kart_model.hpp:104
std::string m_filename
The filename of the headlight model.
Definition: kart_model.hpp:97
void setLight(scene::ISceneNode *parent, float energy, float radius)
Add a light node emitted from the center mass the headlight.
Definition: kart_model.cpp:554
core::matrix4 m_location
The relative matrix to the parent kart scene node where the headlight mesh is attached to.
Definition: kart_model.hpp:101
std::string m_bone_name
Attach to which bone in kart model if not empty.
Definition: kart_model.hpp:113
scene::ISceneNode * m_node
The scene node of the headlight (real light).
Definition: kart_model.hpp:107
void setModel(scene::IMesh *mesh)
Sets the mesh for this headlight object.
Definition: kart_model.hpp:137
This class stores a 3D kart model.
Definition: kart_model.hpp:168
const Vec3 * getWheelsGraphicsPosition() const
Returns the position of wheels relative to the kart.
Definition: kart_model.hpp:383
AnimationFrameType m_current_animation
Which animation is currently being played.
Definition: kart_model.hpp:272
void loadNitroEmitterInfo(const XMLNode &node, const std::string &emitter_name, int index)
Loads a single nitro emitter node.
Definition: kart_model.cpp:765
std::string m_model_filename
Name of the 3d model file.
Definition: kart_model.hpp:225
Vec3 m_wheel_graphics_position[4]
The position of all four wheels in the 3d model.
Definition: kart_model.hpp:237
void reset()
Resets the kart model.
Definition: kart_model.cpp:874
const SpeedWeightedObject & getSpeedWeightedObject(int i) const
Returns the position of a speed weighted object relative to the kart.
Definition: kart_model.hpp:408
int getBaseFrame() const
Since karts might be animated, we might need to know which base frame to use.
Definition: kart_model.hpp:369
float m_default_physics_suspension[4]
Length of the physics suspension when the kart is at rest.
Definition: kart_model.hpp:254
float m_kart_width
Width of kart.
Definition: kart_model.hpp:275
void initInverseBoneMatrices()
Called when a kart is load.
Definition: kart_model.cpp:1290
std::unordered_map< std::string, core::matrix4 > m_inverse_bone_matrices
Used to cache inverse bone matrices for each bone in straight frame for attachment.
Definition: kart_model.hpp:318
void update(float dt, float distance, float steer, float speed, float current_lean_angle, int gt_replay_index=-1)
Rotates and turns the wheels appropriately, and adjust for suspension updates the speed-weighted obje...
Definition: kart_model.cpp:1083
float getWheelGraphicsRadius(unsigned int i) const
Returns the radius of the graphical wheels.
Definition: kart_model.hpp:389
core::matrix4 * m_hat_location
Location of hat in object space.
Definition: kart_model.hpp:213
SpeedWeightedObjectList m_speed_weighted_objects
The speed weighted objects.
Definition: kart_model.hpp:249
scene::IMesh * getWheelModel(const int i) const
Returns the mesh of the wheel for this kart.
Definition: kart_model.hpp:364
float getHeight() const
Returns the height of the kart.
Definition: kart_model.hpp:418
float m_dampen_suspension_amplitude[4]
value used to divide the visual movement of wheels (because the actual movement of wheels in bullet i...
Definition: kart_model.hpp:267
unsigned m_version
Version of kart model (in kart.xml).
Definition: kart_model.hpp:321
bool loadModels(const KartProperties &kart_properties)
Loads the 3d model and all wheels.
Definition: kart_model.cpp:567
int m_animation_frame[AF_COUNT]
Which frame number starts/end which animation.
Definition: kart_model.hpp:199
AbstractKart * m_kart
Pointer to the kart object belonging to this kart model.
Definition: kart_model.hpp:307
size_t getSpeedWeightedObjectsCount() const
Returns the number of speed weighted objects for this kart.
Definition: kart_model.hpp:403
float getWidth() const
Returns the width of the kart model.
Definition: kart_model.hpp:415
scene::IAnimatedMesh * getModel() const
Returns the animated mesh of this kart model.
Definition: kart_model.hpp:360
std::string m_wheel_filename[4]
Filename of the wheel models.
Definition: kart_model.hpp:234
bool m_has_nitro_emitter
True if kart has nitro emitters.
Definition: kart_model.hpp:246
float m_kart_lowest_point
Smallest coordinate on up axis.
Definition: kart_model.hpp:287
bool m_is_master
True if this is the master copy, managed by KartProperties.
Definition: kart_model.hpp:292
float m_kart_height
Height of kart.
Definition: kart_model.hpp:281
std::shared_ptr< GE::GERenderInfo > m_render_info
For our engine to get the desired hue for colorization.
Definition: kart_model.hpp:310
const bool hasNitroEmitters() const
Returns true if kart has nitro emitters.
Definition: kart_model.hpp:399
void resetVisualWheelPosition()
Called when a kart is rescued to reset all visual wheels to their default position to avoid that some...
Definition: kart_model.cpp:1253
float m_kart_length
Length of kart.
Definition: kart_model.hpp:278
AnimationFrameType getAnimation()
Returns information about currently played animation.
Definition: kart_model.hpp:427
float m_min_suspension[4]
Minimum suspension length (i.e.
Definition: kart_model.hpp:258
float getHighestPoint() const
Highest coordinate on up axis.
Definition: kart_model.hpp:421
void setAnimation(AnimationFrameType type, bool play_non_loop=false)
Enables- or disables the end animation.
Definition: kart_model.cpp:914
bool m_support_colorization
True if this kart model can be colorization in red / blue (now only used in soccer mode).
Definition: kart_model.hpp:314
void setHatMeshName(const std::string &name)
Name of the hat mesh to use.
Definition: kart_model.hpp:436
void loadWheelInfo(const XMLNode &node, const std::string &wheel_name, int index)
Loads a single wheel node.
Definition: kart_model.cpp:822
scene::IMesh * m_wheel_model[4]
The four wheel models.
Definition: kart_model.hpp:228
float m_max_suspension[4]
Maximum suspension length (i.e.
Definition: kart_model.hpp:263
float getLength() const
Returns the length of the kart model.
Definition: kart_model.hpp:412
Vec3 m_nitro_emitter_position[2]
The position of the nitro emitters.
Definition: kart_model.hpp:243
static float UNDEFINED
Value used to indicate undefined entries.
Definition: kart_model.hpp:222
float m_wheel_graphics_radius[4]
Radius of the graphical wheels.
Definition: kart_model.hpp:240
void loadInfo(const XMLNode &node)
This function loads the information about the kart from a xml file.
Definition: kart_model.cpp:145
KartModel * makeCopy(std::shared_ptr< GE::GERenderInfo > ri)
This function returns a copy of this object.
Definition: kart_model.cpp:322
void setKart(AbstractKart *k)
Sets the kart this model is currently used for.
Definition: kart_model.hpp:433
std::string m_hat_bone
Name of the bone for hat attachment.
Definition: kart_model.hpp:216
void finishedRace()
Called when the kart finished the race.
Definition: kart_model.cpp:902
scene::ISceneNode * m_wheel_node[4]
The four scene nodes the wheels are attached to.
Definition: kart_model.hpp:231
void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node)
Called from irrlicht when a non-looped animation ends.
Definition: kart_model.cpp:1024
const Vec3 & getWheelGraphicsPosition(unsigned int i) const
Returns the position of a wheel relative to the kart.
Definition: kart_model.hpp:378
void loadSpeedWeightedInfo(const XMLNode *speed_weighted_node)
Loads a single speed weighted node.
Definition: kart_model.cpp:787
std::string m_hat_name
Name of the hat to use for this kart.
Definition: kart_model.hpp:219
float m_kart_highest_point
Largest coordinate on up axis.
Definition: kart_model.hpp:284
float getLowestPoint() const
Lowest coordinate on up axis.
Definition: kart_model.hpp:424
scene::ISceneNode ** getWheelNodes()
Returns the array of wheel nodes.
Definition: kart_model.hpp:439
scene::IAnimatedMesh * m_mesh
The mesh of the model.
Definition: kart_model.hpp:205
const Vec3 & getNitroEmittersPositon(unsigned int i) const
Returns the position of nitro emitter relative to the kart.
Definition: kart_model.hpp:395
scene::ISceneNode * attachModel(bool animatedModels, bool human_player)
Attach the kart model and wheels to the scene node.
Definition: kart_model.cpp:400
scene::IAnimatedMeshSceneNode * m_animated_node
This is a pointer to the scene node of the kart this model belongs to.
Definition: kart_model.hpp:210
float m_animation_speed
Animation speed.
Definition: kart_model.hpp:202
std::string m_exhaust_xml
Exhaust particle file (xml) for the kart, empty if disabled.
Definition: kart_model.hpp:324
~KartModel()
Destructor.
Definition: kart_model.cpp:233
This class stores the properties of a kart.
Definition: kart_properties.hpp:60
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48
Parameters for a speed-weighted object.
Definition: kart_model.hpp:48
core::vector2df m_texture_speed
Texture speed, in UV coordinates.
Definition: kart_model.hpp:58
float m_strength_factor
Strength factor: how much the kart speed affects the animation's distance from a static pose (-1 to d...
Definition: kart_model.hpp:52
float m_speed_factor
Speed factor: how much the kart speed affects the animation's speed (-1 to disable)
Definition: kart_model.hpp:55
A speed-weighted object is an object whose characteristics are influenced by the kart's speed.
Definition: kart_model.hpp:45
std::string m_name
Filename of the "speed weighted" object.
Definition: kart_model.hpp:76
scene::IAnimatedMesh * m_model
Model.
Definition: kart_model.hpp:66
core::matrix4 m_location
The relative matrix to the parent kart scene node where the speed weighted object is attached to.
Definition: kart_model.hpp:73
std::string m_bone_name
Attach to which bone in kart model if not empty.
Definition: kart_model.hpp:79
Properties m_properties
Specific properties for this given speed-weighted object, otherwise just a copy of the values from th...
Definition: kart_model.hpp:86
core::vector2df m_texture_cur_offset
Current uv translation in the texture matrix for speed-weighted texture animations.
Definition: kart_model.hpp:82
scene::IAnimatedMeshSceneNode * m_node
The scene node the speed weighted model is attached to.
Definition: kart_model.hpp:69