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" 60 void loadFromXMLNode(
const XMLNode* xml_node);
69 scene::IAnimatedMeshSceneNode *
m_node;
88 typedef std::vector<SpeedWeightedObject> SpeedWeightedObjectList;
123 HeadlightObject(
const std::string& filename,
const core::matrix4& location,
124 const std::string& bone_name,
const video::SColor& color)
126 m_filename = filename;
127 m_location = location;
130 m_bone_name = bone_name;
131 m_headlight_color = color;
134 const std::string& getFilename()
const {
return m_filename; }
137 void setModel(scene::IMesh *mesh) { m_model = mesh; }
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,
199 int m_animation_frame[AF_COUNT];
228 scene::IMesh *m_wheel_model[4];
231 scene::ISceneNode *m_wheel_node[4];
234 std::string m_wheel_filename[4];
237 Vec3 m_wheel_graphics_position[4];
240 float m_wheel_graphics_radius[4];
243 Vec3 m_nitro_emitter_position[2];
251 std::vector<HeadlightObject> m_headlight_objects;
254 float m_default_physics_suspension[4];
258 float m_min_suspension[4];
263 float m_max_suspension[4];
267 float m_dampen_suspension_amplitude[4];
294 void loadWheelInfo(
const XMLNode &node,
295 const std::string &wheel_name,
int index);
297 void loadNitroEmitterInfo(
const XMLNode &node,
298 const std::string &emitter_name,
int index);
300 void loadSpeedWeightedInfo(
const XMLNode* speed_weighted_node);
302 void loadHeadlights(
const XMLNode &node);
304 void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node);
328 void initInverseBoneMatrices();
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);
345 KartModel* makeCopy(std::shared_ptr<RenderInfo> ri);
347 void loadInfo(
const XMLNode &node);
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);
354 void resetVisualWheelPosition();
356 attachModel(
bool animatedModels,
bool human_player);
359 scene::IAnimatedMesh*
365 { assert(i>=0 && i<4);
return m_wheel_model[i]; }
371 int getFrame(AnimationFrameType f)
const {
return m_animation_frame[f]; }
373 float getAnimationSpeed()
const {
return m_animation_speed; }
379 {assert(i<4);
return m_wheel_graphics_position[i];}
384 {
return m_wheel_graphics_position;}
390 {assert(i<4);
return m_wheel_graphics_radius[i]; }
396 { assert(i<2);
return m_nitro_emitter_position[i]; }
400 {
return m_has_nitro_emitter;}
404 {
return m_speed_weighted_objects.size();}
409 {
return m_speed_weighted_objects[i];}
430 void setAnimation(AnimationFrameType type,
bool play_non_loop =
false);
441 scene::IAnimatedMeshSceneNode* getAnimatedNode(){
return m_animated_node; }
443 std::shared_ptr<RenderInfo> getRenderInfo();
445 bool supportColorization()
const {
return m_support_colorization; }
447 void toggleHeadlights(
bool on);
450 getInverseBoneMatrix(
const std::string& bone_name)
const;
452 const std::string& getExhaustXML()
const {
return m_exhaust_xml; }
454 bool hasWheel()
const {
return !m_wheel_filename[0].empty(); }
457 {
return m_kart_properties; }
static float UNDEFINED
Value used to indicate undefined entries.
Definition: kart_model.hpp:222
SpeedWeightedObjectList m_speed_weighted_objects
The speed weighted objects.
Definition: kart_model.hpp:249
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
std::shared_ptr< RenderInfo > m_render_info
For our engine to get the desired hue for colorization.
Definition: kart_model.hpp:310
AnimationFrameType m_current_animation
Which animation is currently being played.
Definition: kart_model.hpp:272
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
float getWidth() const
Returns the width of the kart model.
Definition: kart_model.hpp:415
const bool hasNitroEmitters() const
Returns true if kart has nitro emitters.
Definition: kart_model.hpp:399
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
float m_speed_factor
Speed factor: how much the kart speed affects the animation's speed (-1 to disable) ...
Definition: kart_model.hpp:55
core::matrix4 * m_hat_location
Location of hat in object space.
Definition: kart_model.hpp:213
size_t getSpeedWeightedObjectsCount() const
Returns the number of speed weighted objects for this kart.
Definition: kart_model.hpp:403
float m_kart_width
Width of kart.
Definition: kart_model.hpp:275
float m_kart_lowest_point
Smallest coordinate on up axis.
Definition: kart_model.hpp:287
std::string m_filename
The filename of the headlight model.
Definition: kart_model.hpp:97
A speed-weighted object is an object whose characteristics are influenced by the kart's speed...
Definition: kart_model.hpp:44
float m_animation_speed
Animation speed.
Definition: kart_model.hpp:202
float getWheelGraphicsRadius(unsigned int i) const
Returns the radius of the graphical wheels.
Definition: kart_model.hpp:389
std::string m_model_filename
Name of the 3d model file.
Definition: kart_model.hpp:225
Definition: three_d_animation.hpp:32
float m_kart_height
Height of kart.
Definition: kart_model.hpp:281
std::string m_hat_name
Name of the hat to use for this kart.
Definition: kart_model.hpp:219
core::vector2df m_texture_speed
Texture speed, in UV coordinates.
Definition: kart_model.hpp:58
const Vec3 & getWheelGraphicsPosition(unsigned int i) const
Returns the position of a wheel relative to the kart.
Definition: kart_model.hpp:378
AbstractKart * m_kart
Pointer to the kart object belonging to this kart model.
Definition: kart_model.hpp:307
void setModel(scene::IMesh *mesh)
Sets the mesh for this headlight object.
Definition: kart_model.hpp:137
scene::IAnimatedMesh * getModel() const
Returns the animated mesh of this kart model.
Definition: kart_model.hpp:360
float m_kart_highest_point
Largest coordinate on up axis.
Definition: kart_model.hpp:284
bool m_has_nitro_emitter
True if kart has nitro emitters.
Definition: kart_model.hpp:246
SimpleVec3 getLocation(int idKart)
Attempts to project kart to the given 2D location, to the position with height 0, at a 45 degree angl...
Definition: script_kart.cpp:110
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
scene::IMesh * m_model
The mesh for the headlight.
Definition: kart_model.hpp:104
This class stores a 3D kart model.
Definition: kart_model.hpp:167
float getHeight() const
Returns the height of the kart.
Definition: kart_model.hpp:418
video::SColor m_headlight_color
The color of the real light.
Definition: kart_model.hpp:110
scene::IAnimatedMeshSceneNode * m_node
The scene node the speed weighted model is attached to.
Definition: kart_model.hpp:69
void setHatMeshName(const std::string &name)
Name of the hat mesh to use.
Definition: kart_model.hpp:436
std::string m_name
Filename of the "speed weighted" object.
Definition: kart_model.hpp:76
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
core::vector2df m_texture_cur_offset
Current uv translation in the texture matrix for speed-weighted texture animations.
Definition: kart_model.hpp:82
This class stores the properties of a kart.
Definition: kart_properties.hpp:59
std::string m_exhaust_xml
Exhaust particle file (xml) for the kart, empty if disabled.
Definition: kart_model.hpp:324
utility class used to parse XML files
Definition: xml_node.hpp:47
const Vec3 * getWheelsGraphicsPosition() const
Returns the position of wheels relative to the kart.
Definition: kart_model.hpp:383
scene::IAnimatedMesh * m_model
Model.
Definition: kart_model.hpp:66
float m_kart_length
Length of kart.
Definition: kart_model.hpp:278
float getLength() const
Returns the length of the kart model.
Definition: kart_model.hpp:412
const Vec3 & getNitroEmittersPositon(unsigned int i) const
Returns the position of nitro emitter relative to the kart.
Definition: kart_model.hpp:395
scene::IMesh * getWheelModel(const int i) const
Returns the mesh of the wheel for this kart.
Definition: kart_model.hpp:364
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
Definition: render_info.hpp:27
float getLowestPoint() const
Lowest coordinate on up axis.
Definition: kart_model.hpp:424
std::string m_bone_name
Attach to which bone in kart model if not empty.
Definition: kart_model.hpp:113
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
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
AnimationFrameType getAnimation()
Returns information about currently played animation.
Definition: kart_model.hpp:427
void setKart(AbstractKart *k)
Sets the kart this model is currently used for.
Definition: kart_model.hpp:433
float getHighestPoint() const
Highest coordinate on up axis.
Definition: kart_model.hpp:421
const SpeedWeightedObject & getSpeedWeightedObject(int i) const
Returns the position of a speed weighted object relative to the kart.
Definition: kart_model.hpp:408
std::string m_bone_name
Attach to which bone in kart model if not empty.
Definition: kart_model.hpp:79
scene::IAnimatedMesh * m_mesh
The mesh of the model.
Definition: kart_model.hpp:205
unsigned m_version
Version of kart model (in kart.xml).
Definition: kart_model.hpp:321
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
bool m_is_master
True if this is the master copy, managed by KartProperties.
Definition: kart_model.hpp:292
scene::ISceneNode ** getWheelNodes()
Returns the array of wheel nodes.
Definition: kart_model.hpp:439
std::string m_hat_bone
Name of the bone for hat attachment.
Definition: kart_model.hpp:216
scene::ISceneNode * m_node
The scene node of the headlight (real light).
Definition: kart_model.hpp:107
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
A class to store the headlights of a kart.
Definition: kart_model.hpp:93
Parameters for a speed-weighted object.
Definition: kart_model.hpp:47
int getBaseFrame() const
Since karts might be animated, we might need to know which base frame to use.
Definition: kart_model.hpp:369