From: <hik...@us...> - 2010-02-18 21:23:34
|
Revision: 4762 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4762&view=rev Author: hikerstk Date: 2010-02-18 21:23:26 +0000 (Thu, 18 Feb 2010) Log Message: ----------- Added support for end-race animation (though at this stage no kart model has them). Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-02-18 02:08:11 UTC (rev 4761) +++ main/trunk/src/karts/kart.cpp 2010-02-18 21:23:26 UTC (rev 4762) @@ -395,6 +395,7 @@ // m_controller is not yet defined. if(m_controller) m_controller->reset(); + m_kart_properties->getKartModel()->setEndAnimation(false); m_view_blocked_by_plunger = 0.0; m_attachment.clear(); m_powerup.reset(); @@ -465,6 +466,8 @@ m_controller->finishedRace(time); race_manager->kartFinishedRace(this, time); setController(new EndController(this, m_controller->getPlayer())); + m_kart_properties->getKartModel()->setEndAnimation(true); + m_camera->setMode(Camera::CM_REVERSE); } // finishedRace //----------------------------------------------------------------------------- Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-02-18 02:08:11 UTC (rev 4761) +++ main/trunk/src/karts/kart_model.cpp 2010-02-18 21:23:26 UTC (rev 4762) @@ -48,9 +48,8 @@ m_wheel_filename[2] = "wheel-rear-right.3ds"; m_wheel_filename[3] = "wheel-rear-left.3ds"; m_mesh = NULL; - m_af_left = -1; - m_af_straight = -1; - m_af_right = -1; + for(unsigned int i=AF_BEGIN; i<=AF_END; i++) + m_animation_frame[i]=-1; m_animation_speed = 15; } // KartModel @@ -61,11 +60,13 @@ */ void KartModel::loadInfo(const lisp::Lisp* lisp) { - lisp->get("model-file", m_model_filename ); - lisp->get("animation-left", m_af_left ); - lisp->get("animation-straight", m_af_straight ); - lisp->get("animation-right", m_af_right ); - lisp->get("animation-speed", m_animation_speed); + lisp->get("model-file", m_model_filename ); + lisp->get("animation-left", m_animation_frame[AF_LEFT] ); + lisp->get("animation-straight", m_animation_frame[AF_STRAIGHT] ); + lisp->get("animation-right", m_animation_frame[AF_RIGHT] ); + lisp->get("animation-start-winning", m_animation_frame[AF_WIN_START]); + lisp->get("animation-end-winning", m_animation_frame[AF_WIN_END] ); + lisp->get("animation-speed", m_animation_speed ); loadWheelInfo(lisp, "wheel-front-right", 0); loadWheelInfo(lisp, "wheel-front-left", 1); @@ -210,6 +211,30 @@ } // setDefaultPhysicsPosition // ---------------------------------------------------------------------------- +/** Enables- or disables the end animation. + * \param status True if end animation should be played, false otherwise. + */ +void KartModel::setEndAnimation(bool status) +{ + m_end_animation = status; + if(!m_end_animation) + { + m_node->setLoopMode(false); + m_node->setFrameLoop(m_animation_frame[AF_STRAIGHT], + m_animation_frame[AF_STRAIGHT] ); + } + + if(m_end_animation && m_animation_frame[AF_WIN_START]>-1 && + m_animation_frame[AF_WIN_END]>-1) + { + m_node->setFrameLoop(m_animation_frame[AF_WIN_START], + m_animation_frame[AF_WIN_END] ); + m_node->setLoopMode(true); + m_node->setAnimationSpeed(m_animation_speed); + } +} // setEndAnimation + +// ---------------------------------------------------------------------------- /** Rotates and turns the wheels appropriately, and adjust for suspension. * \param rotation How far the wheels should rotate. * \param visual_steer How much the front wheels are turned for steering. @@ -254,8 +279,12 @@ m_wheel_node[2]->setRotation(wheel_rear ); m_wheel_node[3]->setRotation(wheel_rear ); - if(m_af_left<0) return; // no animations defined + // Check if the end animation is being played, if so, don't + // play steering animation. + if(m_end_animation) return; + if(m_animation_frame[AF_LEFT]<0) return; // no animations defined + // Update animation if necessary // ----------------------------- // FIXME: this implementation is currently very simple, it will always @@ -263,9 +292,13 @@ // (say) 50% of left or right. int end; static int last_end=-1; - if(steer>0.0f) end = m_af_straight-(int)((m_af_straight-m_af_left)*steer); - else if(steer<0.0f) end = m_af_straight+(int)((m_af_straight-m_af_right)*steer); - else end = m_af_straight; + if(steer>0.0f) end = m_animation_frame[AF_STRAIGHT] + - (int)( ( m_animation_frame[AF_STRAIGHT] + -m_animation_frame[AF_LEFT] )*steer); + else if(steer<0.0f) end = m_animation_frame[AF_STRAIGHT] + + (int) ( (m_animation_frame[AF_STRAIGHT] + -m_animation_frame[AF_RIGHT] )*steer); + else end = m_animation_frame[AF_STRAIGHT]; // No changes to current frame loop if(end==last_end) return; Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2010-02-18 02:08:11 UTC (rev 4761) +++ main/trunk/src/karts/kart_model.hpp 2010-02-18 21:23:26 UTC (rev 4762) @@ -39,10 +39,19 @@ class KartModel { private: - /** The frames in which the animation points to the left, straight - * ahead, and to the right. */ - int m_af_left, m_af_straight, m_af_right; + enum AnimationFrameType + {AF_BEGIN, // First animation frame + AF_LEFT = AF_BEGIN, // Steering to the left + AF_STRAIGHT, // Going straight + AF_RIGHT, // Steering to the right + AF_WIN_START, // Begin of win animation + AF_WIN_END, // End of win animation + AF_END=AF_WIN_END, // Last animation frame + AF_COUNT}; // Number of entries here + /** Which frame number starts/end which animation. */ + int m_animation_frame[AF_COUNT]; + /** Animation speed. */ float m_animation_speed; @@ -90,6 +99,8 @@ of wheels in bullet is too large and looks strange). 1=no change, 2=half the amplitude */ float m_dampen_suspension_amplitude[4]; + /** True if the end animation is being shown. */ + bool m_end_animation; float m_kart_width; /**< Width of kart. */ float m_kart_length; /**< Length of kart. */ float m_kart_height; /**< Height of kart. */ @@ -110,7 +121,7 @@ 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 */ - int getBaseFrame() const { return m_af_straight; } + int getBaseFrame() const { return m_animation_frame[AF_STRAIGHT]; } /** Returns the position of a wheel relative to the kart. * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear @@ -141,5 +152,8 @@ float steer, const float suspension[4]); void resetWheels(); void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius); + + /** Enables- or disables the end animation. */ + void setEndAnimation(bool status); }; // KartModel #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mbj...@us...> - 2010-03-07 22:55:04
|
Revision: 4955 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4955&view=rev Author: mbjornstk Date: 2010-03-07 22:54:53 +0000 (Sun, 07 Mar 2010) Log Message: ----------- Abstract engine power to a single call. Now karts are 4WD 40-60 ratio. Real karts are not 4WD, but behaviour seems better while jumping/turning. RWD is easy to put back, or FWD, or any other ratios, no more per wheel calls except if really needed (traction control, differentials, etc). Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-03-07 18:42:04 UTC (rev 4954) +++ main/trunk/src/karts/kart.cpp 2010-03-07 22:54:53 UTC (rev 4955) @@ -433,8 +433,7 @@ setTrans(m_reset_transform); - m_vehicle->applyEngineForce (0.0f, 2); - m_vehicle->applyEngineForce (0.0f, 3); + applyEngineForce (0.0f); Moveable::reset(); if(m_skidmarks) m_skidmarks->reset(); @@ -1082,20 +1081,19 @@ engine_power *= m_power_reduction; // Lose some traction when skidding, so it is not abused by player - // The AI will be allowed to cheat on medium and hard difficulty in - // order to make them more competitive (this might be removed once - // the AI is better). + // The AI will be allowed to cheat on medium and hard difficulty in + // order to make them more competitive (this might be removed once + // the AI is better). if(m_controls.m_drift && (race_manager->getDifficulty()==RaceManager::RD_EASY || m_controller->isPlayerController()) ) engine_power *= 0.5f; - m_vehicle->applyEngineForce(engine_power, 2); - m_vehicle->applyEngineForce(engine_power, 3); + applyEngineForce(engine_power); + // Either all or no brake is set, so test only one to avoid // resetting all brakes most of the time. if(m_vehicle->getWheelInfo(0).m_brake && !World::getWorld()->isStartPhase()) resetBrakes(); - } else { // not accelerating @@ -1103,8 +1101,7 @@ { // check if the player is currently only slowing down or moving backwards if(m_speed > 0.0f) { // going forward - m_vehicle->applyEngineForce(0.f, 2);//engine off - m_vehicle->applyEngineForce(0.f, 3); + applyEngineForce(0.f); //apply the brakes for(int i=0; i<4; i++) m_vehicle->setBrake(getBrakeFactor(), i); @@ -1130,13 +1127,11 @@ float f = 2.5f - 3.8f*(1-m_power_reduction); // Avoid that a kart gets really stuck: if(f<0.1f) f=0.1f; - m_vehicle->applyEngineForce(-engine_power*f, 2); - m_vehicle->applyEngineForce(-engine_power*f, 3); + applyEngineForce(-engine_power*f); } else { - m_vehicle->applyEngineForce(0.f, 2); - m_vehicle->applyEngineForce(0.f, 3); + applyEngineForce(0.0f); } } @@ -1144,8 +1139,7 @@ else { // lift the foot from throttle, brakes with 10% engine_power - m_vehicle->applyEngineForce(-m_controls.m_accel*engine_power*0.1f, 2); - m_vehicle->applyEngineForce(-m_controls.m_accel*engine_power*0.1f, 3); + applyEngineForce(-m_controls.m_accel*engine_power*0.1f); #if 1 // If not giving power (forward or reverse gear), and speed is low @@ -1348,6 +1342,31 @@ } // setSuspensionLength //----------------------------------------------------------------------------- +/** Applies engine power to all the wheels that are traction capable, + * so other parts of code do not have to be adjusted to simulate different + * kinds of vehicles in the general case, only if they are trying to + * simulate traction control, diferentials or multiple independent electric + * engines, they will have to tweak the power in a per wheel basis. + */ +void Kart::applyEngineForce(float force) +{ + // Split power to simulate a 4WD 40-60, other values possible + // FWD or RWD is a matter of putting a 0 and 1 in the right place + float frontForce = force*0.4f; + float rearForce = force*0.6f; + // Front wheels + for(unsigned int i=0; i<2; i++) + { + m_vehicle->applyEngineForce (frontForce, i); + } + // Rear wheels + for(unsigned int i=2; i<4; i++) + { + m_vehicle->applyEngineForce (rearForce, i); + } +} // applyEngineForce + +//----------------------------------------------------------------------------- void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr) { float wheel_z_axis[4]; Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-03-07 18:42:04 UTC (rev 4954) +++ main/trunk/src/karts/kart.hpp 2010-03-07 22:54:53 UTC (rev 4955) @@ -336,6 +336,7 @@ * from the server information. */ void setSpeed (float s) {m_speed = s; } void setSuspensionLength(); + void applyEngineForce (float force); float handleNitro (float dt); float getActualWheelForce(); /** True if the wheels are touching the ground. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-03-22 11:00:54
|
Revision: 5043 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5043&view=rev Author: hikerstk Date: 2010-03-22 11:00:47 +0000 (Mon, 22 Mar 2010) Log Message: ----------- Removed unused variable. Modified Paths: -------------- main/trunk/src/karts/moveable.cpp main/trunk/src/karts/moveable.hpp Modified: main/trunk/src/karts/moveable.cpp =================================================================== --- main/trunk/src/karts/moveable.cpp 2010-03-22 02:06:01 UTC (rev 5042) +++ main/trunk/src/karts/moveable.cpp 2010-03-22 11:00:47 UTC (rev 5043) @@ -30,7 +30,6 @@ { m_body = 0; m_motion_state = 0; - m_first_time = true; m_mesh = NULL; m_node = NULL; } // Moveable @@ -109,7 +108,6 @@ m_roll = atan2(up.getX(), up.getY()); updateGraphics(Vec3(0,0,0), btQuaternion(0, 0, 0, 1)); - m_first_time = false ; } // update //----------------------------------------------------------------------------- Modified: main/trunk/src/karts/moveable.hpp =================================================================== --- main/trunk/src/karts/moveable.hpp 2010-03-22 02:06:01 UTC (rev 5042) +++ main/trunk/src/karts/moveable.hpp 2010-03-22 11:00:47 UTC (rev 5043) @@ -55,7 +55,6 @@ UserPointer m_user_pointer; scene::IMesh *m_mesh; scene::ISceneNode *m_node; - int m_first_time ; btRigidBody *m_body; KartMotionState *m_motion_state; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-04-08 12:45:27
|
Revision: 5132 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5132&view=rev Author: hikerstk Date: 2010-04-08 12:45:21 +0000 (Thu, 08 Apr 2010) Log Message: ----------- Added support for lose animations (and better support for other animations). Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp main/trunk/src/karts/kart_properties.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-04-08 01:48:57 UTC (rev 5131) +++ main/trunk/src/karts/kart.cpp 2010-04-08 12:45:21 UTC (rev 5132) @@ -46,10 +46,10 @@ #include "physics/btKart.hpp" #include "physics/btUprightConstraint.hpp" #include "physics/physics.hpp" +#include "race/history.hpp" #include "tracks/track.hpp" #include "utils/constants.hpp" #include "utils/coord.hpp" -#include "audio/sfx_manager.hpp" #if defined(WIN32) && !defined(__CYGWIN__) // Disable warning for using 'this' in base member initializer list @@ -388,7 +388,7 @@ m_controller = m_saved_controller; m_saved_controller = NULL; } - m_kart_properties->getKartModel()->setEndAnimation(false); + m_kart_properties->getKartModel()->setAnimation(KartModel::AF_DEFAULT); m_view_blocked_by_plunger = 0.0; m_attachment.clear(); m_powerup.reset(); @@ -469,7 +469,11 @@ { // in modes that support it, start end animation setController(new EndController(this, m_controller->getPlayer())); - m_kart_properties->getKartModel()->setEndAnimation(true); + if(m_race_position<=0.5f*race_manager->getNumberOfKarts() || + m_race_position==1) + m_kart_properties->getKartModel()->setAnimation(KartModel::AF_WIN_START); + else + m_kart_properties->getKartModel()->setAnimation(KartModel::AF_LOSE_START); // Not all karts have a camera if (m_camera) m_camera->setMode(Camera::CM_REVERSE); @@ -485,8 +489,11 @@ { // start end animation setController(new EndController(this, m_controller->getPlayer())); - m_kart_properties->getKartModel()->setEndAnimation(true); - + if(m_race_position<=2) + m_kart_properties->getKartModel()->setAnimation(KartModel::AF_WIN_START); + else if(m_race_position>=0.7f*race_manager->getNumberOfKarts()) + m_kart_properties->getKartModel()->setAnimation(KartModel::AF_LOSE_START); + // Not all karts have a camera if (m_camera) m_camera->setMode(Camera::CM_REVERSE); @@ -647,7 +654,8 @@ //----------------------------------------------------------------------------- void Kart::update(float dt) { - m_controller->update(dt); + if(!history->replayHistory()) + m_controller->update(dt); if(m_camera) m_camera->update(dt); // if its view is blocked by plunger, decrease remaining time Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-04-08 01:48:57 UTC (rev 5131) +++ main/trunk/src/karts/kart_model.cpp 2010-04-08 12:45:21 UTC (rev 5132) @@ -52,6 +52,7 @@ for(unsigned int i=AF_BEGIN; i<=AF_END; i++) m_animation_frame[i]=-1; m_animation_speed = 15; + m_current_animation = AF_DEFAULT; } // KartModel // ---------------------------------------------------------------------------- @@ -64,12 +65,16 @@ node.get("model-file", &m_model_filename); if(const XMLNode *animation_node=node.getNode("animations")) { - animation_node->get("left", &m_animation_frame[AF_LEFT] ); - animation_node->get("straight", &m_animation_frame[AF_STRAIGHT] ); - animation_node->get("right", &m_animation_frame[AF_RIGHT] ); - animation_node->get("start-winning", &m_animation_frame[AF_WIN_START]); - animation_node->get("end-winning", &m_animation_frame[AF_WIN_END] ); - animation_node->get("speed", &m_animation_speed ); + animation_node->get("left", &m_animation_frame[AF_LEFT] ); + animation_node->get("straight", &m_animation_frame[AF_STRAIGHT] ); + animation_node->get("right", &m_animation_frame[AF_RIGHT] ); + animation_node->get("start-winning", &m_animation_frame[AF_WIN_START] ); + animation_node->get("end-winning", &m_animation_frame[AF_WIN_END] ); + animation_node->get("start-losing", &m_animation_frame[AF_LOSE_START]); + animation_node->get("end-losing", &m_animation_frame[AF_LOSE_END] ); + animation_node->get("start-explosion",&m_animation_frame[AF_LOSE_START]); + animation_node->get("end-explosion", &m_animation_frame[AF_LOSE_END] ); + animation_node->get("speed", &m_animation_speed ); } if(const XMLNode *wheels_node=node.getNode("wheels")) @@ -113,6 +118,12 @@ std::string full_path = kart_properties.getKartDir()+"/"+m_model_filename; m_mesh = irr_driver->getAnimatedMesh(full_path); Vec3 min, max; + if(!m_mesh) + { + printf("Problems loading mesh '%s' - aborting.\n", + full_path.c_str()); + exit(-2); + } MeshTools::minMax3D(m_mesh, &min, &max); Vec3 size = max-min; m_z_offset = min.getZ(); @@ -222,21 +233,21 @@ /** Enables- or disables the end animation. * \param status True if end animation should be played, false otherwise. */ -void KartModel::setEndAnimation(bool status) +void KartModel::setAnimation(AnimationFrameType type) { - m_end_animation = status; - if(!m_end_animation) + m_current_animation = type; + if(!m_current_animation==AF_DEFAULT) { m_node->setLoopMode(false); m_node->setFrameLoop(m_animation_frame[AF_STRAIGHT], m_animation_frame[AF_STRAIGHT] ); } - if(m_end_animation && m_animation_frame[AF_WIN_START]>-1 && - m_animation_frame[AF_WIN_END]>-1) + if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1) { - m_node->setFrameLoop(m_animation_frame[AF_WIN_START], - m_animation_frame[AF_WIN_END] ); + AnimationFrameType end = (AnimationFrameType)(type+1); + m_node->setFrameLoop(m_animation_frame[type], + m_animation_frame[end] ); m_node->setLoopMode(true); m_node->setAnimationSpeed(m_animation_speed); } @@ -288,7 +299,7 @@ // Check if the end animation is being played, if so, don't // play steering animation. - if(m_end_animation) return; + if(m_current_animation!=AF_DEFAULT) return; if(m_animation_frame[AF_LEFT]<0) return; // no animations defined Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2010-04-08 01:48:57 UTC (rev 5131) +++ main/trunk/src/karts/kart_model.hpp 2010-04-08 12:45:21 UTC (rev 5132) @@ -38,17 +38,22 @@ */ class KartModel { +public: + enum AnimationFrameType + {AF_BEGIN, // First animation frame + AF_DEFAULT = AF_BEGIN, // Default, i.e. steering animation + AF_LEFT, // Steering to the left + AF_STRAIGHT, // Going straight + AF_RIGHT, // Steering to the right + AF_LOSE_START, // Begin losing animation + AF_LOSE_END, // End losing animation + AF_BEGIN_EXPLOSION, // Begin explosion animation + AF_END_EXPLOSION, // End explosion animation + AF_WIN_START, // Begin of win animation + AF_WIN_END, // End of win animation + AF_END=AF_WIN_END, // Last animation frame + AF_COUNT}; // Number of entries here private: - enum AnimationFrameType - {AF_BEGIN, // First animation frame - AF_LEFT = AF_BEGIN, // Steering to the left - AF_STRAIGHT, // Going straight - AF_RIGHT, // Steering to the right - AF_WIN_START, // Begin of win animation - AF_WIN_END, // End of win animation - AF_END=AF_WIN_END, // Last animation frame - AF_COUNT}; // Number of entries here - /** Which frame number starts/end which animation. */ int m_animation_frame[AF_COUNT]; @@ -69,7 +74,7 @@ std::string m_model_filename; /** The four wheel models. */ - scene::IMesh *m_wheel_model[4]; + scene::IMesh *m_wheel_model[4]; /** The four scene nodes the wheels are attached to */ scene::ISceneNode *m_wheel_node[4]; @@ -99,8 +104,11 @@ of wheels in bullet is too large and looks strange). 1=no change, 2=half the amplitude */ float m_dampen_suspension_amplitude[4]; - /** True if the end animation is being shown. */ - bool m_end_animation; + /** Which animation is currently being played. This is used to overwrite + * the default steering animations while being in race. If this is set + * to AF_DEFAULT the default steering animation is shown. */ + AnimationFrameType m_current_animation; + float m_kart_width; /**< Width of kart. */ float m_kart_length; /**< Length of kart. */ float m_kart_height; /**< Height of kart. */ @@ -154,6 +162,6 @@ void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius); /** Enables- or disables the end animation. */ - void setEndAnimation(bool status); + void setAnimation(AnimationFrameType type); }; // KartModel #endif Modified: main/trunk/src/karts/kart_properties.hpp =================================================================== --- main/trunk/src/karts/kart_properties.hpp 2010-04-08 01:48:57 UTC (rev 5131) +++ main/trunk/src/karts/kart_properties.hpp 2010-04-08 12:45:21 UTC (rev 5132) @@ -43,18 +43,26 @@ { private: /** Base directory for this kart. */ - std::string m_root; - Material *m_icon_material; /**< The icon texture to use. */ + std::string m_root; + + /** The icon texture to use. */ + Material *m_icon_material; + /** The kart model and wheels. It is mutable since the wheels of the - * KartModel can rotate and turn, but otherwise the kart_properties - * object is const. */ - mutable KartModel m_kart_model; - std::vector<std::string> m_groups; /**< List of all groups the kart - belongs to. */ + * KartModel can rotate and turn, and animations are played, but otherwise + * the kart_properties object is const. */ + mutable KartModel m_kart_model; + + /** List of all groups the kart belongs to. */ + std::vector<std::string> m_groups; static float UNDEFINED; - float m_speed_angle_increase; /**< Increase of turn angle with speed. */ - int m_version; /**< Version of the .kart file. */ + /** Increase of turn angle with speed. */ + float m_speed_angle_increase; + + /** Version of the .kart file. */ + int m_version; + // SFX files // --------------- std::vector<int> m_custom_sfx_id; /**< Vector of custom SFX ids */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-04-21 00:16:53
|
Revision: 5224 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5224&view=rev Author: hikerstk Date: 2010-04-21 00:16:43 +0000 (Wed, 21 Apr 2010) Log Message: ----------- Removed debug printf statement, removed global variables (which I swear was only done to avoid a complete recompile, since the laptop's battery were nearly empty). Modified Paths: -------------- main/trunk/src/karts/explosion_animation.cpp main/trunk/src/karts/explosion_animation.hpp main/trunk/src/karts/kart.cpp Modified: main/trunk/src/karts/explosion_animation.cpp =================================================================== --- main/trunk/src/karts/explosion_animation.cpp 2010-04-20 23:50:38 UTC (rev 5223) +++ main/trunk/src/karts/explosion_animation.cpp 2010-04-21 00:16:43 UTC (rev 5224) @@ -24,9 +24,6 @@ #include "tracks/track.hpp" #include "utils/constants.hpp" -Vec3 m_add_rotation; -Vec3 m_curr_rotation; - /** The constructor stores a pointer to the kart this object is animating, * and initialised the timer. * \param kart Pointer to the kart which is animated. Modified: main/trunk/src/karts/explosion_animation.hpp =================================================================== --- main/trunk/src/karts/explosion_animation.hpp 2010-04-20 23:50:38 UTC (rev 5223) +++ main/trunk/src/karts/explosion_animation.hpp 2010-04-21 00:16:43 UTC (rev 5224) @@ -40,9 +40,13 @@ /** The coordinates where the kart was hit originally. */ Vec3 m_xyz; - /** The rotation of the kart at the time of the explosion. */ - Vec3 m_hpr; + /** The kart's current rotation. */ + Vec3 m_curr_rotation; + /** The artificial rotation to toss the kart around. It's in units + * of rotation per second. */ + Vec3 m_add_rotation; + /** The upwards velocity. */ float m_up_velocity; Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-04-20 23:50:38 UTC (rev 5223) +++ main/trunk/src/karts/kart.cpp 2010-04-21 00:16:43 UTC (rev 5224) @@ -633,7 +633,6 @@ int sign_bits = rand(); // To select plus or minus randomnly, assuming 15 bit at least if(direct_hit) { - printf("he: "); ExplosionAnimation::handleExplosion(pos, direct_hit); m_kart_mode = KM_EXPLOSION; // Play associated kart sound This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-04-22 13:22:37
|
Revision: 5240 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5240&view=rev Author: hikerstk Date: 2010-04-22 13:22:31 +0000 (Thu, 22 Apr 2010) Log Message: ----------- Forgot to remove these files in previous commit. Removed Paths: ------------- main/trunk/src/karts/explosion_animation.cpp main/trunk/src/karts/explosion_animation.hpp Deleted: main/trunk/src/karts/explosion_animation.cpp =================================================================== --- main/trunk/src/karts/explosion_animation.cpp 2010-04-22 13:21:35 UTC (rev 5239) +++ main/trunk/src/karts/explosion_animation.cpp 2010-04-22 13:22:31 UTC (rev 5240) @@ -1,98 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010 Joerg Henrichs -// -// 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. - -#include "karts/explosion_animation.hpp" - -#include "karts/kart.hpp" -#include "modes/world.hpp" -#include "tracks/track.hpp" -#include "utils/constants.hpp" - -/** The constructor stores a pointer to the kart this object is animating, - * and initialised the timer. - * \param kart Pointer to the kart which is animated. - */ -ExplosionAnimation::ExplosionAnimation(Kart *kart) -{ - m_timer = -1; - m_kart = kart; -}; // ExplosionAnimation - -// ---------------------------------------------------------------------------- -/** Starts an explosion animation. - * \param pos The coordinates of the explosion. - * \param direct_hig True if the kart was hit directly --> maximal impact. - */ -void ExplosionAnimation::handleExplosion(const Vec3 &pos, bool direct_hit) -{ - // Avoid doing another explosion while a kart is thrown around in the air. - if(m_timer>=0) return; - - m_timer = 0; - m_xyz = m_kart->getXYZ(); - - float t = m_kart->getKartProperties()->getExplosionTime(); - - // Half of the overall time is spent in raising, so only use - // half of the explosion time here. - // Velocity after t seconds is: - // v(t) = m_up_velocity + t*gravity - // Since v(explosion_time*0.5) = 0, the following forumla computes - // the right initial velocity for a kart to land back after - // the specified time. - m_up_velocity = 0.5f * t * World::getWorld()->getTrack()->getGravity(); - World::getWorld()->getPhysics()->removeKart(m_kart); - - m_curr_rotation.setHPR(m_kart->getRotation()); - const int max_rotation = direct_hit ? 2 : 1; - // To get rotations in botb directions for each axis we determine a random - // number between -(max_rotation-1) and +(max_rotation-1) - float f=2.0f*M_PI/t; - m_add_rotation.setHeading( (rand()%(2*max_rotation+1)-max_rotation)*f ); - m_add_rotation.setPitch( (rand()%(2*max_rotation+1)-max_rotation)*f ); - m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); - -} // handleExplosion - -// ---------------------------------------------------------------------------- -/** Updates the explosion animation. - * \param dt Time step size. - * \return True if the explosion is still shown, false if it has finished. - */ -bool ExplosionAnimation::update(float dt) -{ - assert(m_timer>=0); - m_timer += dt; - if(m_timer>m_kart->getKartProperties()->getExplosionTime()) - { - m_timer=-1; - World::getWorld()->getPhysics()->addKart(m_kart); - m_kart->getBody()->setLinearVelocity(btVector3(0,0,0)); - m_kart->getBody()->setAngularVelocity(btVector3(0,0,0)); - return false; - } - m_up_velocity -= dt*World::getWorld()->getTrack()->getGravity(); - m_xyz.setY(m_xyz.getY()+m_up_velocity*dt); - m_kart->setXYZ(m_xyz); - m_curr_rotation += dt*m_add_rotation; - btQuaternion q(m_curr_rotation.getHeading(), m_curr_rotation.getPitch(), - m_curr_rotation.getRoll()); - m_kart->setRotation(q); - return true; -} // update \ No newline at end of file Deleted: main/trunk/src/karts/explosion_animation.hpp =================================================================== --- main/trunk/src/karts/explosion_animation.hpp 2010-04-22 13:21:35 UTC (rev 5239) +++ main/trunk/src/karts/explosion_animation.hpp 2010-04-22 13:22:31 UTC (rev 5240) @@ -1,70 +0,0 @@ -// $Id$ -// -// SuperTuxKart - a fun racing game with go-kart -// Copyright (C) 2010 Joerg Henrichs -// -// 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_EXPLOSION_ANIMATION_HPP -#define HEADER_EXPLOSION_ANIMATION_HPP - -#include "utils/vec3.hpp" - -class Kart; - -/** This class is a 'mixin' for kart, and handles the animated explosion. - * I.e. it will throw the kart a certain amount in the air, rotate it - * randomly, and after the specified time period let it land at the - * same spot where it was hit, therefore avoiding any problems of - * karts being pushed on wrong parts of the track, and making explosion - * more 'fair' (it can't happen that one explosion give you actually - * a benefit by pushing you forwards. - * The object is a base class for kart, but will only be used if an - * explosion happens. - */ -class ExplosionAnimation -{ -private: - /** The coordinates where the kart was hit originally. */ - Vec3 m_xyz; - - /** The kart's current rotation. */ - Vec3 m_curr_rotation; - - /** The artificial rotation to toss the kart around. It's in units - * of rotation per second. */ - Vec3 m_add_rotation; - - /** The upwards velocity. */ - float m_up_velocity; - - /** Timer for the explosion. */ - float m_timer; - - /** Duration for this explosion. This can potentially be set - * with different values for different karts, or depending - * on difficulty (so that on easy you can drive again earlier. */ - float m_duration; - - /** A pointer to the class to which this object belongs. */ - Kart *m_kart; - -public: - ExplosionAnimation(Kart *kart); - ~ExplosionAnimation() {}; - void handleExplosion(const Vec3& pos, bool direct_hit); - bool update(float dt); -}; // ExplosionAnimation -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-06-29 11:15:09
|
Revision: 5591 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5591&view=rev Author: hikerstk Date: 2010-06-29 11:15:00 +0000 (Tue, 29 Jun 2010) Log Message: ----------- 1) Fixed 'shaking' of kart, which happens esp. in end- and reverse camera (reason was that camera used the previous kart position to adjust the camera settings, while the karts were shown at the new position. This becomes a problem if bullet does more than one time step, since then the usually fixed offset is changes, which is visible). 2) Removed debug output. Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/moveable.cpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-06-29 11:11:03 UTC (rev 5590) +++ main/trunk/src/karts/kart.cpp 2010-06-29 11:15:00 UTC (rev 5591) @@ -621,6 +621,9 @@ */ void Kart::update(float dt) { + // Update the position and other data taken from the physics + Moveable::update(dt); + if(!history->replayHistory()) m_controller->update(dt); if(m_camera) @@ -695,8 +698,6 @@ updatePhysics(dt); - Moveable::update(dt); - /* (TODO: add back when properly done) for (int n = 0; n < SFXManager::NUM_CUSTOMS; n++) { Modified: main/trunk/src/karts/moveable.cpp =================================================================== --- main/trunk/src/karts/moveable.cpp 2010-06-29 11:11:03 UTC (rev 5590) +++ main/trunk/src/karts/moveable.cpp 2010-06-29 11:15:00 UTC (rev 5591) @@ -63,10 +63,6 @@ void Moveable::updateGraphics(const Vec3& offset_xyz, const btQuaternion& rotation) { -#ifdef DEBUG_PRINT - printf("moveable: %f %f (%f %f)\n", getXYZ().getX(), getXYZ().getZ(), - off_xyz.getX(), off_xyz.getZ()); -#endif Vec3 xyz=getXYZ()+offset_xyz; btQuaternion r_all = getRotation()*rotation; Vec3 hpr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-07-04 22:51:51
|
Revision: 5629 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5629&view=rev Author: hikerstk Date: 2010-07-04 22:51:45 +0000 (Sun, 04 Jul 2010) Log Message: ----------- Added support for a sequence of frame to be played in an animation before the actual animation loop starts. Modified Paths: -------------- main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp main/trunk/src/karts/kart_properties.hpp Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-07-04 22:49:13 UTC (rev 5628) +++ main/trunk/src/karts/kart_model.cpp 2010-07-04 22:51:45 UTC (rev 5629) @@ -51,7 +51,7 @@ m_mesh = NULL; for(unsigned int i=AF_BEGIN; i<=AF_END; i++) m_animation_frame[i]=-1; - m_animation_speed = 15; + m_animation_speed = 25; m_current_animation = AF_DEFAULT; } // KartModel @@ -69,8 +69,12 @@ animation_node->get("straight", &m_animation_frame[AF_STRAIGHT] ); animation_node->get("right", &m_animation_frame[AF_RIGHT] ); animation_node->get("start-winning", &m_animation_frame[AF_WIN_START] ); + animation_node->get("start-winning-loop", + &m_animation_frame[AF_WIN_LOOP_START] ); animation_node->get("end-winning", &m_animation_frame[AF_WIN_END] ); animation_node->get("start-losing", &m_animation_frame[AF_LOSE_START]); + animation_node->get("start-losing-loop", + &m_animation_frame[AF_LOSE_LOOP_START]); animation_node->get("end-losing", &m_animation_frame[AF_LOSE_END] ); animation_node->get("start-explosion",&m_animation_frame[AF_LOSE_START]); animation_node->get("end-explosion", &m_animation_frame[AF_LOSE_END] ); @@ -246,7 +250,7 @@ // ---------------------------------------------------------------------------- /** Enables- or disables the end animation. - * \param status True if end animation should be played, false otherwise. + * \param type The type of animation to play. */ void KartModel::setAnimation(AnimationFrameType type) { @@ -257,20 +261,61 @@ { m_animated_node->setLoopMode(false); m_animated_node->setFrameLoop(m_animation_frame[AF_STRAIGHT], - m_animation_frame[AF_STRAIGHT] ); + m_animation_frame[AF_STRAIGHT] ); + m_animated_node->setAnimationEndCallback(NULL); } if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1) { - AnimationFrameType end = (AnimationFrameType)(type+1); + // 'type' is the start frame of the animation, type + 1 the frame + // to begin the loop with, type + 2 to end the frame with + AnimationFrameType end = (AnimationFrameType)(type+2); + m_animated_node->setAnimationSpeed(m_animation_speed); m_animated_node->setFrameLoop(m_animation_frame[type], - m_animation_frame[end] ); - m_animated_node->setLoopMode(true); - m_animated_node->setAnimationSpeed(m_animation_speed); + m_animation_frame[end] ); + // Loop mode must be set to false so that we get a callback when + // the first iteration is finished. + m_animated_node->setLoopMode(false); + m_animated_node->setAnimationEndCallback(this); } } // setEndAnimation // ---------------------------------------------------------------------------- +/** Called from irrlicht when a non-looped animation ends. This is used to + * implement an introductory frame sequence before the actual loop can + * start: first a non-looped version from the first frame to the last + * frame is being played. When this is finished, this function is called, + * which then enables the actual loop. + * \param node The node for which the animation ended. Should always be + * m_animated_node + */ +void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node) +{ + // It should only be called for the animated node of this + // kart_model + assert(node==m_animated_node); + + // It should be a non-default type of animation, and should have + // a non negative frame (i.e. the animation is indeed defined). + assert(m_current_animation!=AF_DEFAULT); + assert(m_animation_frame[m_current_animation]>-1 ); + + // 'type' is the start frame of the animation, type + 1 the frame + // to begin the loop with, type + 2 to end the frame with + AnimationFrameType start = (AnimationFrameType)(m_current_animation+1); + // If there is no loop-start defined (i.e. no 'introductory' sequence) + // use the normal start frame. + if(m_animation_frame[start]==-1) + start = m_current_animation; + AnimationFrameType end = (AnimationFrameType)(m_current_animation+2); + m_animated_node->setAnimationSpeed(m_animation_speed); + m_animated_node->setFrameLoop(m_animation_frame[start], + m_animation_frame[end] ); + m_animated_node->setLoopMode(true); + m_animated_node->setAnimationEndCallback(NULL); +} // OnAnimationEnd + +// ---------------------------------------------------------------------------- /** Rotates and turns the wheels appropriately, and adjust for suspension. * \param rotation How far the wheels should rotate. * \param visual_steer How much the front wheels are turned for steering. @@ -346,13 +391,13 @@ // the animation speed to a negative number. if(begin<end) { + m_animated_node->setAnimationSpeed(m_animation_speed); m_animated_node->setFrameLoop(begin, end); - m_animated_node->setAnimationSpeed(m_animation_speed); } else { + m_animated_node->setAnimationSpeed(-m_animation_speed); m_animated_node->setFrameLoop(begin, end); - m_animated_node->setAnimationSpeed(-m_animation_speed); } } // update Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2010-07-04 22:49:13 UTC (rev 5628) +++ main/trunk/src/karts/kart_model.hpp 2010-07-04 22:51:45 UTC (rev 5629) @@ -39,7 +39,7 @@ * OpenGL library used. * \ingroup karts */ -class KartModel +class KartModel : public scene::IAnimationEndCallBack { public: enum AnimationFrameType @@ -49,10 +49,12 @@ AF_STRAIGHT, // Going straight AF_RIGHT, // Steering to the right AF_LOSE_START, // Begin losing animation + AF_LOSE_LOOP_START, // Begin of the losing loop AF_LOSE_END, // End losing animation AF_BEGIN_EXPLOSION, // Begin explosion animation AF_END_EXPLOSION, // End explosion animation AF_WIN_START, // Begin of win animation + AF_WIN_LOOP_START, // Begin of win loop animation AF_WIN_END, // End of win animation AF_END=AF_WIN_END, // Last animation frame AF_COUNT}; // Number of entries here @@ -122,6 +124,8 @@ void loadWheelInfo(const XMLNode &node, const std::string &wheel_name, int index); + void OnAnimationEnd(scene::IAnimatedMeshSceneNode *node); + public: KartModel(); ~KartModel(); Modified: main/trunk/src/karts/kart_properties.hpp =================================================================== --- main/trunk/src/karts/kart_properties.hpp 2010-07-04 22:49:13 UTC (rev 5628) +++ main/trunk/src/karts/kart_properties.hpp 2010-07-04 22:51:45 UTC (rev 5629) @@ -62,7 +62,7 @@ /** 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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-08-31 13:24:32
|
Revision: 5836 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5836&view=rev Author: hikerstk Date: 2010-08-31 13:04:04 +0000 (Tue, 31 Aug 2010) Log Message: ----------- Removed now unnecessary heading,pitch,roll variable m_hpr. Modified Paths: -------------- main/trunk/src/karts/moveable.cpp main/trunk/src/karts/moveable.hpp Modified: main/trunk/src/karts/moveable.cpp =================================================================== --- main/trunk/src/karts/moveable.cpp 2010-08-31 10:30:26 UTC (rev 5835) +++ main/trunk/src/karts/moveable.cpp 2010-08-31 13:04:04 UTC (rev 5836) @@ -83,7 +83,6 @@ } m_node->setVisible(true); // In case that the objects was eliminated - m_hpr.setHPR(m_transform.getRotation()); Vec3 up = getTrans().getBasis().getColumn(1); m_pitch = atan2(up.getZ(), fabsf(up.getY())); m_roll = atan2(up.getX(), up.getY()); @@ -100,7 +99,6 @@ { m_motion_state->getWorldTransform(m_transform); m_velocityLC = getVelocity()*m_transform.getBasis(); - m_hpr.setHPR(m_transform.getRotation()); Vec3 forw_vec = m_transform.getBasis().getColumn(0); m_heading = -atan2f(forw_vec.getZ(), forw_vec.getX()); @@ -138,7 +136,6 @@ // functions are not called correctly. So only init the pointer to zero. m_user_pointer.zero(); m_body->setUserPointer(&m_user_pointer); - m_hpr.setHPR(m_body->getWorldTransform().getRotation()); } // createBody //----------------------------------------------------------------------------- Modified: main/trunk/src/karts/moveable.hpp =================================================================== --- main/trunk/src/karts/moveable.hpp 2010-08-31 10:30:26 UTC (rev 5835) +++ main/trunk/src/karts/moveable.hpp 2010-08-31 13:04:04 UTC (rev 5836) @@ -44,9 +44,7 @@ private: btVector3 m_velocityLC; /**<Velocity in kart coordinates. */ btTransform m_transform; - Vec3 m_hpr; - /** The heading in m_hpr is between -90 and 90 degrees only. The 'real' - * heading between -180 to 180 degrees is stored in this variable. */ + /** The 'real' heading between -180 to 180 degrees. */ float m_heading; /** The pitch between -90 and 90 degrees. */ float m_pitch; @@ -73,8 +71,6 @@ &getVelocityLC() const {return m_velocityLC; } virtual void setVelocity(const btVector3& v) {m_body->setLinearVelocity(v); } const Vec3& getXYZ() const {return (Vec3&)m_transform.getOrigin();} - /** Return the rotation, but heading is restricted to -90 and 90 degrees. */ - const Vec3& getHPR() const {return m_hpr; } /** Returns the heading between -180 and 180 degrees. Note that using * getHPR().getHeading() can result a different heading (e.g. a heading * of 180 degrees is the same as a roll and pitch around 180).*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-06 11:07:47
|
Revision: 5901 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5901&view=rev Author: hikerstk Date: 2010-09-06 11:07:41 +0000 (Mon, 06 Sep 2010) Log Message: ----------- Fixed missing stars animation, which is now moved completely into EmergencyAnimation (see bug 3059588). Modified Paths: -------------- main/trunk/src/karts/emergency_animation.cpp main/trunk/src/karts/emergency_animation.hpp main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/emergency_animation.cpp =================================================================== --- main/trunk/src/karts/emergency_animation.cpp 2010-09-05 23:44:07 UTC (rev 5900) +++ main/trunk/src/karts/emergency_animation.cpp 2010-09-06 11:07:41 UTC (rev 5901) @@ -19,6 +19,7 @@ #include "karts/emergency_animation.hpp" +#include "graphics/stars.hpp" #include "karts/kart.hpp" #include "modes/world.hpp" #include "physics/btKart.hpp" @@ -31,21 +32,36 @@ */ EmergencyAnimation::EmergencyAnimation(Kart *kart) { - m_kart = kart; + m_stars_effect = NULL; + m_kart = kart; // Setting kart mode here is important! If the mode should be rescue when // reset() is called, it is assumed that this was triggered by a restart, // and that the vehicle must be added back to the physics world. Since // reset() is also called at the very start, it must be guaranteed that // rescue is not set. - m_kart_mode = EA_NONE; + m_kart_mode = EA_NONE; }; // EmergencyAnimation //----------------------------------------------------------------------------- +EmergencyAnimation::~EmergencyAnimation() +{ + if(m_stars_effect) + delete m_stars_effect; +} // ~EmergencyAnimation + +//----------------------------------------------------------------------------- /** Resets all data at the beginning of a race. */ void EmergencyAnimation::reset() { + // Create the stars effect in the first reset + if(!m_stars_effect) + m_stars_effect = new Stars(m_kart->getNode()); + + // Reset star effect in case that it is currently being shown. + m_stars_effect->reset(); + // If the kart was eliminated or rescued, the body was removed from the // physics world. Add it again. if(playingEmergencyAnimation()) @@ -124,6 +140,7 @@ m_add_rotation.setHeading( (rand()%(2*max_rotation+1)-max_rotation)*f ); m_add_rotation.setPitch( (rand()%(2*max_rotation+1)-max_rotation)*f ); m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f ); + m_stars_effect->showFor(6.0f); } // handleExplosion @@ -134,6 +151,12 @@ */ void EmergencyAnimation::update(float dt) { + if ( UserConfigParams::m_graphical_effects ) + { + // update star effect (call will do nothing if stars are not activated) + m_stars_effect->update(dt); + } + if(!playingEmergencyAnimation()) return; // See if the timer expires, if so return the kart to normal game play Modified: main/trunk/src/karts/emergency_animation.hpp =================================================================== --- main/trunk/src/karts/emergency_animation.hpp 2010-09-05 23:44:07 UTC (rev 5900) +++ main/trunk/src/karts/emergency_animation.hpp 2010-09-06 11:07:41 UTC (rev 5901) @@ -23,6 +23,7 @@ #include "utils/vec3.hpp" class Kart; +class Stars; /** * \brief This class is a 'mixin' for kart, and handles the animated explosion. @@ -63,13 +64,16 @@ /** A pointer to the class to which this object belongs. */ Kart *m_kart; + /** For stars rotating around head effect */ + Stars *m_stars_effect; + /** Different kart modes: normal racing, being rescued, showing end * animation, explosions, kart eliminated. */ enum {EA_NONE, EA_RESCUE, EA_EXPLOSION} m_kart_mode; public: EmergencyAnimation(Kart *kart); - ~EmergencyAnimation() {}; + ~EmergencyAnimation(); void reset(); void handleExplosion(const Vec3& pos, bool direct_hit); void forceRescue(); Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-05 23:44:07 UTC (rev 5900) +++ main/trunk/src/karts/kart.cpp 2010-09-06 11:07:41 UTC (rev 5901) @@ -34,7 +34,6 @@ #include "graphics/skid_marks.hpp" #include "graphics/slip_stream.hpp" #include "graphics/smoke.hpp" -#include "graphics/stars.hpp" #include "graphics/water_splash.hpp" #include "modes/world.hpp" #include "io/file_manager.hpp" @@ -83,7 +82,6 @@ m_shadow_enabled = false; m_shadow = NULL; m_smoke_system = NULL; - m_stars_effect = NULL; m_water_splash_system = NULL; m_nitro = NULL; m_slip_stream = NULL; @@ -307,7 +305,6 @@ if(m_slip_stream) delete m_slip_stream; delete m_shadow; - delete m_stars_effect; if(m_skidmarks) delete m_skidmarks ; @@ -438,8 +435,6 @@ m_controls.m_drift = false; m_controls.m_fire = false; m_controls.m_look_back = false; - // Reset star effect in case that it is currently being shown. - m_stars_effect->reset(); m_slip_stream->reset(); m_vehicle->deactivateZipper(); @@ -708,9 +703,6 @@ m_water_splash_system->update(dt); m_nitro->update(dt); m_slip_stream->update(dt); - // update star effect (call will do nothing if stars are not activated) - m_stars_effect->update(dt); - } // UserConfigParams::m_graphical_effects updatePhysics(dt); @@ -1377,8 +1369,6 @@ m_shadow = new Shadow(m_kart_properties->getShadowTexture(), m_node); - - m_stars_effect = new Stars(m_node); } // loadData //----------------------------------------------------------------------------- Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-09-05 23:44:07 UTC (rev 5900) +++ main/trunk/src/karts/kart.hpp 2010-09-06 11:07:41 UTC (rev 5901) @@ -47,7 +47,6 @@ class SkidMarks; class SlipStream; class Smoke; -class Stars; class WaterSplash; /** The main kart class. All type of karts are of this object, but with @@ -140,9 +139,6 @@ /** Water splash when driving in water. */ WaterSplash *m_water_splash_system; - /** For stars rotating around head effect */ - Stars *m_stars_effect; - /** Graphical effect when using a nitro. */ Nitro *m_nitro; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-06 23:08:33
|
Revision: 5908 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5908&view=rev Author: hikerstk Date: 2010-09-06 23:08:27 +0000 (Mon, 06 Sep 2010) Log Message: ----------- Moved handling of kart elimination into emergency animation (since it's closely related, i.e. removing and adding bullet bodies), and fixed bug 3059830). Modified Paths: -------------- main/trunk/src/karts/emergency_animation.cpp main/trunk/src/karts/emergency_animation.hpp main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/emergency_animation.cpp =================================================================== --- main/trunk/src/karts/emergency_animation.cpp 2010-09-06 23:05:56 UTC (rev 5907) +++ main/trunk/src/karts/emergency_animation.cpp 2010-09-06 23:08:27 UTC (rev 5908) @@ -40,7 +40,7 @@ // reset() is also called at the very start, it must be guaranteed that // rescue is not set. m_kart_mode = EA_NONE; - + m_eliminated = false; }; // EmergencyAnimation //----------------------------------------------------------------------------- @@ -55,6 +55,7 @@ */ void EmergencyAnimation::reset() { + // Create the stars effect in the first reset if(!m_stars_effect) m_stars_effect = new Stars(m_kart->getNode()); @@ -64,15 +65,31 @@ // If the kart was eliminated or rescued, the body was removed from the // physics world. Add it again. - if(playingEmergencyAnimation()) + if(m_eliminated || playingEmergencyAnimation()) { World::getWorld()->getPhysics()->addKart(m_kart); } - m_timer = 0; - m_kart_mode = EA_NONE; + m_timer = 0; + m_kart_mode = EA_NONE; + m_eliminated = false; } // reset //----------------------------------------------------------------------------- +/** Eliminates a kart from the race. It removes the kart from the physics + * world, and makes the scene node invisible. + */ +void EmergencyAnimation::eliminate() +{ + if (!playingEmergencyAnimation()) + { + World::getWorld()->getPhysics()->removeKart(m_kart); + } + m_eliminated = true; + + m_kart->getNode()->setVisible(false); +} // eliminate + +//----------------------------------------------------------------------------- /** Sets the mode of the kart to being rescued, attaches the rescue model * and saves the current pitch and roll (for the rescue animation). It * also removes the kart from the physics world. @@ -168,7 +185,12 @@ World::getWorld()->getPhysics()->addKart(m_kart); m_kart->getBody()->setLinearVelocity(btVector3(0,0,0)); m_kart->getBody()->setAngularVelocity(btVector3(0,0,0)); - m_kart_mode = EA_NONE; + m_kart_mode = EA_NONE; + // We have to make sure that m_kart_mode and m_eliminated are in + // synch, otherwise it can happen that a kart is entered in world + // here, and again in reset (e.g. when restarting the race) if + // m_eliminated is still true. + m_eliminated = false; return; } Modified: main/trunk/src/karts/emergency_animation.hpp =================================================================== --- main/trunk/src/karts/emergency_animation.hpp 2010-09-06 23:05:56 UTC (rev 5907) +++ main/trunk/src/karts/emergency_animation.hpp 2010-09-06 23:08:27 UTC (rev 5908) @@ -64,6 +64,9 @@ /** A pointer to the class to which this object belongs. */ Kart *m_kart; + /** True if this kart has been eliminated. */ + bool m_eliminated; + /** For stars rotating around head effect */ Stars *m_stars_effect; @@ -90,5 +93,9 @@ /** Returns the timer for the currently played animation. */ const float getAnimationTimer() const {return m_timer;} + /** Returns true if the kart is eliminated. */ + bool isEliminated () const {return m_eliminated;} + void eliminate (); + }; // EmergencyAnimation #endif Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-06 23:05:56 UTC (rev 5907) +++ main/trunk/src/karts/kart.cpp 2010-09-06 23:08:27 UTC (rev 5908) @@ -78,7 +78,6 @@ m_finished_race = false; m_finish_time = 0.0f; m_slipstream_time = 0.0f; - m_eliminated = false; m_shadow_enabled = false; m_shadow = NULL; m_smoke_system = NULL; @@ -322,21 +321,6 @@ } // ~Kart //----------------------------------------------------------------------------- -/** Eliminates a kart from the race. It removes the kart from the physics - * world, and makes the scene node invisible. - */ -void Kart::eliminate() -{ - if (!playingEmergencyAnimation()) - { - World::getWorld()->getPhysics()->removeKart(this); - } - m_eliminated = true; - - getNode()->setVisible(false); -} // eliminate - -//----------------------------------------------------------------------------- /** Returns true if the kart is 'resting', i.e. (nearly) not moving. */ bool Kart::isInRest() const @@ -374,12 +358,6 @@ */ void Kart::reset() { - // Only add the physics body back if the kart is eliminated - // and no emergency animations is being played. Since if - // an emergency animation is being played, the physics body - // will be added back in EMergencyAnimation::reset - if(m_eliminated && !playingEmergencyAnimation()) - World::getWorld()->getPhysics()->addKart(this); EmergencyAnimation::reset(); if (m_camera) @@ -403,7 +381,6 @@ m_powerup.reset(); m_race_position = m_initial_position; - m_eliminated = false; m_finished_race = false; m_finish_time = 0.0f; m_zipper_time_left = 0.0f; Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-09-06 23:05:56 UTC (rev 5907) +++ main/trunk/src/karts/kart.hpp 2010-09-06 23:08:27 UTC (rev 5908) @@ -180,9 +180,6 @@ float m_view_blocked_by_plunger; float m_speed; - /** True if this kart has been eliminated. */ - bool m_eliminated; - std::vector<SFXBase*> m_custom_sounds; SFXBase *m_beep_sound; SFXBase *m_engine_sound; @@ -363,9 +360,6 @@ /** Returns true if the kart is close to the ground, used to dis/enable * the upright constraint to allow for more realistic explosions. */ bool isNearGround () const; - /** Returns true if the kart is eliminated. */ - bool isEliminated () const {return m_eliminated;} - void eliminate (); void resetBrakes (); void startEngineSFX (); void adjustSpeed (float f); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-09 00:35:22
|
Revision: 5935 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=5935&view=rev Author: hikerstk Date: 2010-09-09 00:35:15 +0000 (Thu, 09 Sep 2010) Log Message: ----------- Each kart instance has now its own copy of kart_model instead of a shared version of it. This avoids animation issues (in some circumstances e.g. a win/lose animation could be shown for a kart still driving), and an assert crash (bug 3058787) is also avoided. Note that the animation issues are usually not easy to see since the random AI kart selection makes usually sure that the player kart is not used more than once, so this issue can only be seen in AI karts. Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_properties.cpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-09 00:31:47 UTC (rev 5934) +++ main/trunk/src/karts/kart.cpp 2010-09-09 00:35:15 UTC (rev 5935) @@ -72,6 +72,14 @@ { m_kart_properties = kart_properties_manager->getKart(ident); assert(m_kart_properties != NULL); + // We have to take a copy of the kart model, since otherwise + // the animations will be mixed up (i.e. different instances of + // the same model will set different animation frames). + // Technically the mesh in m_kart_model needs to be grab'ed and + // 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_initial_position = position; m_race_position = position; m_collected_energy = 0; @@ -183,10 +191,9 @@ { // First: Create the chassis of the kart // ------------------------------------- - const KartModel *km = m_kart_properties->getKartModel(); - float kart_width = km->getWidth(); - float kart_length = km->getLength(); - float kart_height = km->getHeight(); + float kart_width = getKartWidth(); + float kart_length = getKartLength(); + float kart_height = getKartHeight(); btBoxShape *shape = new btBoxShape(btVector3(0.5f*kart_width, 0.5f*kart_height, @@ -241,7 +248,7 @@ { bool is_front_wheel = i<2; btWheelInfo& wheel = m_vehicle->addWheel( - m_kart_properties->getKartModel()->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(); @@ -367,7 +374,7 @@ } // Stop any animations currently being played. - m_kart_properties->getKartModel()->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) @@ -375,7 +382,7 @@ m_controller = m_saved_controller; m_saved_controller = NULL; } - m_kart_properties->getKartModel()->setAnimation(KartModel::AF_DEFAULT); + m_kart_model.setAnimation(KartModel::AF_DEFAULT); m_view_blocked_by_plunger = 0.0; m_attachment->clear(); m_powerup.reset(); @@ -466,9 +473,9 @@ setController(new EndController(this, m_controller->getPlayer())); if(m_race_position<=0.5f*race_manager->getNumberOfKarts() || m_race_position==1) - m_kart_properties->getKartModel()->setAnimation(KartModel::AF_WIN_START); + m_kart_model.setAnimation(KartModel::AF_WIN_START); else - m_kart_properties->getKartModel()->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); @@ -485,9 +492,9 @@ // start end animation setController(new EndController(this, m_controller->getPlayer())); if(m_race_position<=2) - m_kart_properties->getKartModel()->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_properties->getKartModel()->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); @@ -1327,7 +1334,7 @@ */ void Kart::loadData() { - m_kart_properties->getKartModel()->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 @@ -1403,7 +1410,6 @@ const btQuaternion& rotation) { float wheel_up_axis[4]; - KartModel *kart_model = m_kart_properties->getKartModel(); for(unsigned int i=0; i<4; i++) { // Set the suspension length @@ -1417,15 +1423,15 @@ // 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; - kart_model->update(m_wheel_rotation, auto_skid, - getSteerPercent(), wheel_up_axis); + 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 - - (kart_model->getWheelGraphicsRadius(0) - -kart_model->getWheelGraphicsPosition(0).getY() ); + - (m_kart_model.getWheelGraphicsRadius(0) + -m_kart_model.getWheelGraphicsPosition(0).getY() ); center_shift.setY(y); if(m_smoke_system) Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-09-09 00:31:47 UTC (rev 5934) +++ main/trunk/src/karts/kart.hpp 2010-09-09 00:35:15 UTC (rev 5935) @@ -29,11 +29,13 @@ #include "items/powerup.hpp" #include "karts/emergency_animation.hpp" #include "karts/moveable.hpp" +#include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" #include "karts/controller/controller.hpp" #include "karts/controller/kart_control.hpp" #include "karts/kart_model.hpp" #include "tracks/terrain_info.hpp" +#include "utils/no_copy.hpp" class btKart; class btUprightConstraint; @@ -58,7 +60,8 @@ * and TerrainInfo, which manages the terrain the kart is on. * \ingroup karts */ -class Kart : public TerrainInfo, public Moveable, public EmergencyAnimation +class Kart : public TerrainInfo, public Moveable, public EmergencyAnimation, + public NoCopy { private: /** Reset position. */ @@ -201,7 +204,10 @@ protected: const KartProperties *m_kart_properties; - + /** 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; public: Kart(const std::string& ident, int position, @@ -334,14 +340,12 @@ float getMaxSpeedOnTerrain() const {return m_max_speed- m_max_speed_reduction; } /** Returns the length of the kart. */ - float getKartLength () const - {return m_kart_properties->getKartModel()->getLength(); } + float getKartLength () const {return m_kart_model.getLength(); } /** Returns the height of the kart. */ - float getKartHeight () const - {return m_kart_properties->getKartModel()->getHeight(); } + float getKartHeight () const {return m_kart_model.getHeight(); } /** Returns the width of the kart. */ - float getKartWidth () const - {return m_kart_properties->getKartModel()->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;} void createPhysics (); Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-09-09 00:31:47 UTC (rev 5934) +++ main/trunk/src/karts/kart_model.cpp 2010-09-09 00:35:15 UTC (rev 5935) @@ -28,8 +28,18 @@ float KartModel::UNDEFINED = -99.9f; -/** The constructor reads the model file name and wheel specification from the - * kart config file. +/** 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. + * ATM there are two pointers: + * - to the scene node (which is otherwise handled by kart and set + * later anyway) + * - to the mesh. Sharing mesh is supported in irrlicht, so that's + * no problem. + * 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() { @@ -94,6 +104,12 @@ */ KartModel::~KartModel() { + for(unsigned int i=0; i<4; i++) + { + m_wheel_node[i]->remove(); + //m_wheel_node[i]->drop(); + } + } // ~KartModel // ---------------------------------------------------------------------------- @@ -125,13 +141,13 @@ for(unsigned int i=0; i<4; i++) { - m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i]); - m_wheel_node[i]->setPosition(m_wheel_graphics_position[i].toIrrVector()); + m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i], + *node); #ifdef DEBUG std::string debug_name = m_wheel_filename[i]+" (wheel)"; m_wheel_node[i]->setName(debug_name.c_str()); #endif - (*node)->addChild(m_wheel_node[i]); + m_wheel_node[i]->setPosition(m_wheel_graphics_position[i].toIrrVector()); } } // attachModel Modified: main/trunk/src/karts/kart_properties.cpp =================================================================== --- main/trunk/src/karts/kart_properties.cpp 2010-09-09 00:31:47 UTC (rev 5934) +++ main/trunk/src/karts/kart_properties.cpp 2010-09-09 00:35:15 UTC (rev 5935) @@ -213,8 +213,6 @@ root->get("groups", &m_groups ); - //m_kart_model.loadInfo(lisp); - if(const XMLNode *dimensions_node = root->getNode("center")) dimensions_node->get("gravity-shift", &m_gravity_center_shift); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-14 11:29:34
|
Revision: 6001 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6001&view=rev Author: hikerstk Date: 2010-09-14 11:29:27 +0000 (Tue, 14 Sep 2010) Log Message: ----------- Removed unused code. Modified Paths: -------------- main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-09-14 06:05:48 UTC (rev 6000) +++ main/trunk/src/karts/kart_model.cpp 2010-09-14 11:29:27 UTC (rev 6001) @@ -64,7 +64,8 @@ m_wheel_model[i] = NULL; m_wheel_node[i] = NULL; - // default value for kart suspensions. move to config file later if we find each kart needs custom values + // default value for kart suspensions. move to config file later + // if we find each kart needs custom values m_min_suspension[i] = -1.3f; m_max_suspension[i] = 1.3f; m_dampen_suspension_amplitude[i] = 2.5f; @@ -149,7 +150,6 @@ km->m_kart_width = m_kart_width; km->m_kart_length = m_kart_length; km->m_kart_height = m_kart_height; - km->m_z_offset = m_z_offset; km->m_mesh = m_mesh; km->m_model_filename = m_model_filename; km->m_animation_speed = m_animation_speed; @@ -231,16 +231,10 @@ exit(-2); } MeshTools::minMax3D(m_mesh, &min, &max); - Vec3 size = max-min; - m_z_offset = min.getZ(); + Vec3 size = max-min; m_kart_width = size.getX(); m_kart_height = size.getY(); m_kart_length = size.getZ(); - // FIXME: How do we handle this? it's a mesh only, so we can't - // simply move it in a transform (unless we turn it into a scene - // node). m_z_offset should probably be made available to kart. - // Vec3 move_kart_to_0_z(0, 0, m_z_offset); - // m_root->setTransform(move_kart_to_0_z); // Now set default some default parameters (if not defined) that // depend on the size of the kart model (wheel position, center @@ -268,10 +262,6 @@ m_wheel_model[i] = irr_driver->getMesh(full_wheel); // FIXME: wheel handling still missing. } // for i<4 - if(!m_wheel_model[0]) - { - m_z_offset = m_kart_height*0.5f; - } } // loadModels // ---------------------------------------------------------------------------- Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2010-09-14 06:05:48 UTC (rev 6000) +++ main/trunk/src/karts/kart_model.hpp 2010-09-14 11:29:27 UTC (rev 6001) @@ -120,9 +120,6 @@ float m_kart_width; /**< Width of kart. */ float m_kart_length; /**< Length of kart. */ float m_kart_height; /**< Height of kart. */ - 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. */ @@ -172,9 +169,6 @@ float getLength () const {return m_kart_length; } float getWidth () const {return m_kart_width; } float getHeight () const {return m_kart_height; } - /** Returns the amount a kart has to be moved down so that the bottom of - * the kart is at z=0. */ - float getZOffset () const {return m_z_offset; } void update(float rotation, float visual_steer, float steer, const float suspension[4]); void resetWheels(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-16 23:31:20
|
Revision: 6031 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6031&view=rev Author: hikerstk Date: 2010-09-16 23:31:13 +0000 (Thu, 16 Sep 2010) Log Message: ----------- Fixed steering animation to be independent of the actual frame rate defined in the animation, and also to handle if only steering partly into a direction. Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-16 23:29:17 UTC (rev 6030) +++ main/trunk/src/karts/kart.cpp 2010-09-16 23:31:13 UTC (rev 6031) @@ -1417,15 +1417,7 @@ wheel_up_axis[i] = m_default_suspension_length[i] - m_vehicle->getWheelInfo(i).m_raycastInfo.m_suspensionLength; } - const float auto_skid_visual=1.7f; - float auto_skid; - // FIXME -// if (m_skidding>auto_skid_visual) // Above a limit, start counter rotating the wheels to get drifting look -// 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, - getSteerPercent(), wheel_up_axis); + m_kart_model->update(m_wheel_rotation, getSteerPercent(), wheel_up_axis); Vec3 center_shift = getGravityCenterShift(); float y = m_vehicle->getWheelInfo(0).m_chassisConnectionPointCS.getY() Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2010-09-16 23:29:17 UTC (rev 6030) +++ main/trunk/src/karts/kart_model.cpp 2010-09-16 23:31:13 UTC (rev 6031) @@ -184,7 +184,6 @@ { *node = irr_driver->addAnimatedMesh(m_mesh); m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(*node); - m_animated_node->setAnimationSpeed(1500); m_animated_node->setLoopMode(false); } else @@ -338,12 +337,15 @@ if(m_current_animation==AF_DEFAULT) { m_animated_node->setLoopMode(false); - m_animated_node->setFrameLoop(m_animation_frame[AF_STRAIGHT], - m_animation_frame[AF_STRAIGHT] ); + if(m_animation_frame[AF_LEFT] <= m_animation_frame[AF_RIGHT]) + m_animated_node->setFrameLoop(m_animation_frame[AF_LEFT], + m_animation_frame[AF_RIGHT] ); + else + m_animated_node->setFrameLoop(m_animation_frame[AF_RIGHT], + m_animation_frame[AF_LEFT] ); m_animated_node->setAnimationEndCallback(NULL); } - - if(m_current_animation!=AF_DEFAULT && m_animation_frame[type]>-1) + else if(m_animation_frame[type]>-1) { // 'type' is the start frame of the animation, type + 1 the frame // to begin the loop with, type + 2 to end the frame with @@ -406,10 +408,8 @@ * \param steer The actual steer settings. * \param suspension Suspension height for all four wheels. */ -void KartModel::update(float rotation, float visual_steer, - float steer, const float suspension[4]) +void KartModel::update(float rotation, float steer, const float suspension[4]) { - float clamped_suspension[4]; // Clamp suspension to minimum and maximum suspension length, so that // the graphical wheel models don't look too wrong. @@ -429,7 +429,7 @@ } // for i<4 core::vector3df wheel_rear (rotation*RAD_TO_DEGREE, 0, 0); - core::vector3df wheel_steer(0, visual_steer, 0); + core::vector3df wheel_steer(0, steer*30.0f, 0); core::vector3df wheel_front = wheel_rear+wheel_steer; for(unsigned int i=0; i<4; i++) @@ -454,36 +454,16 @@ // Update animation if necessary // ----------------------------- - // FIXME: this implementation is currently very simple, it will always - // animate to the very left or right, even if actual steering is only - // (say) 50% of left or right. - int end; - static int last_end=-1; - if(steer>0.0f) end = m_animation_frame[AF_STRAIGHT] - - (int)( ( m_animation_frame[AF_STRAIGHT] - -m_animation_frame[AF_RIGHT] )*steer); - else if(steer<0.0f) end = m_animation_frame[AF_STRAIGHT] - + (int) ( (m_animation_frame[AF_STRAIGHT] - -m_animation_frame[AF_LEFT] )*steer); - else end = m_animation_frame[AF_STRAIGHT]; + float frame; + if(steer>0.0f) frame = m_animation_frame[AF_STRAIGHT] + - ( ( m_animation_frame[AF_STRAIGHT] + -m_animation_frame[AF_RIGHT] )*steer); + else if(steer<0.0f) frame = m_animation_frame[AF_STRAIGHT] + + ( (m_animation_frame[AF_STRAIGHT] + -m_animation_frame[AF_LEFT] )*steer); + else frame = m_animation_frame[AF_STRAIGHT]; - // No changes to current frame loop - if(end==last_end) return; - - int begin = (int)m_animated_node->getFrameNr(); - last_end = end; - // Handle reverse animation, which are done by setting - // the animation speed to a negative number. - if(begin<end) - { - m_animated_node->setAnimationSpeed(m_animation_speed); - m_animated_node->setFrameLoop(begin, end); - } - else - { - m_animated_node->setAnimationSpeed(-m_animation_speed); - m_animated_node->setFrameLoop(begin, end); - } + m_animated_node->setCurrentFrame(frame); } // update // ---------------------------------------------------------------------------- @@ -493,5 +473,5 @@ void KartModel::resetWheels() { const float suspension[4]={0,0,0,0}; - update(0, 0, 0.0f, suspension); + update(0, 0.0f, suspension); } // reset Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2010-09-16 23:29:17 UTC (rev 6030) +++ main/trunk/src/karts/kart_model.hpp 2010-09-16 23:31:13 UTC (rev 6031) @@ -169,8 +169,7 @@ float getLength () const {return m_kart_length; } float getWidth () const {return m_kart_width; } float getHeight () const {return m_kart_height; } - void update(float rotation, float visual_steer, - float steer, const float suspension[4]); + void update(float rotation, float steer, const float suspension[4]); void resetWheels(); void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xa...@us...> - 2010-09-19 15:17:15
|
Revision: 6061 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6061&view=rev Author: xapantu Date: 2010-09-19 15:17:09 +0000 (Sun, 19 Sep 2010) Log Message: ----------- Fix a bug when reloading the karts after installing an addons Modified Paths: -------------- main/trunk/src/karts/kart_properties_manager.cpp main/trunk/src/karts/kart_properties_manager.hpp Modified: main/trunk/src/karts/kart_properties_manager.cpp =================================================================== --- main/trunk/src/karts/kart_properties_manager.cpp 2010-09-19 14:58:56 UTC (rev 6060) +++ main/trunk/src/karts/kart_properties_manager.cpp 2010-09-19 15:17:09 UTC (rev 6061) @@ -99,12 +99,12 @@ m_groups.clear(); m_all_groups.clear(); //m_kart_search_path.clear(); - loadAllKarts(); + loadAllKarts(false); } //----------------------------------------------------------------------------- /** Loads all kart properties and models. */ -void KartPropertiesManager::loadAllKarts() +void KartPropertiesManager::loadAllKarts(bool loading_icon) { m_all_kart_dirs.clear(); for(std::vector<std::string>::const_iterator dir=m_kart_search_path.begin(); @@ -123,7 +123,7 @@ { const bool loaded = loadKart(*dir+"/"+*subdir); - if (loaded) + if (loaded && loading_icon) { GUIEngine::addLoadingIcon(irr_driver->getTexture( *dir + "/"+*subdir + "/" + Modified: main/trunk/src/karts/kart_properties_manager.hpp =================================================================== --- main/trunk/src/karts/kart_properties_manager.hpp 2010-09-19 14:58:56 UTC (rev 6060) +++ main/trunk/src/karts/kart_properties_manager.hpp 2010-09-19 15:17:09 UTC (rev 6061) @@ -66,7 +66,7 @@ const int getKartId (const std::string &ident) const; int getKartByGroup (const std::string& group, int i) const; - void loadAllKarts (); + void loadAllKarts (bool loading_icon = true); void unloadAllKarts (); void reLoadAllKarts (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-20 01:21:24
|
Revision: 6074 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6074&view=rev Author: hikerstk Date: 2010-09-20 01:21:17 +0000 (Mon, 20 Sep 2010) Log Message: ----------- Made the amount of nitro configurable per kart - in case that we want to change this later when giving each kart different abilities (now that I think about it: a similar effect can be accomplished with the nitro consumption rate). Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart_properties.cpp main/trunk/src/karts/kart_properties.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-20 01:16:41 UTC (rev 6073) +++ main/trunk/src/karts/kart.cpp 2010-09-20 01:21:17 UTC (rev 6074) @@ -531,9 +531,12 @@ case Item::ITEM_BANANA: m_attachment->hitBanana(item, add_info); break; - - case Item::ITEM_NITRO_SMALL: m_collected_energy++; break; - case Item::ITEM_NITRO_BIG: m_collected_energy += 3; break; + case Item::ITEM_NITRO_SMALL: + m_collected_energy += m_kart_properties->getNitroSmallContainer(); + break; + case Item::ITEM_NITRO_BIG: + m_collected_energy += m_kart_properties->getNitroBigContainer(); + break; case Item::ITEM_BONUS_BOX : { // In wheelie style, karts get more items depending on energy, Modified: main/trunk/src/karts/kart_properties.cpp =================================================================== --- main/trunk/src/karts/kart_properties.cpp 2010-09-20 01:16:41 UTC (rev 6073) +++ main/trunk/src/karts/kart_properties.cpp 2010-09-20 01:21:17 UTC (rev 6074) @@ -62,6 +62,7 @@ m_max_speed[0] = m_max_speed[1] = m_max_speed[2] = m_time_full_steer = m_time_full_steer_ai = m_nitro_power_boost = m_nitro_consumption = + m_nitro_small_container = m_nitro_big_container = m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_base = m_wheel_damping_compression = m_friction_slip = m_roll_influence = m_wheel_radius = m_chassis_linear_damping = @@ -216,8 +217,10 @@ if(const XMLNode *nitro_node = root->getNode("nitro")) { - nitro_node->get("power-boost", &m_nitro_power_boost); - nitro_node->get("consumption", &m_nitro_consumption); + nitro_node->get("power-boost", &m_nitro_power_boost ); + nitro_node->get("consumption", &m_nitro_consumption ); + nitro_node->get("small-container", &m_nitro_small_container); + nitro_node->get("big-container", &m_nitro_big_container ); } if(const XMLNode *rescue_node = root->getNode("rescue")) @@ -500,6 +503,8 @@ CHECK_NEG(m_camera_distance, "camera distance" ); CHECK_NEG(m_nitro_power_boost, "nitro power-boost" ); CHECK_NEG(m_nitro_consumption, "nitro consumption" ); + CHECK_NEG(m_nitro_big_container, "nitro big-container" ); + CHECK_NEG(m_nitro_small_container, "nitro small-container" ); CHECK_NEG(m_rescue_height, "rescue height" ); CHECK_NEG(m_rescue_time, "rescue time" ); CHECK_NEG(m_rescue_vert_offset, "rescue vert-offset" ); Modified: main/trunk/src/karts/kart_properties.hpp =================================================================== --- main/trunk/src/karts/kart_properties.hpp 2010-09-20 01:16:41 UTC (rev 6073) +++ main/trunk/src/karts/kart_properties.hpp 2010-09-20 01:21:17 UTC (rev 6074) @@ -144,6 +144,8 @@ float m_wheel_base; /**< Wheel base of the kart. */ float m_nitro_power_boost; /**< Nitro power boost. */ float m_nitro_consumption; /**< Nitro consumption. */ + float m_nitro_small_container; /**< Nitro amount for small bottle. */ + float m_nitro_big_container; /**< Nitro amount for big bittle. */ std::string m_engine_sfx_type; /**< Engine sound effect. */ // bullet physics data @@ -325,6 +327,12 @@ /** Returns the nitro consumption. */ float getNitroConsumption () const {return m_nitro_consumption; } + /** Returns the amount of nitro for a small container. */ + float getNitroSmallContainer () const {return m_nitro_small_container; } + + /** Returns the amount of nitro for a big container. */ + float getNitroBigContainer () const {return m_nitro_big_container; } + /** Returns a shift of the center of mass (lowering the center of mass * makes the karts more stable. */ const Vec3&getGravityCenterShift() const {return m_gravity_center_shift; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-09-26 22:44:30
|
Revision: 6153 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6153&view=rev Author: hikerstk Date: 2010-09-26 22:44:23 +0000 (Sun, 26 Sep 2010) Log Message: ----------- Changed slipstream handling: boost will now be given when getting out of slipstream and enough 'slipstream credits' have been accumulated (which is shown by a little bit of nitro). This should avoid the problem of crashing into the kart ahead when getting nitro, and also make it less likely that the AI creates trains. Modified Paths: -------------- main/trunk/src/karts/controller/default_ai_controller.cpp main/trunk/src/karts/controller/default_ai_controller.hpp main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/controller/default_ai_controller.cpp =================================================================== --- main/trunk/src/karts/controller/default_ai_controller.cpp 2010-09-26 01:20:50 UTC (rev 6152) +++ main/trunk/src/karts/controller/default_ai_controller.cpp 2010-09-26 22:44:23 UTC (rev 6153) @@ -37,7 +37,7 @@ #include <iostream> #ifdef AI_DEBUG -#include "graphics/irr_driver.hpp" +# include "graphics/irr_driver.hpp" #endif #include "modes/linear_world.hpp" #include "network/network_manager.hpp" @@ -92,6 +92,7 @@ { case RaceManager::RD_EASY: m_wait_for_players = true; + m_make_use_of_slipstream = false; m_max_handicap_accel = 0.9f; m_item_tactic = IT_TEN_SECONDS; m_false_start_probability = 0.08f; @@ -104,6 +105,7 @@ break; case RaceManager::RD_MEDIUM: m_wait_for_players = true; + m_make_use_of_slipstream = false; m_max_handicap_accel = 0.95f; m_item_tactic = IT_CALCULATE; m_false_start_probability = 0.04f; @@ -116,6 +118,7 @@ break; case RaceManager::RD_HARD: m_wait_for_players = false; + m_make_use_of_slipstream = true; m_max_handicap_accel = 1.0f; m_item_tactic = IT_CALCULATE; m_false_start_probability = 0.01f; @@ -821,6 +824,19 @@ //tell when a kart is going to get out of the track so it steers. m_crashes.clear(); + // If slipstream should be handled actively, trigger overtaking the + // kart which gives us slipstream if slipstream is readyA + if(m_make_use_of_slipstream && m_kart->isSlipstreamReady() && + m_kart->getSlipstreamKart()) + { + //printf("%s overtaking %s\n", m_kart->getIdent().c_str(), + // m_kart->getSlipstreamKart()->getIdent().c_str()); + // FIXME: we might define a minimum distance, and if the target kart + // is too close break first - otherwise the AI hits the kart when + // trying to overtake it, actually speeding the other kart up. + m_crashes.m_kart = m_kart->getSlipstreamKart()->getWorldKartId(); + } + const size_t NUM_KARTS = m_world->getNumKarts(); //Protection against having vel_normal with nan values Modified: main/trunk/src/karts/controller/default_ai_controller.hpp =================================================================== --- main/trunk/src/karts/controller/default_ai_controller.hpp 2010-09-26 01:20:50 UTC (rev 6152) +++ main/trunk/src/karts/controller/default_ai_controller.hpp 2010-09-26 22:44:23 UTC (rev 6153) @@ -69,22 +69,28 @@ /** The actual start delay used. */ float m_start_delay; - int m_min_steps; //Minimum number of steps to check. If 0, the AI doesn't - //even has check around the kart, if 1, it checks around - //the kart always, and more than that will check the - //remaining number of steps in front of the kart, always - bool m_wait_for_players; //If true, the acceleration is decreased when - //the AI is in a better position than all the - //human players. - float m_max_handicap_accel; //The allowed maximum speed, in percentage, - //from 0.0 to 1.0. Used only when - //m_wait_for_players == true. + /** Minimum number of steps to check. If 0, the AI doesn't even has check + * around the kart, if 1, it checks around the kart always, and more + * than that will check the remaining number of steps in front of the + * kart, always. */ + int m_min_steps; + /** If true, the acceleration is decreased when the AI is in a better + * position than all the human players. */ + bool m_wait_for_players; + + /** The allowed maximum speed, in percentage, from 0.0 to 1.0. Used only + * when m_wait_for_players == true. */ + float m_max_handicap_accel; - ItemTactic m_item_tactic; //How are items going to be used? + /** How are items going to be used? */ + ItemTactic m_item_tactic; /** True if the kart should try to pass on a bomb to another kart. */ + bool m_handle_bomb; - bool m_handle_bomb; + /** True if the AI should avtively try to make use of slipstream. */ + bool m_make_use_of_slipstream; + /*General purpose variables*/ //The crash percentage is how much of the time the AI has been crashing, //if the AI has been crashing for some time, use the rescue. @@ -127,7 +133,7 @@ * graph nodes. */ std::vector<std::vector<int> > m_all_look_aheads; - float m_time_since_stuck; + float m_time_since_stuck; int m_start_kart_crash_direction; //-1 = left, 1 = right, 0 = no crash. Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-09-26 01:20:50 UTC (rev 6152) +++ main/trunk/src/karts/kart.cpp 2010-09-26 22:44:23 UTC (rev 6153) @@ -85,13 +85,13 @@ m_collected_energy = 0; m_finished_race = false; m_finish_time = 0.0f; - m_slipstream_time = 0.0f; m_shadow_enabled = false; m_shadow = NULL; m_smoke_system = NULL; m_water_splash_system = NULL; m_nitro = NULL; - m_slip_stream = NULL; + m_slipstream = NULL; + m_slipstream_time = 0.0f; m_skidmarks = NULL; m_camera = NULL; m_controller = NULL; @@ -308,7 +308,7 @@ if(m_smoke_system) delete m_smoke_system; if(m_water_splash_system) delete m_water_splash_system; if(m_nitro) delete m_nitro; - if(m_slip_stream) delete m_slip_stream; + if(m_slipstream) delete m_slipstream; delete m_shadow; @@ -386,6 +386,7 @@ m_kart_model->setAnimation(KartModel::AF_DEFAULT); m_view_blocked_by_plunger = 0.0; m_attachment->clear(); + m_nitro->setCreationRate(0.0f); m_powerup.reset(); m_race_position = m_initial_position; @@ -420,7 +421,7 @@ m_controls.m_drift = false; m_controls.m_fire = false; m_controls.m_look_back = false; - m_slip_stream->reset(); + m_slipstream->reset(); m_vehicle->deactivateZipper(); // Set the brakes so that karts don't slide downhill @@ -687,7 +688,7 @@ m_smoke_system->update(dt); m_water_splash_system->update(dt); m_nitro->update(dt); - m_slip_stream->update(dt); + m_slipstream->update(dt); } // UserConfigParams::m_graphical_effects updatePhysics(dt); @@ -880,9 +881,9 @@ */ float Kart::handleSlipstream(float dt) { - // Update this karts slipstream quad (even for low level AI, since even - // then player karts can get slipstream, and so have to compare with - // the modified slipstream quad. + // Update this karts slipstream quad (even for low level AI which don't + // use slipstream, since even then player karts can get slipstream, + // and so have to compare with the modified slipstream quad. m_slipstream_original_quad->transform(getTrans(), m_slipstream_quad); // Low level AIs should not do any slipstreaming. @@ -895,7 +896,7 @@ { m_slipstream_time -= dt; if(m_slipstream_time<0) m_slipstream_mode=SS_NONE; - m_slip_stream->setIntensity(2.0f, NULL); + m_slipstream->setIntensity(2.0f, NULL); return m_kart_properties->getSlipstreamAddPower(); } @@ -908,7 +909,7 @@ #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING if(getSpeed()<m_kart_properties->getSlipstreamMinSpeed()) { - m_slip_stream->setIntensity(0, NULL); + m_slipstream->setIntensity(0, NULL); return 0; } #endif @@ -917,16 +918,16 @@ World *world = World::getWorld(); unsigned int num_karts = world->getNumKarts(); bool is_sstreaming = false; - Kart *target_kart; + m_slipstream_target = NULL; // Note that this loop can not be simply replaced with a shorter loop // using only the karts with a better position - since a kart might // be a lap behind for(unsigned int i=0; i<num_karts; i++) { - target_kart = world->getKart(i); + m_slipstream_target= world->getKart(i); // Don't test for slipstream with itself. - if(target_kart==this || - target_kart->isEliminated() ) continue; + if(m_slipstream_target==this || + m_slipstream_target->isEliminated() ) continue; // If the kart we are testing against is too slow, no need to test // slipstreaming. Note: We compare the speed of the other kart @@ -934,16 +935,18 @@ // entirely sure if this makes sense, but it makes it easier to // give karts different slipstream properties. #ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING - if(target_kart->getSpeed()<m_kart_properties->getSlipstreamMinSpeed()) + if(m_slipstream_target->getSpeed() < + m_kart_properties->getSlipstreamMinSpeed()) continue; #endif // Quick test: the kart must be not more than // slipstream length+kart_length() away from the other kart - Vec3 delta = getXYZ() - target_kart->getXYZ(); - float l = target_kart->m_kart_properties->getSlipstreamLength() - + target_kart->getKartLength()*0.5f; + Vec3 delta = getXYZ() - m_slipstream_target->getXYZ(); + float l = m_slipstream_target->m_kart_properties->getSlipstreamLength() + + m_slipstream_target->getKartLength()*0.5f; if(delta.length2_2d() > l*l) continue; - if(target_kart->m_slipstream_quad->pointInQuad(getXYZ())) + // Real test: if in slipstream quad of other kart + if(m_slipstream_target->m_slipstream_quad->pointInQuad(getXYZ())) { is_sstreaming = true; break; @@ -952,9 +955,26 @@ if(!is_sstreaming) { + if(isSlipstreamReady()) + { + // The first time slipstream is ready after collecting + // and you are leaving the slipstream area, you get a + // zipper bonus. + if(m_slipstream_mode==SS_COLLECT) + { + m_slipstream_mode = SS_USE; + handleZipper(); + // And the time is set to a maximum (to avoid that e.g. AI + // karts slipstream for a long time and then get a very long + // bonus). + m_slipstream_time = + m_kart_properties->getSlipstreamCollectTime(); + return m_kart_properties->getSlipstreamAddPower(); + } + } m_slipstream_time -=dt; if(m_slipstream_time<0) m_slipstream_mode = SS_NONE; - m_slip_stream->setIntensity(0, NULL); + m_slipstream->setIntensity(0, NULL); return 0; } // for i<number of karts @@ -962,21 +982,29 @@ m_slipstream_time = m_slipstream_mode==SS_NONE ? dt : m_slipstream_time+dt; //printf("Collecting slipstream %f\n", m_slipstream_time); - m_slip_stream->setIntensity(m_slipstream_time, target_kart); + if(isSlipstreamReady()) + m_nitro->setCreationRate(3.0f); + m_slipstream->setIntensity(m_slipstream_time, m_slipstream_target); m_slipstream_mode = SS_COLLECT; if(m_slipstream_time>m_kart_properties->getSlipstreamCollectTime()) { - m_slipstream_mode = SS_USE; - handleZipper(); // FIXME(/REMOVE?) Zipper gives a sharp push, maybe too sharp + m_slipstream->setIntensity(1.0f, m_slipstream_target); return 0; // see below about abusing m_zipper_time_left without zipper //return m_kart_properties->getSlipstreamAddPower(); } - //m_zipper_time_left = 5.0f; // FIXME, this is a hack to test higher speed limit without zipper, better would be own counter return 0; - //return m_kart_properties->getSlipstreamAddPower(); + } // handleSlipstream +// ----------------------------------------------------------------------------- +/** Returns true if enough slipstream credits have been accumulated + * to get a boost when leaving the slipstream area. + */ +bool Kart::isSlipstreamReady() const +{ + return m_slipstream_time>m_kart_properties->getSlipstreamCollectTime(); +} // isSlipstreamReady // ----------------------------------------------------------------------------- /** This function is called when the race starts. Up to then all brakes are @@ -1353,7 +1381,7 @@ m_smoke_system = new Smoke(this); m_water_splash_system = new WaterSplash(this); m_nitro = new Nitro(this); - m_slip_stream = new SlipStream(this); + m_slipstream = new SlipStream(this); if(m_kart_properties->hasSkidmarks()) m_skidmarks = new SkidMarks(*this); Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-09-26 01:20:50 UTC (rev 6152) +++ main/trunk/src/karts/kart.hpp 2010-09-26 22:44:23 UTC (rev 6153) @@ -145,7 +145,7 @@ Nitro *m_nitro; /** Graphical effect when slipstreaming. */ - SlipStream *m_slip_stream; + SlipStream *m_slipstream; float m_wheel_rotation; /** For each wheel it stores the suspension length after the karts are at @@ -169,6 +169,10 @@ /** The time a kart was in slipstream. */ float m_slipstream_time; + + /** The kart from which this kart gets slipstream. Used by the AI to + ** overtake the right kart. */ + Kart *m_slipstream_target; /** Slipstream mode: either nothing happening, or the kart is collecting * 'slipstream credits', or the kart is using accumulated credits. */ @@ -367,6 +371,10 @@ /** Returns true if the kart is close to the ground, used to dis/enable * the upright constraint to allow for more realistic explosions. */ bool isNearGround () const; + bool isSlipstreamReady() const; + + /** Returns which kart is giving slip stream to this kart. */ + const Kart* getSlipstreamKart() const {return m_slipstream_target;}; void resetBrakes (); void startEngineSFX (); void adjustSpeed (float f); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-10-11 00:59:12
|
Revision: 6242 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6242&view=rev Author: auria Date: 2010-10-11 00:59:06 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Make AIs drive slower during the end animation with an ugly hack Modified Paths: -------------- main/trunk/src/karts/controller/end_controller.cpp main/trunk/src/karts/kart.cpp Modified: main/trunk/src/karts/controller/end_controller.cpp =================================================================== --- main/trunk/src/karts/controller/end_controller.cpp 2010-10-11 00:57:03 UTC (rev 6241) +++ main/trunk/src/karts/controller/end_controller.cpp 2010-10-11 00:59:06 UTC (rev 6242) @@ -143,7 +143,7 @@ m_controls->m_look_back = false; m_controls->m_nitro = false; m_controls->m_brake = false; - m_controls->m_accel = 1.0f; + m_controls->m_accel = 0.3f; // Update the current node: if(m_track_node!=QuadGraph::UNKNOWN_SECTOR) Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-10-11 00:57:03 UTC (rev 6241) +++ main/trunk/src/karts/kart.cpp 2010-10-11 00:59:06 UTC (rev 6242) @@ -1149,6 +1149,13 @@ else if(m_speed < 0.0f) engine_power *= 5.0f; + // FIXME: horrible hack. A small acceleration value will cause the engine power to + // be reduced (for the end controller) + if (fabsf(m_controls.m_accel) < 1.0f) + { + engine_power *= fabsf(m_controls.m_accel); + } + // Engine slow down due to terrain (see m_power_reduction is set in // update() depending on terrain type. Don't apply this if kart is already // going slowly, this would make it hard accelerating to get out of there This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-10-25 01:11:14
|
Revision: 6327 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6327&view=rev Author: hikerstk Date: 2010-10-25 01:11:07 +0000 (Mon, 25 Oct 2010) Log Message: ----------- Removed compiler warning by adding missing newline at end of file. Modified Paths: -------------- main/trunk/src/karts/max_speed.cpp main/trunk/src/karts/max_speed.hpp Modified: main/trunk/src/karts/max_speed.cpp =================================================================== --- main/trunk/src/karts/max_speed.cpp 2010-10-25 00:53:17 UTC (rev 6326) +++ main/trunk/src/karts/max_speed.cpp 2010-10-25 01:11:07 UTC (rev 6327) @@ -173,4 +173,4 @@ } // update -// ---------------------------------------------------------------------------- \ No newline at end of file +// ---------------------------------------------------------------------------- Modified: main/trunk/src/karts/max_speed.hpp =================================================================== --- main/trunk/src/karts/max_speed.hpp 2010-10-25 00:53:17 UTC (rev 6326) +++ main/trunk/src/karts/max_speed.hpp 2010-10-25 01:11:07 UTC (rev 6327) @@ -135,4 +135,4 @@ float getCurrentMaxSpeed() const { return m_current_max_speed; } }; // MaxSpeed -#endif \ No newline at end of file +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-11-18 05:58:41
|
Revision: 6637 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6637&view=rev Author: hikerstk Date: 2010-11-18 05:58:34 +0000 (Thu, 18 Nov 2010) Log Message: ----------- Fix for bug 3109198: sound for a powerup zipper was not played anymore. Modified Paths: -------------- main/trunk/src/karts/controller/controller.hpp main/trunk/src/karts/controller/player_controller.cpp main/trunk/src/karts/controller/player_controller.hpp main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/controller/controller.hpp =================================================================== --- main/trunk/src/karts/controller/controller.hpp 2010-11-18 05:54:14 UTC (rev 6636) +++ main/trunk/src/karts/controller/controller.hpp 2010-11-18 05:58:34 UTC (rev 6637) @@ -54,7 +54,7 @@ StateManager::ActivePlayer *getPlayer () {return m_player;} virtual void reset () {}; virtual void update (float dt) {}; - virtual void handleZipper () {}; + virtual void handleZipper (bool play_sound) {}; virtual void collectedItem (const Item &item, int add_info=-1, float previous_energy=0) {}; Modified: main/trunk/src/karts/controller/player_controller.cpp =================================================================== --- main/trunk/src/karts/controller/player_controller.cpp 2010-11-18 05:54:14 UTC (rev 6636) +++ main/trunk/src/karts/controller/player_controller.cpp 2010-11-18 05:58:34 UTC (rev 6637) @@ -367,13 +367,13 @@ //----------------------------------------------------------------------------- /** Called when a kart hits or uses a zipper. */ -void PlayerController::handleZipper() +void PlayerController::handleZipper(bool play_sound) { // Only play a zipper sound if it's not already playing, and // if the material has changed (to avoid machine gun effect // on conveyor belt zippers). - if (m_wee_sound->getStatus() != SFXManager::SFX_PLAYING && - m_kart->getMaterial()!=m_kart->getLastMaterial()) + if (play_sound || (m_wee_sound->getStatus() != SFXManager::SFX_PLAYING && + m_kart->getMaterial()!=m_kart->getLastMaterial() ) ) { m_wee_sound->play(); } Modified: main/trunk/src/karts/controller/player_controller.hpp =================================================================== --- main/trunk/src/karts/controller/player_controller.hpp 2010-11-18 05:54:14 UTC (rev 6636) +++ main/trunk/src/karts/controller/player_controller.hpp 2010-11-18 05:58:34 UTC (rev 6637) @@ -52,7 +52,7 @@ ~PlayerController (); void update (float); void action (PlayerAction action, int value); - void handleZipper (); + void handleZipper (bool play_sound); void collectedItem (const Item &item, int add_info=-1, float previous_energy=0); virtual void setPosition (int p); Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-11-18 05:54:14 UTC (rev 6636) +++ main/trunk/src/karts/kart.cpp 2010-11-18 05:58:34 UTC (rev 6637) @@ -894,8 +894,10 @@ * \param material If not NULL, will be used to determine the zipper * parameters, otherwise the defaults from kart properties * will be used. + * \param play_sound If true this will cause a sfx to be played even if the + * terrain hasn't changed. It is used by the zipper powerup. */ -void Kart::handleZipper(const Material *material) +void Kart::handleZipper(const Material *material, bool play_sound) { /** The additional speed allowed on top of the kart-specific maximum kart * speed. */ @@ -943,7 +945,7 @@ m_vehicle->activateZipper(speed); // Play custom character sound (weee!) playCustomSFX(SFXManager::CUSTOM_ZIPPER); - m_controller->handleZipper(); + m_controller->handleZipper(play_sound); } // handleZipper // ----------------------------------------------------------------------------- Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-11-18 05:54:14 UTC (rev 6636) +++ main/trunk/src/karts/kart.hpp 2010-11-18 05:58:34 UTC (rev 6637) @@ -231,7 +231,7 @@ void updatedWeight (); virtual void collectedItem (Item *item, int random_attachment); virtual void reset (); - virtual void handleZipper (const Material *m=NULL); + virtual void handleZipper (const Material *m=NULL, bool play_sound=false); virtual void crashed (Kart *k); virtual void update (float dt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-12-12 02:23:46
|
Revision: 6969 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=6969&view=rev Author: auria Date: 2010-12-12 02:23:38 +0000 (Sun, 12 Dec 2010) Log Message: ----------- Fixed another memory leak Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-12-12 02:14:47 UTC (rev 6968) +++ main/trunk/src/karts/kart.cpp 2010-12-12 02:23:38 UTC (rev 6969) @@ -339,6 +339,7 @@ delete m_controller; if(m_saved_controller) delete m_saved_controller; + if (m_camera) delete m_camera; } // ~Kart //----------------------------------------------------------------------------- Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2010-12-12 02:14:47 UTC (rev 6968) +++ main/trunk/src/karts/kart.hpp 2010-12-12 02:23:38 UTC (rev 6969) @@ -95,11 +95,13 @@ */ protected: // Used by the AI atm + KartControl m_controls; // The kart controls (e.g. steering, fire, ...) Powerup m_powerup; Attachment *m_attachment; - /** Easier access for player_kart. */ + Camera *m_camera; + private: /** True if the kart hasn't moved since 'ready-set-go' - used to * determine startup boost. */ @@ -256,7 +258,7 @@ * to this kart) - const version. */ const Camera* getCamera () const {return m_camera;} // ------------------------------------------------------------------------ - /** Sets the camera for this kart. */ + /** Sets the camera for this kart. Takes ownership of the camera and will delete it. */ void setCamera(Camera *camera) {m_camera=camera; } // ------------------------------------------------------------------------ /** Returns the current powerup. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-03-14 20:53:59
|
Revision: 7892 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7892&view=rev Author: auria Date: 2011-03-14 20:53:50 +0000 (Mon, 14 Mar 2011) Log Message: ----------- No particles during rescue Modified Paths: -------------- main/trunk/src/karts/emergency_animation.hpp main/trunk/src/karts/kart.cpp Modified: main/trunk/src/karts/emergency_animation.hpp =================================================================== --- main/trunk/src/karts/emergency_animation.hpp 2011-03-14 20:45:01 UTC (rev 7891) +++ main/trunk/src/karts/emergency_animation.hpp 2011-03-14 20:53:50 UTC (rev 7892) @@ -40,7 +40,7 @@ */ class EmergencyAnimation: public NoCopy { -private: +protected: /** The coordinates where the kart was hit originally. */ Vec3 m_xyz; Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2011-03-14 20:45:01 UTC (rev 7891) +++ main/trunk/src/karts/kart.cpp 2011-03-14 20:53:50 UTC (rev 7892) @@ -982,7 +982,7 @@ // on top of a surface (i.e. not falling), actually touching // something with the wheels, and the material has not the // below surface property set. - if(material && isOnGround() && !material->isBelowSurface()) + if(material && isOnGround() && !material->isBelowSurface() && m_kart_mode != EA_RESCUE) { Vec3 xyz; m_wheel_toggle = 1 - m_wheel_toggle; @@ -1050,7 +1050,7 @@ } const ParticleKind *pk = surface_material->getParticlesWhen(Material::EMIT_ON_DRIVE); - if(pk && !m_flying) + if(pk && !m_flying && m_kart_mode != EA_RESCUE) { const float distance = xyz.distance2(from); m_terrain_particles->setParticleType(pk); @@ -1076,7 +1076,8 @@ const std::string s = surface_material->getSFXName(); - if (s != "" && (m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED)) + if (s != "" && m_kart_mode != EA_RESCUE && + (m_terrain_sound == NULL || m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED)) { if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound); m_previous_terrain_sound = m_terrain_sound; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-04-19 22:57:58
|
Revision: 8385 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8385&view=rev Author: hikerstk Date: 2011-04-19 22:57:52 +0000 (Tue, 19 Apr 2011) Log Message: ----------- Fixed memory leak. Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2011-04-19 16:09:16 UTC (rev 8384) +++ main/trunk/src/karts/kart.cpp 2011-04-19 22:57:52 UTC (rev 8385) @@ -96,6 +96,7 @@ m_shadow = NULL; m_terrain_particles = NULL; m_nitro = NULL; + m_nitro_kind = NULL; m_slipstream = NULL; m_skidmarks = NULL; m_camera = NULL; @@ -377,6 +378,7 @@ if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound); if(m_terrain_particles) delete m_terrain_particles; if(m_nitro) delete m_nitro; + if(m_nitro_kind) delete m_nitro_kind; if(m_slipstream) delete m_slipstream; if(m_rain) delete m_rain; if(m_sky_particles_emitter) delete m_sky_particles_emitter; @@ -1735,9 +1737,8 @@ try { - m_nitro = new ParticleEmitter( - new ParticleKind(file_manager->getGfxFile("nitro.xml")), - position, getNode()); + m_nitro_kind = new ParticleKind(file_manager->getGfxFile("nitro.xml")); + m_nitro = new ParticleEmitter(m_nitro_kind, position, getNode()); } catch (std::runtime_error& e) { Modified: main/trunk/src/karts/kart.hpp =================================================================== --- main/trunk/src/karts/kart.hpp 2011-04-19 16:09:16 UTC (rev 8384) +++ main/trunk/src/karts/kart.hpp 2011-04-19 22:57:52 UTC (rev 8385) @@ -143,6 +143,9 @@ /** Graphical effect when using a nitro. */ ParticleEmitter *m_nitro; + /** The particle kind for the nitro. */ + ParticleKind *m_nitro_kind; + /** Handles all slipstreaming. */ SlipStream *m_slipstream; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2011-05-22 01:16:28
|
Revision: 8655 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=8655&view=rev Author: auria Date: 2011-05-22 01:16:19 +0000 (Sun, 22 May 2011) Log Message: ----------- Make end camera stick a bit more Modified Paths: -------------- main/trunk/src/karts/controller/player_controller.cpp main/trunk/src/karts/emergency_animation.cpp main/trunk/src/karts/kart.cpp Modified: main/trunk/src/karts/controller/player_controller.cpp =================================================================== --- main/trunk/src/karts/controller/player_controller.cpp 2011-05-22 01:08:13 UTC (rev 8654) +++ main/trunk/src/karts/controller/player_controller.cpp 2011-05-22 01:16:19 UTC (rev 8655) @@ -313,17 +313,20 @@ // look backward when the player requests or // if automatic reverse camera is active - if (m_controls->m_look_back || (UserConfigParams::m_reverse_look_threshold>0 && - m_kart->getSpeed()<-UserConfigParams::m_reverse_look_threshold)) + if (m_kart->getCamera()->getMode() != Camera::CM_FINAL) { - m_kart->getCamera()->setMode(Camera::CM_REVERSE); + if (m_controls->m_look_back || (UserConfigParams::m_reverse_look_threshold>0 && + m_kart->getSpeed()<-UserConfigParams::m_reverse_look_threshold)) + { + m_kart->getCamera()->setMode(Camera::CM_REVERSE); + } + else + { + if (m_kart->getCamera()->getMode() == Camera::CM_REVERSE) + m_kart->getCamera()->setMode(Camera::CM_NORMAL); + } } - else - { - if (m_kart->getCamera()->getMode() == Camera::CM_REVERSE) - m_kart->getCamera()->setMode(Camera::CM_NORMAL); - } - + // We can't restrict rescue to fulfil isOnGround() (which would be more like // MK), since e.g. in the City track it is possible for the kart to end // up sitting on a brick wall, with all wheels in the air :(( Modified: main/trunk/src/karts/emergency_animation.cpp =================================================================== --- main/trunk/src/karts/emergency_animation.cpp 2011-05-22 01:08:13 UTC (rev 8654) +++ main/trunk/src/karts/emergency_animation.cpp 2011-05-22 01:16:19 UTC (rev 8655) @@ -209,7 +209,7 @@ // here, and again in reset (e.g. when restarting the race) if // m_eliminated is still true. m_eliminated = false; - if(m_kart->getCamera()) + if(m_kart->getCamera() && m_kart->getCamera()->getMode() != Camera::CM_FINAL) m_kart->getCamera()->setMode(Camera::CM_NORMAL); return; } Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2011-05-22 01:08:13 UTC (rev 8654) +++ main/trunk/src/karts/kart.cpp 2011-05-22 01:16:19 UTC (rev 8655) @@ -1068,7 +1068,7 @@ // Now the kart is either falling, or driving on a terrain which // has the 'below surface' flag set. Detect if there is a surface // on top of the kart. - if (m_camera) + if (m_camera && m_camera->getMode() != Camera::CM_FINAL) { if (material && material->hasFallingEffect() && !m_flying) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2011-06-27 11:43:26
|
Revision: 9108 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=9108&view=rev Author: hikerstk Date: 2011-06-27 11:43:19 +0000 (Mon, 27 Jun 2011) Log Message: ----------- 1) Moved LOD node from kart into kart_model (which should handle all graphics for the karts). 2) Fixed squashing of karts in case of disabled animations (see #283, but only partly solved). Modified Paths: -------------- main/trunk/src/karts/kart.cpp main/trunk/src/karts/kart_model.cpp main/trunk/src/karts/kart_model.hpp Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2011-06-27 11:12:32 UTC (rev 9107) +++ main/trunk/src/karts/kart.cpp 2011-06-27 11:43:19 UTC (rev 9108) @@ -32,7 +32,6 @@ #include "audio/sfx_base.hpp" #include "config/user_config.hpp" #include "graphics/camera.hpp" -#include "graphics/lod_node.hpp" #include "graphics/material_manager.hpp" #include "graphics/particle_emitter.hpp" #include "graphics/particle_kind.hpp" @@ -483,8 +482,8 @@ m_camera->setInitialTransform(); } - // Reset squashing and animations - m_kart_model->resetWheels(); + // Reset animations and wheels + m_kart_model->reset(); // If the controller was replaced (e.g. replaced by end controller), // restore the original controller. @@ -504,7 +503,7 @@ m_finish_time = 0.0f; m_invulnerable_time = 0.0f; m_squash_time = 0.0f; - m_kart_model->scaleKart(Vec3(1.0f, 1.0f, 1.0f)); + m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f)); m_collected_energy = 0; m_has_started = false; m_wheel_rotation = 0; @@ -752,7 +751,7 @@ // If squasing time ends, reset the model if(m_squash_time<=0) { - m_kart_model->scaleKart(Vec3(1.0f, 1.0f, 1.0f)); + m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f)); MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, /*slowdown*/1.0f, /*fade in*/0.0f); } @@ -961,7 +960,7 @@ */ void Kart::setSquash(float time, float slowdown) { - m_kart_model->scaleKart(Vec3(1.0f, 0.5f, 1.0f)); + m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f)); MaxSpeed::setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown, 0.1f); m_squash_time = time; } // setSquash @@ -1728,22 +1727,11 @@ /** Attaches the right model, creates the physics and loads all special * effects (particle systems etc.) */ -void Kart::loadData(RaceManager::KartType type, bool is_first_kart, Track* track, bool animatedModel) +void Kart::loadData(RaceManager::KartType type, bool is_first_kart, + Track* track, bool is_animated_model) { - if (animatedModel) - { - scene::ISceneNode* staticModel = m_kart_model->attachModel(false); - scene::ISceneNode* animatedModelNode = m_kart_model->attachModel(animatedModel); - LODNode* node = new LODNode(irr_driver->getSceneManager()->getRootSceneNode(), - irr_driver->getSceneManager()); - node->add(50, animatedModelNode, true); - node->add(500, staticModel, true); - m_node = node; - } - else - { - m_node = m_kart_model->attachModel(animatedModel); - } + + m_node = m_kart_model->attachModel(is_animated_model); #ifdef DEBUG m_node->setName( (m_kart_properties->getIdent()+"(lod-node)").c_str() ); Modified: main/trunk/src/karts/kart_model.cpp =================================================================== --- main/trunk/src/karts/kart_model.cpp 2011-06-27 11:12:32 UTC (rev 9107) +++ main/trunk/src/karts/kart_model.cpp 2011-06-27 11:43:19 UTC (rev 9108) @@ -20,10 +20,12 @@ #include "karts/kart_model.hpp" #include <IMeshSceneNode.h> +#include <ISceneManager.h> #include "config/stk_config.hpp" #include "config/user_config.hpp" #include "graphics/irr_driver.hpp" +#include "graphics/lod_node.hpp" #include "graphics/mesh_tools.hpp" #include "io/xml_node.hpp" #include "karts/kart.hpp" @@ -198,24 +200,34 @@ /** Attach the kart model and wheels to the scene node. * \return the node with the model attached */ -scene::ISceneNode* KartModel::attachModel(bool animatedModels) +scene::ISceneNode* KartModel::attachModel(bool animated_models) { assert(!m_is_master); scene::ISceneNode* node; - if (animatedModels) + if (animated_models) { + LODNode* lod_node = new LODNode( + irr_driver->getSceneManager()->getRootSceneNode(), + irr_driver->getSceneManager() ); + + node = irr_driver->addAnimatedMesh(m_mesh); + lod_node->add(50, node, true); + scene::ISceneNode* static_model = attachModel(false); + lod_node->add(500, static_model, true); m_animated_node = static_cast<scene::IAnimatedMeshSceneNode*>(node); #ifdef DEBUG + std::string debug_name = m_model_filename+" (animated-kart-model)"; + node->setName(debug_name.c_str()); #if SKELETON_DEBUG irr_driver->debug_meshes.push_back(m_animated_node); #endif -#endif - +#endif m_animated_node->setLoopMode(false); m_animated_node->grab(); + node = lod_node; } else { @@ -229,20 +241,12 @@ main_frame->setHardwareMappingHint(scene::EHM_STATIC); node = irr_driver->addMesh(main_frame); - } - #ifdef DEBUG - if (animatedModels) - { - std::string debug_name = m_model_filename+" (animated-kart-model)"; - node->setName(debug_name.c_str()); - } - else - { std::string debug_name = m_model_filename+" (kart-model)"; node->setName(debug_name.c_str()); - } #endif + } + for(unsigned int i=0; i<4; i++) { @@ -377,17 +381,19 @@ } // setDefaultPhysicsPosition // ---------------------------------------------------------------------------- -/** Resets the kart model. It removes any scaling (squashing) and stops - * animation from being played. +/** Resets the kart model. It stops animation from being played and resets + * the wheels to the correct position (i.e. no suspension). */ void KartModel::reset() { - m_animated_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f)); + // Reset the wheels + const float suspension[4]={0,0,0,0}; + update(0, 0.0f, suspension); // Stop any animations currently being played. setAnimation(KartModel::AF_DEFAULT); - } // reset + // ---------------------------------------------------------------------------- /** Enables- or disables the end animation. * \param type The type of animation to play. @@ -532,21 +538,3 @@ m_animated_node->setCurrentFrame(frame); } // update -// ---------------------------------------------------------------------------- -/** Puts all wheels in the default position. Used when displaying the karts - * in the character selection screen. - */ -void KartModel::resetWheels() -{ - const float suspension[4]={0,0,0,0}; - update(0, 0.0f, suspension); -} // reset - -// ---------------------------------------------------------------------------- -/** Scales the kart model by a certain amount. */ -void KartModel::scaleKart(const Vec3 &s) -{ - if (m_animated_node) - m_animated_node->setScale(s.toIrrVector()); -} // scaleKart - Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2011-06-27 11:12:32 UTC (rev 9107) +++ main/trunk/src/karts/kart_model.hpp 2011-06-27 11:43:19 UTC (rev 9108) @@ -179,9 +179,7 @@ float getWidth () const {return m_kart_width; } float getHeight () const {return m_kart_height; } void update(float rotation, float steer, const float suspension[4]); - void resetWheels(); void setDefaultPhysicsPosition(const Vec3 ¢er_shift, float wheel_radius); - void scaleKart(const Vec3 &s); /** Enables- or disables the end animation. */ void setAnimation(AnimationFrameType type); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |