SuperTuxKart
Loading...
Searching...
No Matches
track_object_manager.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2009-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_TRACK_OBJECT_MANAGER_HPP
20#define HEADER_TRACK_OBJECT_MANAGER_HPP
21
22#include "physics/physical_object.hpp"
23#include "tracks/track_object.hpp"
24#include "utils/ptr_vector.hpp"
25
26class Track;
27class Vec3;
28class XMLNode;
29class LODNode;
30
31#include <map>
32#include <vector>
33#include <string>
34
39{
40protected:
46 enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL};
47
50
53
54public:
57 void reset();
58 void init();
59 void add(const XMLNode &xml_node, scene::ISceneNode* parent,
60 ModelDefinitionLoader& model_def_loader,
61 TrackObject* parent_library);
62 void updateGraphics(float dt);
63 void update(float dt);
64 void resetAfterRewind();
65 void handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
66 bool secondary_hits=true);
67 bool castRay(const btVector3 &from,
68 const btVector3 &to, btVector3 *hit_point,
69 const Material **material, btVector3 *normal = NULL,
70 bool interpolate_normal = false) const;
71
72 void insertObject(TrackObject* object);
73 void insertDriveableObject(TrackObject* object);
74 void removeObject(TrackObject* who);
75 void removeDriveableObject(TrackObject* obj) { m_driveable_objects.remove(obj); }
76 TrackObject* getTrackObject(const std::string& libraryInstance, const std::string& name);
77
78 PtrVector<TrackObject>& getObjects() { return m_all_objects; }
79 const PtrVector<TrackObject>& getObjects() const { return m_all_objects; }
80
81}; // class TrackObjectManager
82
83#endif
manages level-of-detail
Definition: lod_node.hpp:50
Definition: material.hpp:48
Utility class to load level-of-detail nodes and library nodes.
Definition: model_definition_loader.hpp:81
Definition: physical_object.hpp:40
Definition: ptr_vector.hpp:44
Definition: track_object_manager.hpp:39
PtrVector< TrackObject > m_all_objects
The list of all track objects.
Definition: track_object_manager.hpp:49
PtrVector< TrackObject, REF > m_driveable_objects
A second list which holds all objects that karts can drive on.
Definition: track_object_manager.hpp:52
void update(float dt)
Updates all track objects.
Definition: track_object_manager.cpp:189
TrackObjectType
The different type of track objects: physical objects, graphical objects (without a physical represen...
Definition: track_object_manager.hpp:46
void updateGraphics(float dt)
Updates all track objects.
Definition: track_object_manager.cpp:176
void init()
Initialises all track objects.
Definition: track_object_manager.cpp:69
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp, bool secondary_hits=true)
Handles an explosion, i.e.
Definition: track_object_manager.cpp:161
void removeObject(TrackObject *who)
Removes the object from the scene graph, bullet, and the list of track objects, and then frees the ob...
Definition: track_object_manager.cpp:288
TrackObject * getTrackObject(const std::string &libraryInstance, const std::string &name)
returns a reference to the track object with a particular ID
Definition: track_object_manager.cpp:122
void reset()
Initialises all track objects.
Definition: track_object_manager.cpp:108
bool castRay(const btVector3 &from, const btVector3 &to, btVector3 *hit_point, const Material **material, btVector3 *normal=NULL, bool interpolate_normal=false) const
Does a raycast against all driveable objects.
Definition: track_object_manager.cpp:228
void add(const XMLNode &xml_node, scene::ISceneNode *parent, ModelDefinitionLoader &model_def_loader, TrackObject *parent_library)
Adds an object to the track object manager.
Definition: track_object_manager.cpp:48
This is a base object for any separate object on the track, which might also have a skeletal animatio...
Definition: track_object.hpp:56
Definition: track.hpp:114
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