20#ifndef HEADER_TRACK_HPP
21#define HEADER_TRACK_HPP
43 class IMesh;
class ISceneNode;
47 class IImage;
class ITexture;
53#include "LinearMath/btTransform.h"
55#include "utils/aligned_array.hpp"
56#include "utils/log.hpp"
57#include "utils/vec3.hpp"
58#include "utils/stk_process.hpp"
61class AnimationManager;
77const int HEIGHT_MAP_RESOLUTION = 256;
83 core::vector3df m_position;
84 std::string m_challenge_id;
88 m_position = position;
89 m_challenge_id = challenge_id;
99 Subtitle(
int from,
int to, core::stringw text)
105 int getFrom()
const {
return m_from; }
106 int getTo()
const {
return m_to; }
107 const core::stringw& getText()
const {
return m_text; }
122 unsigned int m_magic_number;
132 std::string m_screenshot;
134 std::vector<MusicInformation*> m_music;
135 unsigned m_music_idx;
140 std::vector<Subtitle> m_subtitles;
146 std::string m_item_style;
147 std::string m_description;
148 core::stringw m_designer;
157 std::vector<std::string> m_groups;
199 std::vector<video::ITexture*> m_old_textures;
205 std::vector<std::string> m_old_mesh_buffers;
208 scene::ISceneNode *m_sun;
224 btTransform m_red_flag;
225 btTransform m_blue_flag;
266 enum {SKY_NONE, SKY_BOX,
267 SKY_COLOR} m_sky_type;
276 std::vector<void*> m_spherical_harmonics_textures;
306 std::string m_weather_sound;
318 unsigned int m_magic_number;
326 m_magic_number = 0x46825179;
333 assert(m_magic_number == 0x46825179);
334 m_magic_number = 0xDEADBEEF;
363 float m_fog_height_start;
364 float m_fog_height_end;
365 core::vector3df m_sun_position;
368 video::SColor m_default_ambient_color;
369 video::SColor m_sun_specular_color;
370 video::SColor m_sun_diffuse_color;
371 video::SColor m_fog_color;
376 std::shared_ptr<ItemManager> m_item_manager;
377 float m_minimap_x_scale;
378 float m_minimap_y_scale;
381 float m_bloom_threshold;
384 core::vector3df m_godrays_position;
385 float m_godrays_opacity;
386 video::SColor m_godrays_color;
390 float m_displacement_speed;
391 int m_physical_object_uid;
393 bool m_minimap_invert_x_z;
399 core::vector2df m_color_outlevel;
404 std::vector<std::pair<TrackObject*, TrackObject*> > m_meta_library;
413 void loadTrackInfo();
416 btQuaternion getArenaStartRotation(
const Vec3& xyz,
float heading);
421 std::vector<MusicInformation*>& m_music );
424 void freeCachedMeshVertexBuffer();
425 void copyFromMainProcess();
426 video::IImage* getSkyTexture(std::string path)
const;
433 ProcessType type = STKProcess::getType();
434 return m_current_track[type];
440 child_track->copyFromMainProcess();
444 void initChildTrack();
446 static void cleanChildTrack();
458 static const float NOHIT;
460 Track (
const std::string &filename);
467 bool for_height_map);
477 bool isInGroup(
const std::string &group_name);
484 bool secondary_hits=
true)
const;
486 unsigned int mode_id=0);
489 std::vector< std::vector<float> > buildHeightMap();
490 void drawMiniMap(
const core::rect<s32>& dest_rect)
const;
491 void updateMiniMapScale();
496 bool isCTF()
const {
return m_is_ctf; }
502 return !m_internal && !m_is_arena && !m_is_soccer;
514 void loadObjects(
const XMLNode* root,
const std::string& path,
516 scene::ISceneNode* parent,
TrackObject* parent_library);
518 bool isSoccer ()
const {
return m_is_soccer; }
521 {m_music.push_back(mi); }
523 float getGravity ()
const {
return m_gravity; }
529 float getTrackLength ()
const;
532 const std::string&
getIdent ()
const {
return m_ident; }
535 const std::vector<std::string>&
557 if (index >= m_start_transforms.size())
558 Log::fatal(
"Track",
"No start position for kart %i.", index);
559 return m_start_transforms[index];
566 std::random_shuffle(m_start_transforms.begin(), m_start_transforms.end());
571 { *min = &m_aabb_min; *max = &m_aabb_max; }
579 float getAngle(
int n)
const;
587 void mapPoint2MiniMap(
const Vec3 &xyz,
Vec3 *draw_at)
const;
591 {
return m_root+
"/"+s; }
597 unsigned int getNumOfCompletedChallenges();
601 {
return m_all_modes[i].m_name; }
605 {
return m_default_ambient_color; }
612 const TriangleMesh& getTriangleMesh()
const {
return *m_track_mesh; }
619 {
return m_max_arena_players; }
623 {
return (
unsigned int)m_start_transforms.size(); }
625 bool getWeatherLightning() {
return m_weather_lightning;}
627 const std::string& getWeatherSound() {
return m_weather_sound;}
629 ParticleKind* getSkyParticles () {
return m_sky_particles; }
638 return !m_force_disable_fog && m_use_fog;
642 float getFogStart()
const {
return m_fog_start; }
644 void setFogStart(
float start) { m_fog_start = start; }
646 float getFogEnd()
const {
return m_fog_end; }
648 void setFogEnd(
float end) { m_fog_end = end; }
650 float getFogStartHeight()
const {
return m_fog_height_start; }
652 float getFogEndHeight()
const {
return m_fog_height_end; }
654 float getFogMax()
const {
return m_fog_max; }
656 void setFogMax(
float max) { m_fog_max = max; }
658 video::SColor getFogColor()
const {
return m_fog_color; }
660 void setFogColor(video::SColor& color) { m_fog_color = color; }
662 video::SColor getSunColor()
const {
return m_sun_diffuse_color; }
680 return m_track_object_manager;
686 {
return m_challenges; }
689 const std::vector<Subtitle>& getSubtitles()
const {
return m_subtitles; }
692 bool hasBloom()
const {
return m_bloom; }
695 float getBloomThreshold()
const {
return m_bloom_threshold; }
701 core::vector2df getColorLevelOut()
const {
return m_color_outlevel; }
703 bool hasGodRays()
const {
return m_godrays; }
705 core::vector3df getGodRaysPosition()
const {
return m_godrays_position; }
707 float getGodRaysOpacity()
const {
return m_godrays_opacity; }
709 video::SColor getGodRaysColor()
const {
return m_godrays_color; }
711 bool hasShadows()
const {
return m_shadows; }
713 void addNode(scene::ISceneNode* node) { m_all_nodes.push_back(node); }
715 void addPhysicsOnlyNode(scene::ISceneNode* node)
717 m_object_physics_only_nodes.push_back(node);
720 float getDisplacementSpeed()
const {
return m_displacement_speed; }
722 int getPhysicalObjectUID() {
return m_physical_object_uid++; }
724 const int getDefaultNumberOfLaps()
const {
return m_default_number_of_laps;}
726 const int getActualNumberOfLap()
const {
return m_actual_number_of_laps; }
728 void setActualNumberOfLaps(
unsigned int laps)
729 { m_actual_number_of_laps = laps; }
734 void addCachedMesh(scene::IMesh* mesh) { m_all_cached_meshes.push_back(mesh); }
738 { m_meta_library.emplace_back(parent, meta_library); }
740 const btTransform& getRedFlag()
const {
return m_red_flag; }
742 const btTransform& getBlueFlag()
const {
return m_blue_flag; }
744 bool isAddon()
const {
return m_is_addon; }
748 CheckManager* getCheckManager()
const {
return m_check_manager; }
750 ItemManager* getItemManager()
const {
return m_item_manager.get(); }
752 bool isOnGround(
const Vec3& xyz,
const Vec3& down,
Vec3* hit_point,
753 Vec3* normal,
bool print_warning =
true);
757 if (m_music_idx < m_music.size())
758 return m_music[m_music_idx];
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
A class to manage bezier curves and interpolation.
Definition: bezier_curve.hpp:34
Controls all checks structures of a track.
Definition: check_manager.hpp:40
Definition: item_manager.hpp:47
Utility class to load level-of-detail nodes and library nodes.
Definition: model_definition_loader.hpp:81
Handles animated textures (textures that move)
Definition: moving_texture.hpp:34
manages smoke particle effects
Definition: particle_emitter.hpp:42
type of particles
Definition: particle_kind.hpp:42
Definition: physical_object.hpp:40
Definition: render_target.hpp:42
Definition: track_object_manager.hpp:39
This is a base object for any separate object on the track, which might also have a skeletal animatio...
Definition: track_object.hpp:56
A simple class to keep information about a track mode.
Definition: track.hpp:310
std::string m_quad_name
Name of the quad file to use.
Definition: track.hpp:313
std::string m_graph_name
Name of the graph file to use.
Definition: track.hpp:314
TrackMode()
Default constructor, sets default names for all fields.
Definition: track.hpp:322
std::string m_scene
Name of the scene file to use.
Definition: track.hpp:315
std::string m_name
Name / description of this mode.
Definition: track.hpp:312
Definition: track.hpp:114
int getVersion() const
Returns the version of the .track file.
Definition: track.hpp:526
std::vector< scene::IMesh * > m_all_cached_meshes
The list of all meshes that are loaded from disk, which means that those meshes are being cached by i...
Definition: track.hpp:173
std::vector< BezierCurve * > m_all_curves
List of all bezier curves in the track - for e.g.
Definition: track.hpp:402
irr::video::SColor m_sky_color
Used if m_sky_type is SKY_COLOR only.
Definition: track.hpp:279
const std::string & getModeName(unsigned int i) const
Returns the name of the i-th.
Definition: track.hpp:600
void setAmbientColor(const video::SColor &color, unsigned int k)
Sets the current ambient color for a kart with index k.
RenderTarget * m_render_target
The render target for the mini map, which is displayed in the race gui.
Definition: track.hpp:374
void update(int ticks)
Update, called once per physics time step.
Definition: track.cpp:1669
TriangleMesh * m_gfx_effect_mesh
Used to collect the triangles which do not have a physical representation, but are needed for some ra...
Definition: track.hpp:219
void cleanup()
Removes the physical body from the world.
Definition: track.cpp:315
void loadTrackModel(bool reverse_track=false, unsigned int mode_id=0)
This function load the actual scene, i.e.
Definition: track.cpp:1835
void loadDriveGraph(unsigned int mode_id, const bool reverse)
Loads the drive graph, i.e.
Definition: track.cpp:800
void getAABB(const Vec3 **min, const Vec3 **max) const
Sets pointer to the aabb of this track.
Definition: track.hpp:570
void loadCurves(const XMLNode &node)
Loads all curves from the XML node.
Definition: track.cpp:665
void shuffleStartTransforms()
Shuffles the start transformations.
Definition: track.hpp:564
TrackObjectManager * m_track_object_manager
Manager for all track objects.
Definition: track.hpp:285
const std::string & getIdent() const
Returns a unique identifier for this track (the directory name).
Definition: track.hpp:532
int m_actual_number_of_laps
The number of laps that is predefined in a track info dialog.
Definition: track.hpp:411
unsigned int m_max_arena_players
Max players supported by an arena.
Definition: track.hpp:230
core::stringw getSortName() const
Returns the name of the track used to sort the tracks alphabetically.
Definition: track.cpp:243
float m_sky_sphere_percent
If a sky dome is used, percentage of the sphere to be used.
Definition: track.hpp:296
bool reverseAvailable() const
Returns true if this race can be driven in reverse.
Definition: track.hpp:509
static bool m_dont_load_navmesh
Flag to avoid loading navmeshes (useful to speedup debugging: e.g.
Definition: track.hpp:453
TrackObjectManager * getTrackObjectManager() const
Returns the track object manager.
Definition: track.hpp:678
std::vector< scene::ISceneNode * > m_static_physics_only_nodes
The list of all nodes that are to be converted into physics, but not to be drawn (e....
Definition: track.hpp:164
std::string getTrackFile(const std::string &s) const
Returns the full path of a given file inside this track directory.
Definition: track.hpp:590
void addMetaLibrary(TrackObject *parent, TrackObject *meta_library)
Adds the parent of the meta library for correction later.
Definition: track.hpp:737
bool m_force_disable_fog
Can be set to force fog off (e.g.
Definition: track.hpp:353
const core::vector3df & getSunRotation()
Returns the rotation of the sun.
Definition: track.cpp:2805
unsigned int getNumberOfStartPositions() const
Get the number of start positions defined in the scene file.
Definition: track.hpp:622
unsigned int getNumberOfModes() const
Returns the number of modes available for this track.
Definition: track.hpp:594
void updateGraphics(float dt)
This updates all only graphical elements.
Definition: track.cpp:1653
bool m_smooth_normals
True if this track supports using smoothed normals.
Definition: track.hpp:356
bool isPushBackEnabled() const
True if push back of karts towards the track should be enabled.
Definition: track.hpp:672
core::vector3df m_color_inlevel
The levels for color correction m_color_inlevel(black, gamma, white) m_color_outlevel(black,...
Definition: track.hpp:398
void itemCommand(const XMLNode *node)
Handle creation and placement of an item.
Definition: track.cpp:2665
void forceFogDisabled(bool v)
Override track fog value to force disabled.
Definition: track.hpp:632
void startMusic() const
Select and set the music for this track (doesn't actually start it yet).
Definition: track.cpp:726
std::vector< MovingTexture * > m_animated_textures
The list of all animated textures.
Definition: track.hpp:282
bool smoothNormals() const
Returns true if the normals of this track can be smoothed.
Definition: track.hpp:675
bool m_cache_track
True if this track (textures and track data) should be cached.
Definition: track.hpp:191
Vec3 m_aabb_min
Minimum coordinates of this track.
Definition: track.hpp:221
bool isInternal() const
Whether this is an "internal" track.
Definition: track.hpp:666
void convertTrackToBullet(scene::ISceneNode *node)
Convert the graohics track into its physics equivalents.
Definition: track.cpp:943
int m_sky_vert_segments
If a sky dome is used, the number of vertical segments the sphere should be divided in.
Definition: track.hpp:293
bool m_enable_push_back
If true any collision of a kart with the track will push the kart towards the nearest driveline.
Definition: track.hpp:263
std::vector< TrackMode > m_all_modes
List of all modes for a track.
Definition: track.hpp:341
const bool getIsDuringDay() const
Returns if the track is during day time.
Definition: track.hpp:548
std::vector< scene::ISceneNode * > m_object_physics_only_nodes
Same concept but for track objects.
Definition: track.hpp:169
AlignedArray< btTransform > m_start_transforms
Start transforms of karts (either the default, or the ones taken from the scene file).
Definition: track.hpp:144
bool operator<(const Track &other) const
A < comparison of tracks.
Definition: track.cpp:210
TriangleMesh * m_track_mesh
Used to collect the triangles for the bullet mesh.
Definition: track.hpp:210
void getMusicInformation(std::vector< std::string > &filenames, std::vector< MusicInformation * > &m_music)
Loads all music information for the specified files (which is taken from the track....
Definition: track.cpp:681
std::vector< void * > m_sky_textures
A list of the textures for the sky to use.
Definition: track.hpp:274
bool m_reverse_available
Whether this track should be available in reverse version.
Definition: track.hpp:253
float m_sky_dx
sky rotation speed
Definition: track.hpp:270
const video::SColor & getDefaultAmbientColor() const
Returns the default ambient color.
Definition: track.hpp:604
bool m_enable_auto_rescue
If true a player kart will automatically be rescued if it is e.g.
Definition: track.hpp:257
void handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml)
Handles animated textures.
Definition: track.cpp:1566
bool m_has_easter_eggs
True if this track has easter eggs.
Definition: track.hpp:232
core::stringw m_sort_name
The name used in sorting the track.
Definition: track.hpp:347
void removeCachedData()
Removes all cached data structures.
Definition: track.cpp:292
const std::string & getFilename() const
Returns the filename of this track.
Definition: track.hpp:539
bool isRaceTrack() const
Returns true if this track is a racing track.
Definition: track.hpp:500
bool m_materials_loaded
True if the materials.xml file is already loaded.
Definition: track.hpp:187
ParticleKind * m_sky_particles
Particles emitted from the sky (wheather)
Definition: track.hpp:302
const core::stringw & getDesigner() const
Returns the name of the designer.
Definition: track.hpp:542
bool m_use_fog
True if the track uses fog.
Definition: track.hpp:350
bool m_internal
Whether this is an "internal" track.
Definition: track.hpp:250
std::vector< video::ITexture * > m_all_cached_textures
A list of all textures loaded by the track, so that they can be removed from the cache at cleanup tim...
Definition: track.hpp:183
void createWater(const XMLNode &node)
Creates a water node.
Definition: track.cpp:1711
std::vector< scene::ISceneNode * > m_all_nodes
The list of all nodes.
Definition: track.hpp:160
bool isInGroup(const std::string &group_name)
Returns true if this track belongs to the specified track group.
Definition: track.cpp:259
int m_default_number_of_laps
The number of laps the track will be raced in a random GP.
Definition: track.hpp:408
bool isArena() const
Returns true if this track has an arena mode.
Definition: track.hpp:494
bool isFogEnabled() const
Returns if fog is currently enabled.
Definition: track.hpp:636
bool m_weather_lightning
Use a special built-in wheather.
Definition: track.hpp:305
const bool getMinimapInvert() const
Returns if invert minimap.
Definition: track.hpp:551
bool m_is_soccer
True if this track is a soccer arena.
Definition: track.hpp:236
std::string m_name
Name of the track to display.
Definition: track.hpp:344
static std::atomic< Track * > m_current_track[PT_COUNT]
If a race is in progress, this stores the active track object.
Definition: track.hpp:119
void reset()
Prepates the track for a new race.
Definition: track.cpp:302
const TriangleMesh & getGFXEffectMesh() const
Returns the graphical effect mesh for this track.
Definition: track.hpp:615
void createPhysicsModel(unsigned int main_track_count, bool for_height_map)
Convert the track tree into its physics equivalents.
Definition: track.cpp:855
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp, bool secondary_hits=true) const
Handles an explosion, i.e.
Definition: track.cpp:1701
const btTransform & getStartTransform(unsigned int index) const
Returns the start coordinates for a kart with a given index.
Definition: track.hpp:555
float m_sky_texture_percent
If a sky dome is used, percentage of the texture to be used.
Definition: track.hpp:299
static Track * getCurrentTrack()
Static function to get the current track.
Definition: track.hpp:431
const std::vector< OverworldChallenge > & getChallengeList() const
Get list of challenges placed on that world.
Definition: track.hpp:685
core::vector3df getColorLevelIn() const
Return the color levels for color correction shader.
Definition: track.hpp:699
unsigned int getMaxArenaPlayers() const
Get the max players supported for this track, for arena only.
Definition: track.hpp:618
bool isAutoRescueEnabled() const
Returns true if auto rescue is enabled.
Definition: track.hpp:669
bool findGround(AbstractKart *kart)
Determines if the kart is over ground.
Definition: track.cpp:2872
float getCameraFar() const
Returns the far value for cameras.
Definition: track.hpp:608
float m_friction
Friction to be used for the track.
Definition: track.hpp:129
int m_sky_hori_segments
If a sky dome is used, the number of horizontal segments the sphere should be divided in.
Definition: track.hpp:289
std::vector< OverworldChallenge > m_challenges
Will only be used on overworld.
Definition: track.hpp:138
const std::vector< std::string > & getGroups() const
Returns all groups this track belongs to.
Definition: track.hpp:536
void addCachedMesh(scene::IMesh *mesh)
Adds mesh to cleanup list.
Definition: track.hpp:734
float m_camera_far
Far value for cameras for this track.
Definition: track.hpp:245
std::string m_root
The base dir of all files of this track.
Definition: track.hpp:156
TriangleMesh * m_height_map_mesh
Used to collect the triangles for the height map mesh used for particle rendering.
Definition: track.hpp:213
bool hasNavMesh() const
Returns true if this track navmesh.
Definition: track.hpp:512
core::stringw getName() const
Returns the name of the track, which is e.g.
Definition: track.cpp:225
bool m_is_arena
True if this track is an arena.
Definition: track.hpp:227
int m_version
The version of this track.
Definition: track.hpp:242
bool m_has_navmesh
True if this track has navmesh.
Definition: track.hpp:234
void handleSky(const XMLNode &root, const std::string &filename)
Handles a sky-dome or sky-box.
Definition: track.cpp:2490
Vec3 m_aabb_max
Maximum coordinates of this track.
Definition: track.hpp:223
video::SColor m_ambient_color
The current ambient color for each kart.
Definition: track.hpp:367
const TriangleMesh * getPtrTriangleMesh() const
Returns the triangle mesh for this track.
Definition: track.hpp:611
const std::string & getScreenshotFile() const
Returns an absolute path to the screenshot file of this track.
Definition: track.hpp:545
std::vector< scene::IMesh * > m_detached_cached_meshes
m_all_cached_meshes assumes meshes are attached to a scene node.
Definition: track.hpp:179
void loadArenaGraph(const XMLNode &node)
Loads the quad graph for arena, i.e.
Definition: track.cpp:739
bool hasEasterEggs() const
Returns true if this track has easter eggs.
Definition: track.hpp:506
std::string m_filename
The full filename of the config (xml) file.
Definition: track.hpp:153
static void uploadNodeVertexBuffer(scene::ISceneNode *node)
Static helper function to pre-upload vertex buffer in spm.
Definition: track.cpp:2908
bool loadMainTrack(const XMLNode &node)
Loads the main track model (i.e.
Definition: track.cpp:1242
A special class to store a triangle mesh with a separate material per triangle.
Definition: triangle_mesh.hpp:35
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