improved plunger to point in right direction and allow shooting backwards

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2471 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2008-11-18 01:29:22 +00:00
parent e74fffd6cc
commit 94cfd1bab8
5 changed files with 354 additions and 336 deletions

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Flyable::createPhysics(float y_offset, const btVector3 velocity, void Flyable::createPhysics(float y_offset, const btVector3 velocity,
btCollisionShape *shape, const bool gravity, btCollisionShape *shape, const bool gravity,
const bool rotates, const btTransform* customDirection) const bool rotates, const bool turn_around, const btTransform* customDirection)
{ {
// Get Kart heading direction // Get Kart heading direction
btTransform trans = ( customDirection == NULL ? m_owner->getKartHeading() : *customDirection ); btTransform trans = ( customDirection == NULL ? m_owner->getKartHeading() : *customDirection );
@ -76,6 +76,16 @@ void Flyable::createPhysics(float y_offset, const btVector3 velocity,
btVector3 offset=btVector3(0,y_offset,m_average_height); btVector3 offset=btVector3(0,y_offset,m_average_height);
offset_transform.setOrigin(offset); offset_transform.setOrigin(offset);
// turn around
if(turn_around)
{
btTransform turn_around_trans;
//turn_around_trans.setOrigin(trans.getOrigin());
turn_around_trans.setIdentity();
turn_around_trans.setRotation(btQuaternion(btVector3(0, 0, 1), M_PI));
trans *= turn_around_trans;
}
trans *= offset_transform; trans *= offset_transform;
m_shape = shape; m_shape = shape;

View File

@ -74,7 +74,8 @@ protected:
void createPhysics(float y_offset, void createPhysics(float y_offset,
const btVector3 velocity, const btVector3 velocity,
btCollisionShape *shape, const bool gravity=false, btCollisionShape *shape, const bool gravity=false,
const bool rotates=false, const btTransform* customDirection=NULL); const bool rotates=false, const bool turn_around=false,
const btTransform* customDirection=NULL);
public: public:
Flyable (Kart* kart, PowerupType type, float mass=1.0f); Flyable (Kart* kart, PowerupType type, float mass=1.0f);

View File

@ -19,19 +19,27 @@
#include "items/plunger.hpp" #include "items/plunger.hpp"
#include "constants.hpp" #include "constants.hpp"
#include "coord.hpp"
#include "karts/player_kart.hpp"
#include "camera.hpp"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER) Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER)
{ {
float y_offset=kart->getKartLength()+2.0f*m_extend.getY(); float y_offset = 0.5f*kart->getKartLength()+2.0f*m_extend.getY();
createPhysics(y_offset, btVector3(0.0f, m_speed, 0.0f),
new btCylinderShape(0.5f*m_extend)); // if the kart is looking backwards, release from the back
} // Missile PlayerKart* pk = dynamic_cast<PlayerKart*>(kart);
const bool reverse_mode = (pk != NULL && pk->getCamera()->getMode() == Camera::CM_REVERSE);
createPhysics(y_offset, btVector3(0.0f, m_speed*2, 0.0f),
new btCylinderShape(0.5f*m_extend), false, false, reverse_mode );
} // Plunger
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Plunger::init(const lisp::Lisp* lisp, ssgEntity *missile) void Plunger::init(const lisp::Lisp* lisp, ssgEntity *plunger_model)
{ {
Flyable::init(lisp, missile, POWERUP_PLUNGER); Flyable::init(lisp, plunger_model, POWERUP_PLUNGER);
} // init } // init
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -140,8 +140,6 @@ void PowerupManager::LoadNode(const lisp::Lisp* lisp, int collectType )
Bowling::init (lisp, m_all_models[collectType]); break; Bowling::init (lisp, m_all_models[collectType]); break;
case POWERUP_PLUNGER: case POWERUP_PLUNGER:
Plunger::init (lisp, m_all_models[collectType]); break; Plunger::init (lisp, m_all_models[collectType]); break;
//case POWERUP_BUBBLEGUM:
// BubbleGum::init(lisp, m_all_models[collectType]); break;
case POWERUP_CAKE: case POWERUP_CAKE:
Cake::init (lisp, m_all_models[collectType]); break; Cake::init (lisp, m_all_models[collectType]); break;
default:; default:;