Fixed crashes in grand_prix lose, win, feature animation etc.
KartModel instances come now in two different types: master instances which are part of KartProperties and should never call attachModel (or have wheels attached), and copies of the master instances (which are used by karts and other classes when the kart is actually displayed. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5954 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
ea7e1e2734
commit
7f3f598193
@ -32,8 +32,8 @@ AIBaseController::AIBaseController(Kart *kart,
|
||||
: Controller(kart, player)
|
||||
{
|
||||
m_kart = kart;
|
||||
m_kart_length = m_kart->getKartProperties()->getKartModel()->getLength();
|
||||
m_kart_width = m_kart->getKartProperties()->getKartModel()->getWidth();
|
||||
m_kart_length = m_kart->getKartModel()->getLength();
|
||||
m_kart_width = m_kart->getKartModel()->getWidth();
|
||||
m_world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||
m_track = m_world->getTrack();
|
||||
m_quad_graph = &m_track->getQuadGraph();
|
||||
|
@ -79,7 +79,7 @@ Kart::Kart (const std::string& ident, int position,
|
||||
// released when the kart is deleted, but since the original
|
||||
// kart_model is stored in the kart_properties all the time,
|
||||
// there is no risk of a mesh being deleted to early.
|
||||
m_kart_model = *(m_kart_properties->getKartModel());
|
||||
m_kart_model = m_kart_properties->getKartModelCopy();
|
||||
m_initial_position = position;
|
||||
m_race_position = position;
|
||||
m_collected_energy = 0;
|
||||
@ -248,7 +248,7 @@ void Kart::createPhysics()
|
||||
{
|
||||
bool is_front_wheel = i<2;
|
||||
btWheelInfo& wheel = m_vehicle->addWheel(
|
||||
m_kart_model.getWheelPhysicsPosition(i),
|
||||
m_kart_model->getWheelPhysicsPosition(i),
|
||||
wheel_direction, wheel_axle, suspension_rest,
|
||||
wheel_radius, *m_tuning, is_front_wheel);
|
||||
wheel.m_suspensionStiffness = m_kart_properties->getSuspensionStiffness();
|
||||
@ -325,6 +325,7 @@ Kart::~Kart()
|
||||
}
|
||||
delete m_slipstream_original_quad;
|
||||
delete m_slipstream_quad;
|
||||
delete m_kart_model;
|
||||
} // ~Kart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -374,7 +375,7 @@ void Kart::reset()
|
||||
}
|
||||
|
||||
// Stop any animations currently being played.
|
||||
m_kart_model.setAnimation(KartModel::AF_DEFAULT);
|
||||
m_kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
// If the controller was replaced (e.g. replaced by end controller),
|
||||
// restore the original controller.
|
||||
if(m_saved_controller)
|
||||
@ -382,7 +383,7 @@ void Kart::reset()
|
||||
m_controller = m_saved_controller;
|
||||
m_saved_controller = NULL;
|
||||
}
|
||||
m_kart_model.setAnimation(KartModel::AF_DEFAULT);
|
||||
m_kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
m_view_blocked_by_plunger = 0.0;
|
||||
m_attachment->clear();
|
||||
m_powerup.reset();
|
||||
@ -473,9 +474,9 @@ void Kart::finishedRace(float time)
|
||||
setController(new EndController(this, m_controller->getPlayer()));
|
||||
if(m_race_position<=0.5f*race_manager->getNumberOfKarts() ||
|
||||
m_race_position==1)
|
||||
m_kart_model.setAnimation(KartModel::AF_WIN_START);
|
||||
m_kart_model->setAnimation(KartModel::AF_WIN_START);
|
||||
else
|
||||
m_kart_model.setAnimation(KartModel::AF_LOSE_START);
|
||||
m_kart_model->setAnimation(KartModel::AF_LOSE_START);
|
||||
|
||||
// Not all karts have a camera
|
||||
if (m_camera) m_camera->setMode(Camera::CM_FINAL);
|
||||
@ -492,9 +493,9 @@ void Kart::finishedRace(float time)
|
||||
// start end animation
|
||||
setController(new EndController(this, m_controller->getPlayer()));
|
||||
if(m_race_position<=2)
|
||||
m_kart_model.setAnimation(KartModel::AF_WIN_START);
|
||||
m_kart_model->setAnimation(KartModel::AF_WIN_START);
|
||||
else if(m_race_position>=0.7f*race_manager->getNumberOfKarts())
|
||||
m_kart_model.setAnimation(KartModel::AF_LOSE_START);
|
||||
m_kart_model->setAnimation(KartModel::AF_LOSE_START);
|
||||
|
||||
// Not all karts have a camera
|
||||
if (m_camera) m_camera->setMode(Camera::CM_REVERSE);
|
||||
@ -1334,7 +1335,7 @@ void Kart::updatePhysics(float dt)
|
||||
*/
|
||||
void Kart::loadData()
|
||||
{
|
||||
m_kart_model.attachModel(&m_node);
|
||||
m_kart_model->attachModel(&m_node);
|
||||
// Attachment must be created after attachModel, since only then the
|
||||
// scene node will exist (to which the attachment is added). But the
|
||||
// attachment is needed in createPhysics (which gets the mass, which
|
||||
@ -1423,15 +1424,15 @@ void Kart::updateGraphics(const Vec3& offset_xyz,
|
||||
// auto_skid = m_controls.m_steer*30.0f*((auto_skid_visual - m_skidding) / 0.8f); // divisor comes from max_skid - AUTO_SKID_VISUAL
|
||||
// else
|
||||
auto_skid = m_controls.m_steer*30.0f;
|
||||
m_kart_model.update(m_wheel_rotation, auto_skid,
|
||||
m_kart_model->update(m_wheel_rotation, auto_skid,
|
||||
getSteerPercent(), wheel_up_axis);
|
||||
|
||||
Vec3 center_shift = getGravityCenterShift();
|
||||
float y = m_vehicle->getWheelInfo(0).m_chassisConnectionPointCS.getY()
|
||||
- m_default_suspension_length[0]
|
||||
- m_vehicle->getWheelInfo(0).m_wheelsRadius
|
||||
- (m_kart_model.getWheelGraphicsRadius(0)
|
||||
-m_kart_model.getWheelGraphicsPosition(0).getY() );
|
||||
- (m_kart_model->getWheelGraphicsRadius(0)
|
||||
-m_kart_model->getWheelGraphicsPosition(0).getY() );
|
||||
center_shift.setY(y);
|
||||
|
||||
if(m_smoke_system)
|
||||
|
@ -206,7 +206,7 @@ protected:
|
||||
/** This stores a copy of the kart model. It has to be a copy
|
||||
* since otherwise incosistencies can happen if the same kart
|
||||
* is used more than once. */
|
||||
KartModel m_kart_model;
|
||||
KartModel* m_kart_model;
|
||||
|
||||
public:
|
||||
Kart(const std::string& ident, int position,
|
||||
@ -217,6 +217,10 @@ public:
|
||||
void loadData();
|
||||
virtual void updateGraphics(const Vec3& off_xyz,
|
||||
const btQuaternion& off_rotation);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns this kart's kart model. */
|
||||
KartModel* getKartModel() { return m_kart_model; }
|
||||
// ------------------------------------------------------------------------
|
||||
const KartProperties*
|
||||
getKartProperties() const { return m_kart_properties; }
|
||||
// ------------------------------------------------------------------------
|
||||
@ -339,11 +343,11 @@ public:
|
||||
float getMaxSpeedOnTerrain() const {return m_max_speed-
|
||||
m_max_speed_reduction; }
|
||||
/** Returns the length of the kart. */
|
||||
float getKartLength () const {return m_kart_model.getLength(); }
|
||||
float getKartLength () const {return m_kart_model->getLength(); }
|
||||
/** Returns the height of the kart. */
|
||||
float getKartHeight () const {return m_kart_model.getHeight(); }
|
||||
float getKartHeight () const {return m_kart_model->getHeight(); }
|
||||
/** Returns the width of the kart. */
|
||||
float getKartWidth () const {return m_kart_model.getWidth(); }
|
||||
float getKartWidth () const {return m_kart_model->getWidth(); }
|
||||
/** Returns the bullet vehicle which represents this kart. */
|
||||
btKart *getVehicle () const {return m_vehicle; }
|
||||
btUprightConstraint *getUprightConstraint() const {return m_uprightConstraint;}
|
||||
|
@ -29,20 +29,33 @@
|
||||
float KartModel::UNDEFINED = -99.9f;
|
||||
|
||||
/** Default constructor which initialises all variables with defaults.
|
||||
* Note that the KartModel is copied, so make sure that all variables
|
||||
* are safe to be copied, or write a custom copy function.
|
||||
* Note that the KartModel is copied, so make sure to update makeCopy
|
||||
* if any more variables are added to this object.
|
||||
* ATM there are two pointers:
|
||||
* - to the scene node (which is otherwise handled by kart and set
|
||||
* - to the scene node (which is otherwise handled by kart/movable and set
|
||||
* later anyway)
|
||||
* - to the mesh. Sharing mesh is supported in irrlicht, so that's
|
||||
* no problem.
|
||||
* There are two different type of instances of this class:
|
||||
* One is the 'master instances' which is part of the kart_properties.
|
||||
* These instances have m_is_master = true, will cause an assertion
|
||||
* crash if attachModel is called or the destructor notices any
|
||||
* wheels being defined.
|
||||
* The other types are copies of one of the master objects: these are
|
||||
* used when actually displaying the karts (e.g. in race). They must
|
||||
* be copied since otherwise (if the same kart is used more than once)
|
||||
* shared variables in KartModel (esp. animation status) will cause
|
||||
* incorrect animations. The mesh is shared (between the master instance
|
||||
* and all of its copies).
|
||||
* Technically the scene node and mesh should be grab'ed on copy,
|
||||
* and dropped when the copy is deleted. But since the master copy
|
||||
* in the kart_properties_manager is always kept, there is no risk of
|
||||
* a mesh being deleted to early.
|
||||
*/
|
||||
KartModel::KartModel()
|
||||
KartModel::KartModel(bool is_master)
|
||||
{
|
||||
m_is_master = is_master;
|
||||
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
m_wheel_graphics_position[i] = Vec3(UNDEFINED);
|
||||
@ -99,7 +112,7 @@ void KartModel::loadInfo(const XMLNode &node)
|
||||
loadWheelInfo(*wheels_node, "rear-right", 2);
|
||||
loadWheelInfo(*wheels_node, "rear-left", 3);
|
||||
}
|
||||
} // init
|
||||
} // loadInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Destructor.
|
||||
*/
|
||||
@ -108,17 +121,50 @@ KartModel::~KartModel()
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
if(m_wheel_node[i])
|
||||
{
|
||||
// Master KartModels should never have a wheel attached.
|
||||
assert(!m_is_master);
|
||||
m_wheel_node[i]->drop();
|
||||
}
|
||||
}
|
||||
|
||||
} // ~KartModel
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This function returns a copy of this object. The memory is allocated
|
||||
* here, but needs to be managed (esp. freed) by the calling function.
|
||||
* It is also marked not to be a master copy, so attachModel can be called
|
||||
* for this instance.
|
||||
*/
|
||||
KartModel* KartModel::makeCopy()
|
||||
{
|
||||
KartModel *km = new KartModel(/*is master*/ false);
|
||||
km->m_kart_height = m_kart_height;
|
||||
km->m_kart_length = m_kart_length;
|
||||
km->m_kart_width = m_kart_width;
|
||||
km->m_mesh = m_mesh;
|
||||
km->m_model_filename = m_model_filename;
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
km->m_max_suspension[i] = m_max_suspension[i];
|
||||
km->m_min_suspension[i] = m_min_suspension[i];
|
||||
km->m_wheel_filename[i] = m_wheel_filename[i];
|
||||
km->m_wheel_model[i] = m_wheel_model[i];
|
||||
km->m_wheel_graphics_position[i] = m_wheel_graphics_position[i];
|
||||
km->m_wheel_graphics_radius[i] = m_wheel_graphics_radius[i];
|
||||
km->m_wheel_physics_position[i] = m_wheel_physics_position[i];
|
||||
km->m_z_offset = m_z_offset;
|
||||
}
|
||||
return km;
|
||||
} // makeCopy
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Attach the kart model and wheels to the scene node.
|
||||
* \param node Node to attach the models to.
|
||||
*/
|
||||
void KartModel::attachModel(scene::ISceneNode **node)
|
||||
{
|
||||
assert(!m_is_master);
|
||||
if(UserConfigParams::m_show_steering_animations)
|
||||
{
|
||||
*node = irr_driver->addAnimatedMesh(m_mesh);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
class KartProperties;
|
||||
@ -40,7 +41,7 @@ class XMLNode;
|
||||
* kart.cpp.
|
||||
* \ingroup karts
|
||||
*/
|
||||
class KartModel : public scene::IAnimationEndCallBack
|
||||
class KartModel : public scene::IAnimationEndCallBack, public NoCopy
|
||||
{
|
||||
public:
|
||||
enum AnimationFrameType
|
||||
@ -122,22 +123,31 @@ private:
|
||||
float m_z_offset; /**< Models are usually not at z=0 (due
|
||||
* to the wheels), so this value moves
|
||||
* the karts down appropriately. */
|
||||
/** True if this is the master copy, managed by KartProperties. This
|
||||
* is mainly used for debugging, e.g. the master copies might not have
|
||||
* anything attached to it etc. */
|
||||
bool m_is_master;
|
||||
|
||||
void loadWheelInfo(const XMLNode &node,
|
||||
const std::string &wheel_name, int index);
|
||||
|
||||
void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node);
|
||||
|
||||
public:
|
||||
KartModel();
|
||||
~KartModel();
|
||||
void loadInfo(const XMLNode &node);
|
||||
void loadModels(const KartProperties &kart_properties);
|
||||
void attachModel(scene::ISceneNode **node);
|
||||
scene::IAnimatedMesh* getModel() const { return m_mesh; }
|
||||
KartModel(bool is_master);
|
||||
~KartModel();
|
||||
KartModel* makeCopy();
|
||||
void loadInfo(const XMLNode &node);
|
||||
void loadModels(const KartProperties &kart_properties);
|
||||
void attachModel(scene::ISceneNode **node);
|
||||
scene::IAnimatedMesh*
|
||||
getModel() const { return m_mesh; }
|
||||
|
||||
scene::IMesh* getWheelModel(const int wheelID) const { return m_wheel_model[wheelID]; }
|
||||
scene::IMesh* getWheelModel(const int wheelID) const
|
||||
{ return m_wheel_model[wheelID]; }
|
||||
|
||||
/** Since karts might be animated, we might need to know which base frame to use */
|
||||
/** Since karts might be animated, we might need to know which base frame
|
||||
* to use. */
|
||||
int getBaseFrame() const { return m_animation_frame[AF_STRAIGHT]; }
|
||||
|
||||
/** Returns the position of a wheel relative to the kart.
|
||||
|
@ -40,7 +40,7 @@ float KartProperties::UNDEFINED = -99.9f;
|
||||
/** The constructor initialises all values with invalid values. It can later
|
||||
* then be checked (for STKConfig) that all values are indeed defined.
|
||||
* Otherwise the defaults are taken from STKConfig (and since they are all
|
||||
* defined, it is guaranteed that each kart has well defined physics values.
|
||||
* defined, it is guaranteed that each kart has well defined physics values).
|
||||
*/
|
||||
KartProperties::KartProperties(const std::string &filename)
|
||||
{
|
||||
@ -85,7 +85,7 @@ KartProperties::KartProperties(const std::string &filename)
|
||||
m_color = video::SColor(255, 0, 0, 0);
|
||||
m_shape = 32; // close enough to a circle.
|
||||
m_engine_sfx_type = "engine_small";
|
||||
|
||||
m_kart_model = NULL;
|
||||
// The default constructor for stk_config uses filename=""
|
||||
if (filename != "") load(filename, "kart");
|
||||
} // KartProperties
|
||||
@ -103,8 +103,12 @@ KartProperties::~KartProperties()
|
||||
*/
|
||||
void KartProperties::load(const std::string &filename, const std::string &node)
|
||||
{
|
||||
// Get the default values from STKConfig:
|
||||
*this = stk_config->getDefaultKartProperties();
|
||||
// Get the default values from STKConfig:
|
||||
*this = stk_config->getDefaultKartProperties();
|
||||
// m_kart_model must be initialised after assigning the default
|
||||
// values from stk_config (otherwise all kart_properties will
|
||||
// share the same KartModel
|
||||
m_kart_model = new KartModel(/*is_master*/true);
|
||||
|
||||
const XMLNode * root = 0;
|
||||
m_root = StringUtils::getPath(filename);
|
||||
@ -157,18 +161,18 @@ void KartProperties::load(const std::string &filename, const std::string &node)
|
||||
// Only load the model if the .kart file has the appropriate version,
|
||||
// otherwise warnings are printed.
|
||||
if(m_version>=1)
|
||||
m_kart_model.loadModels(*this);
|
||||
m_kart_model->loadModels(*this);
|
||||
if(m_gravity_center_shift.getX()==UNDEFINED)
|
||||
{
|
||||
m_gravity_center_shift.setX(0);
|
||||
// Default: center at the very bottom of the kart.
|
||||
m_gravity_center_shift.setY(m_kart_model.getHeight()*0.5f);
|
||||
m_gravity_center_shift.setY(m_kart_model->getHeight()*0.5f);
|
||||
m_gravity_center_shift.setZ(0);
|
||||
}
|
||||
m_kart_model.setDefaultPhysicsPosition(m_gravity_center_shift,
|
||||
m_kart_model->setDefaultPhysicsPosition(m_gravity_center_shift,
|
||||
m_wheel_radius );
|
||||
m_wheel_base = fabsf( m_kart_model.getWheelPhysicsPosition(0).getZ()
|
||||
-m_kart_model.getWheelPhysicsPosition(2).getZ());
|
||||
m_wheel_base = fabsf( m_kart_model->getWheelPhysicsPosition(0).getZ()
|
||||
-m_kart_model->getWheelPhysicsPosition(2).getZ());
|
||||
m_angle_at_min = asinf(m_wheel_base/m_min_radius);
|
||||
m_angle_at_max = asinf(m_wheel_base/m_max_radius);
|
||||
if(m_max_speed_turn == m_min_speed_turn)
|
||||
@ -181,8 +185,8 @@ void KartProperties::load(const std::string &filename, const std::string &node)
|
||||
// Useful when tweaking kart parameters
|
||||
if(UserConfigParams::m_print_kart_sizes)
|
||||
printf("%s:\twidth: %f\tlength: %f\theight: %f\n",getIdent().c_str(),
|
||||
m_kart_model.getWidth(), m_kart_model.getLength(),
|
||||
m_kart_model.getHeight());
|
||||
m_kart_model->getWidth(), m_kart_model->getLength(),
|
||||
m_kart_model->getHeight());
|
||||
|
||||
m_shadow_texture = irr_driver->getTexture(m_shadow_file);
|
||||
file_manager->popTextureSearchPath();
|
||||
@ -416,7 +420,8 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
#endif
|
||||
} // if sounds-node exist
|
||||
|
||||
m_kart_model.loadInfo(*root);
|
||||
if(m_kart_model)
|
||||
m_kart_model->loadInfo(*root);
|
||||
} // getAllData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
/** The kart model and wheels. It is mutable since the wheels of the
|
||||
* KartModel can rotate and turn, and animations are played, but otherwise
|
||||
* the kart_properties object is const. */
|
||||
mutable KartModel m_kart_model;
|
||||
mutable KartModel *m_kart_model;
|
||||
|
||||
/** List of all groups the kart belongs to. */
|
||||
std::vector<std::string> m_groups;
|
||||
@ -228,7 +228,11 @@ public:
|
||||
video::ITexture *getMinimapIcon () const {return m_minimap_icon; }
|
||||
|
||||
/** Returns a pointer to the KartModel object. */
|
||||
KartModel* getKartModel () const {return &m_kart_model; }
|
||||
KartModel* getKartModelCopy () const {return m_kart_model->makeCopy(); }
|
||||
|
||||
/** Returns a pointer to the main KartModel object. This copy
|
||||
* should not be modified, not attachModel be called on it. */
|
||||
const KartModel& getMasterKartModel() const {return *m_kart_model; }
|
||||
|
||||
/** Returns the name of this kart. */
|
||||
const irr::core::stringw& getName() const {return m_name; }
|
||||
|
@ -194,10 +194,9 @@ void FeatureUnlockedCutScene::init()
|
||||
{
|
||||
if (m_unlocked_stuff[n].m_unlocked_kart != NULL)
|
||||
{
|
||||
m_all_kart_models.push_back(
|
||||
(*m_unlocked_stuff[n].m_unlocked_kart->getKartModel())
|
||||
);
|
||||
KartModel *kart_model = &(m_all_kart_models.back());
|
||||
KartModel *kart_model =
|
||||
m_unlocked_stuff[n].m_unlocked_kart->getKartModelCopy();
|
||||
m_all_kart_models.push_back(kart_model);
|
||||
kart_model->attachModel(&(m_unlocked_stuff[n].m_root_gift_node));
|
||||
#ifdef DEBUG
|
||||
m_unlocked_stuff[n].m_root_gift_node->setName("unlocked kart");
|
||||
|
@ -62,7 +62,7 @@ class FeatureUnlockedCutScene : public GUIEngine::Screen, public GUIEngine::Scre
|
||||
ptr_vector<UnlockedThing, HOLD> m_unlocked_stuff;
|
||||
|
||||
/** To store the copy of the KartModel for each unlocked kart. */
|
||||
std::vector<KartModel> m_all_kart_models;
|
||||
std::vector<KartModel*> m_all_kart_models;
|
||||
/** sky angle, 0-360 */
|
||||
float m_sky_angle;
|
||||
|
||||
|
@ -136,11 +136,15 @@ void GrandPrixLose::tearDown()
|
||||
m_light = NULL;
|
||||
|
||||
irr_driver->removeNode(m_garage);
|
||||
irr_driver->removeNode(m_garage_door);
|
||||
m_garage = NULL;
|
||||
|
||||
for(unsigned int i=0; i<m_all_kart_models.size(); i++)
|
||||
delete m_all_kart_models[i];
|
||||
|
||||
m_all_kart_models.clear();
|
||||
irr_driver->removeNode(m_kart_node);
|
||||
|
||||
irr_driver->removeNode(m_garage_door);
|
||||
} // tearDown
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
@ -245,7 +249,10 @@ void GrandPrixLose::setKarts(const std::vector<std::string> ident_arg)
|
||||
const KartProperties* kart = kart_properties_manager->getKart(ident_arg[0]);
|
||||
if (kart != NULL)
|
||||
{
|
||||
KartModel* kart_model = kart->getKartModel();
|
||||
|
||||
KartModel *kart_model = kart->getKartModelCopy();
|
||||
m_all_kart_models.push_back(kart_model);
|
||||
|
||||
m_kart_x = KART_START_X;
|
||||
m_kart_y = KART_Y;
|
||||
m_kart_z = KART_Z;
|
||||
@ -262,3 +269,7 @@ void GrandPrixLose::setKarts(const std::vector<std::string> ident_arg)
|
||||
} // setKarts
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define HEADER_GRAND_PRIX_LOSE_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -36,6 +37,9 @@ class GrandPrixLose : public GUIEngine::Screen, public GUIEngine::ScreenSingleto
|
||||
|
||||
irr::scene::ILightSceneNode* m_light;
|
||||
|
||||
/** A copy of the kart model for each kart used. */
|
||||
std::vector<KartModel*> m_all_kart_models;
|
||||
|
||||
int m_phase;
|
||||
|
||||
float m_kart_x, m_kart_y, m_kart_z;
|
||||
|
@ -223,6 +223,9 @@ void GrandPrixWin::tearDown()
|
||||
if (m_kart_node[n] != NULL) irr_driver->removeNode(m_kart_node[n]);
|
||||
m_kart_node[n] = NULL;
|
||||
}
|
||||
for(unsigned int i=0; i<m_all_kart_models.size(); i++)
|
||||
delete m_all_kart_models[i];
|
||||
m_all_kart_models.clear();
|
||||
} // tearDown
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
@ -399,10 +402,12 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
||||
|
||||
scene::ISceneNode* kart_main_node = NULL;
|
||||
|
||||
const KartProperties* kart = kart_properties_manager->getKart(idents[n]);
|
||||
if (kart != NULL)
|
||||
const KartProperties* kp = kart_properties_manager->getKart(idents[n]);
|
||||
if (kp != NULL)
|
||||
{
|
||||
KartModel* kart_model = kart->getKartModel();
|
||||
KartModel *kart_model = kp->getKartModelCopy();
|
||||
m_all_kart_models.push_back(kart_model);
|
||||
kart_model->attachModel(&kart_main_node);
|
||||
assert(kart_model != NULL);
|
||||
|
||||
m_kart_x[n] = m_podium_x[n];
|
||||
@ -410,9 +415,10 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
||||
m_kart_z[n] = -4;
|
||||
m_kart_rotation[n] = 0.0f;
|
||||
|
||||
kart_model->attachModel(&kart_main_node);
|
||||
assert(kart_main_node != NULL);
|
||||
kart_main_node->setPosition( core::vector3df(m_kart_x[n], m_kart_y[n], m_kart_z[n]) );
|
||||
kart_main_node->setPosition( core::vector3df(m_kart_x[n],
|
||||
m_kart_y[n],
|
||||
m_kart_z[n]) );
|
||||
kart_main_node->setScale( core::vector3df(0.4f, 0.4f, 0.4f) );
|
||||
kart_model->setAnimation(KartModel::AF_DEFAULT);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define HEADER_GRAND_PRIX_WIN_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
|
||||
namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; } }
|
||||
class KartProperties;
|
||||
@ -26,6 +27,9 @@ class GrandPrixWin : public GUIEngine::Screen, public GUIEngine::ScreenSingleton
|
||||
|
||||
irr::scene::IMeshSceneNode* m_podium_step[3];
|
||||
irr::scene::ISceneNode* m_kart_node[3];
|
||||
|
||||
/** A copy of the kart model for each kart used. */
|
||||
std::vector<KartModel*> m_all_kart_models;
|
||||
|
||||
irr::scene::ISceneNode* m_sky;
|
||||
irr::scene::ICameraSceneNode* m_camera;
|
||||
|
@ -315,13 +315,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
KartModel* kart_model = props->getKartModel();
|
||||
const KartModel &kart_model = props->getMasterKartModel();
|
||||
|
||||
m_model_view->addModel( kart_model->getModel(), Vec3(0,0,0), kart_model->getBaseFrame() );
|
||||
m_model_view->addModel( kart_model->getWheelModel(0), kart_model->getWheelGraphicsPosition(0) );
|
||||
m_model_view->addModel( kart_model->getWheelModel(1), kart_model->getWheelGraphicsPosition(1) );
|
||||
m_model_view->addModel( kart_model->getWheelModel(2), kart_model->getWheelGraphicsPosition(2) );
|
||||
m_model_view->addModel( kart_model->getWheelModel(3), kart_model->getWheelGraphicsPosition(3) );
|
||||
m_model_view->addModel( kart_model.getModel(), Vec3(0,0,0),
|
||||
kart_model.getBaseFrame() );
|
||||
m_model_view->addModel( kart_model.getWheelModel(0),
|
||||
kart_model.getWheelGraphicsPosition(0) );
|
||||
m_model_view->addModel( kart_model.getWheelModel(1),
|
||||
kart_model.getWheelGraphicsPosition(1) );
|
||||
m_model_view->addModel( kart_model.getWheelModel(2),
|
||||
kart_model.getWheelGraphicsPosition(2) );
|
||||
m_model_view->addModel( kart_model.getWheelModel(3),
|
||||
kart_model.getWheelGraphicsPosition(3) );
|
||||
m_model_view->setRotateContinuously( 35.0f );
|
||||
|
||||
// ---- Kart name label
|
||||
@ -721,16 +726,20 @@ public:
|
||||
else
|
||||
{
|
||||
//printf("%s\n", selectionID.c_str());
|
||||
const KartProperties* kart = kart_properties_manager->getKart(selectionID);
|
||||
if (kart == NULL) return;
|
||||
KartModel* kart_model = kart->getKartModel();
|
||||
const KartProperties *kp = kart_properties_manager->getKart(selectionID);
|
||||
const KartModel &kart_model = kp->getMasterKartModel();
|
||||
|
||||
w3->clearModels();
|
||||
w3->addModel( kart_model->getModel(), Vec3(0,0,0), kart_model->getBaseFrame() );
|
||||
w3->addModel( kart_model->getWheelModel(0), kart_model->getWheelGraphicsPosition(0) );
|
||||
w3->addModel( kart_model->getWheelModel(1), kart_model->getWheelGraphicsPosition(1) );
|
||||
w3->addModel( kart_model->getWheelModel(2), kart_model->getWheelGraphicsPosition(2) );
|
||||
w3->addModel( kart_model->getWheelModel(3), kart_model->getWheelGraphicsPosition(3) );
|
||||
w3->addModel( kart_model.getModel(), Vec3(0,0,0),
|
||||
kart_model.getBaseFrame() );
|
||||
w3->addModel( kart_model.getWheelModel(0),
|
||||
kart_model.getWheelGraphicsPosition(0) );
|
||||
w3->addModel( kart_model.getWheelModel(1),
|
||||
kart_model.getWheelGraphicsPosition(1) );
|
||||
w3->addModel( kart_model.getWheelModel(2),
|
||||
kart_model.getWheelGraphicsPosition(2) );
|
||||
w3->addModel( kart_model.getWheelModel(3),
|
||||
kart_model.getWheelGraphicsPosition(3) );
|
||||
w3->update(0);
|
||||
|
||||
m_parent->m_kart_widgets[playerID].m_kart_name->setText( selectionText.c_str() );
|
||||
|
@ -147,7 +147,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, cons
|
||||
{
|
||||
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
||||
|
||||
static int i = 3;
|
||||
static int i = 1;
|
||||
i++;
|
||||
|
||||
if (i % 4 == 0)
|
||||
|
@ -32,7 +32,8 @@ private:
|
||||
NoCopy(const NoCopy& )
|
||||
{ }
|
||||
void operator=(const NoCopy& )
|
||||
{ }}
|
||||
{ }
|
||||
} // NoCopy
|
||||
;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user