2009-12-29 19:08:20 -05:00
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2015-03-29 20:31:42 -04:00
|
|
|
// Copyright (C) 2009-2015 Joerg Henrichs
|
2009-12-29 19:08:20 -05:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 3
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
#ifndef HEADER_TRACK_OBJECT_MANAGER_HPP
|
|
|
|
#define HEADER_TRACK_OBJECT_MANAGER_HPP
|
|
|
|
|
2011-09-01 16:09:26 -04:00
|
|
|
#include "physics/physical_object.hpp"
|
2011-05-23 20:04:43 -04:00
|
|
|
#include "tracks/track_object.hpp"
|
|
|
|
#include "utils/ptr_vector.hpp"
|
2009-12-29 19:08:20 -05:00
|
|
|
|
|
|
|
class Track;
|
|
|
|
class Vec3;
|
|
|
|
class XMLNode;
|
2016-08-16 23:57:18 -04:00
|
|
|
class LODNode;
|
2009-12-29 19:08:20 -05:00
|
|
|
|
2011-12-03 20:25:09 -05:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2010-04-23 16:53:45 -04:00
|
|
|
/**
|
|
|
|
* \ingroup tracks
|
|
|
|
*/
|
2009-12-29 19:08:20 -05:00
|
|
|
class TrackObjectManager
|
|
|
|
{
|
2011-12-03 20:25:09 -05:00
|
|
|
protected:
|
2010-04-23 16:53:45 -04:00
|
|
|
/**
|
2013-05-30 15:47:39 -04:00
|
|
|
* The different type of track objects: physical objects, graphical
|
2010-04-23 16:53:45 -04:00
|
|
|
* objects (without a physical representation) - the latter might be
|
|
|
|
* eye candy (to reduce work for physics), ...
|
|
|
|
*/
|
2009-12-29 19:08:20 -05:00
|
|
|
enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL};
|
2014-09-11 07:48:03 -04:00
|
|
|
|
|
|
|
/** The list of all track objects. */
|
2011-05-23 20:04:43 -04:00
|
|
|
PtrVector<TrackObject> m_all_objects;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2014-09-11 07:48:03 -04:00
|
|
|
/** A second list which holds all objects that karts can drive on. */
|
|
|
|
PtrVector<TrackObject, REF> m_driveable_objects;
|
|
|
|
|
2009-12-29 19:08:20 -05:00
|
|
|
public:
|
|
|
|
TrackObjectManager();
|
2010-01-06 20:14:46 -05:00
|
|
|
~TrackObjectManager();
|
2014-09-11 07:48:03 -04:00
|
|
|
void reset();
|
|
|
|
void init();
|
|
|
|
void add(const XMLNode &xml_node, scene::ISceneNode* parent,
|
2015-06-03 20:34:58 -04:00
|
|
|
ModelDefinitionLoader& model_def_loader,
|
2016-08-16 23:57:18 -04:00
|
|
|
TrackObject* parent_library);
|
2018-04-18 08:27:06 -04:00
|
|
|
void updateGraphics(float dt);
|
2009-12-29 19:08:20 -05:00
|
|
|
void update(float dt);
|
2019-03-03 20:54:22 -05:00
|
|
|
void resetAfterRewind();
|
2012-11-04 07:57:03 -05:00
|
|
|
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
|
|
|
|
bool secondary_hits=true);
|
2019-02-14 00:19:53 -05:00
|
|
|
bool castRay(const btVector3 &from,
|
2014-09-11 07:48:03 -04:00
|
|
|
const btVector3 &to, btVector3 *hit_point,
|
|
|
|
const Material **material, btVector3 *normal = NULL,
|
|
|
|
bool interpolate_normal = false) const;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2013-04-04 21:30:34 -04:00
|
|
|
void insertObject(TrackObject* object);
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2013-04-03 21:15:37 -04:00
|
|
|
void removeObject(TrackObject* who);
|
2019-02-26 22:06:18 -05:00
|
|
|
void removeDriveableObject(TrackObject* obj) { m_driveable_objects.remove(obj); }
|
2015-06-05 19:34:46 -04:00
|
|
|
TrackObject* getTrackObject(const std::string& libraryInstance, const std::string& name);
|
2014-06-11 01:22:04 -04:00
|
|
|
|
2012-06-16 19:35:51 -04:00
|
|
|
PtrVector<TrackObject>& getObjects() { return m_all_objects; }
|
2012-06-04 20:27:34 -04:00
|
|
|
const PtrVector<TrackObject>& getObjects() const { return m_all_objects; }
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2009-12-29 19:08:20 -05:00
|
|
|
}; // class TrackObjectManager
|
|
|
|
|
|
|
|
#endif
|