Most attachments (except tinytux, and therefore rescue general) work now.

More code cleanup.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3266 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-03-16 05:27:28 +00:00
parent f5d9330e77
commit c3ad0b9bed
7 changed files with 38 additions and 108 deletions

View File

@ -116,6 +116,8 @@ RaceGUI::~RaceGUI()
} // ~Racegui
//-----------------------------------------------------------------------------
#include "items/attachment.hpp"
void RaceGUI::handle(GameAction ga, int value)
{
static int isWireframe = false;
@ -151,11 +153,12 @@ void RaceGUI::handle(GameAction ga, int value)
if (race_manager->getNumPlayers() ==1 )
{
Kart* kart = RaceManager::getWorld()->getLocalPlayerKart(0);
kart->setPowerup(POWERUP_BUBBLEGUM, 10000);
// kart->setPowerup(POWERUP_BUBBLEGUM, 10000);
kart->attach(ATTACH_ANVIL, 5);
}
break;
case GA_DEBUG_ADD_MISSILE:
//FIXME if (race_manager->getNumPlayers() ==1 )
if (race_manager->getNumPlayers() ==1 )
{
Kart* kart = RaceManager::getPlayerKart(0);
kart->setPowerup(POWERUP_PLUNGER, 10000);

View File

@ -36,19 +36,7 @@ Attachment::Attachment(Kart* _kart)
m_kart = _kart;
m_previous_owner = NULL;
m_node = irr_driver->addMesh(NULL);
#ifdef HAVE_IRRLICHT
#else
m_holder = new ssgSelector();
m_kart->getModelTransform()->addKid(m_holder);
for(int i=ATTACH_FIRST; i<ATTACH_MAX; i++)
{
ssgEntity *p=attachment_manager->getModel((attachmentType)i);
m_holder->addKid(p);
}
m_holder->select(0);
#endif
m_node = NULL;
} // Attachment
//-----------------------------------------------------------------------------
@ -61,10 +49,8 @@ Attachment::~Attachment()
void Attachment::set(attachmentType type, float time, Kart *current_kart)
{
clear();
// m_node->add
#ifndef HAVE_IRRLICHT
m_holder->selectStep(type);
#endif
m_node = irr_driver->addMesh(attachment_manager->getMesh(type));
m_node->setParent(m_kart->getNode());
m_type = type;
m_time_left = time;
m_previous_owner = current_kart;
@ -87,10 +73,11 @@ void Attachment::clear()
{
m_type=ATTACH_NOTHING;
m_time_left=0.0;
#ifdef HAVE_IRRLICHT
#else
m_holder->select(0);
#endif
if(m_node)
{
irr_driver->removeNode(m_node);
m_node = NULL;
}
// Resets the weight of the kart if the previous attachment affected it
// (e.g. anvil). This must be done *after* setting m_type to

View File

@ -70,7 +70,8 @@ void AttachmentManager::loadModels()
{
// FIXME LEAK: these models are not removed (unimportant, since they
// have to be in memory till the end of the game.
m_attachments[iat[i].attachment]=irr_driver->getMesh(iat[i].file);
std::string full_path = file_manager->getModelFile(iat[i].file);
m_attachments[iat[i].attachment]=irr_driver->getMesh(full_path);
} // for
} // reInit

View File

@ -36,16 +36,12 @@
#include "utils/ssg_help.hpp"
// static variables:
float Flyable::m_st_speed[POWERUP_MAX];
#ifdef HAVE_IRRLICHT
float Flyable::m_st_speed[POWERUP_MAX];
scene::IMesh* Flyable::m_st_model[POWERUP_MAX];
#else
ssgEntity* Flyable::m_st_model[POWERUP_MAX];
#endif
float Flyable::m_st_min_height[POWERUP_MAX];
float Flyable::m_st_max_height[POWERUP_MAX];
float Flyable::m_st_force_updown[POWERUP_MAX];
btVector3 Flyable::m_st_extend[POWERUP_MAX];
float Flyable::m_st_min_height[POWERUP_MAX];
float Flyable::m_st_max_height[POWERUP_MAX];
float Flyable::m_st_force_updown[POWERUP_MAX];
btVector3 Flyable::m_st_extend[POWERUP_MAX];
// ----------------------------------------------------------------------------
Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable()
@ -70,14 +66,9 @@ Flyable::Flyable(Kart *kart, PowerupType type, float mass) : Moveable()
m_max_lifespan = -1;
// Add the graphical model
#ifdef HAVE_IRRLICHT
setRoot(irr_driver->addMesh(m_st_model[type]));
#else
ssgTransform *m = getModelTransform();
m->addKid(m_st_model[type]);
stk_scene->add(m);
#endif
setNode(irr_driver->addMesh(m_st_model[type]));
} // Flyable
// ----------------------------------------------------------------------------
void Flyable::createPhysics(float y_offset, const btVector3 &velocity,
btCollisionShape *shape, const float gravity,
@ -124,13 +115,8 @@ void Flyable::createPhysics(float y_offset, const btVector3 &velocity,
} // createPhysics
// -----------------------------------------------------------------------------
#ifdef HAVE_IRRLICHT
void Flyable::init(const lisp::Lisp* lisp, scene::IMesh *model,
PowerupType type)
#else
void Flyable::init(const lisp::Lisp* lisp, ssgEntity *model,
PowerupType type)
#endif
{
m_st_speed[type] = 25.0f;
m_st_max_height[type] = 1.0f;
@ -143,11 +129,7 @@ void Flyable::init(const lisp::Lisp* lisp, ssgEntity *model,
// Store the size of the model
Vec3 min, max;
#ifdef HAVE_IRRLICHT
MeshTools::minMax3D(model, &min, &max);
#else
SSGHelp::MinMax(model, &min, &max);
#endif
m_st_extend[type] = btVector3(max-min);
m_st_model[type] = model;
} // init
@ -275,12 +257,7 @@ void Flyable::hit(Kart *kart_hit, MovingPhysics* moving_physics)
projectile_manager->notifyRemove();
// Now remove this projectile from the graph:
#ifdef HAVE_IRRLICHT
#else
ssgTransform *m = getModelTransform();
m->removeAllKids();
stk_scene->remove(m);
#endif
irr_driver->removeMesh(m_mesh);
// The explosion is a bit higher in the air
Vec3 pos_explosion=getXYZ();

View File

@ -271,11 +271,8 @@ void Kart::eliminate()
RaceManager::getWorld()->getPhysics()->removeKart(this);
// make the kart invisible by placing it way under the track
sgVec3 hell; hell[0]=0.0f; hell[1]=0.0f; hell[2] = -10000.0f;
#ifdef HAVE_IRRLICHT
#else
getModelTransform()->setTransform(hell);
#endif
Vec3 hell(0, 0, -10000.0f);
getNode()->setPosition(hell.toIrrVector());
} // eliminate
//-----------------------------------------------------------------------------
@ -1004,23 +1001,9 @@ void Kart::loadData()
{
float r [ 2 ] = { -10.0f, 100.0f } ;
#ifdef HAVE_IRRLICHT
m_kart_properties->getKartModel()->attachModel(&m_root);
#else
ssgEntity *obj = m_kart_properties->getKartModel()->getRoot();
#endif
m_kart_properties->getKartModel()->attachModel(&m_node);
createPhysics();
#ifdef HAVE_IRRLICHT
#else
SSGHelp::createDisplayLists(obj); // create all display lists
ssgRangeSelector *lod = new ssgRangeSelector ;
lod -> addKid ( obj ) ;
lod -> setRanges ( r, 2 ) ;
getModelTransform() -> addKid ( lod ) ;
#endif
// Attach Particle System
m_smoke_system = new Smoke(this);
m_smoke_system->ref();

View File

@ -32,12 +32,8 @@ Moveable::Moveable()
m_body = 0;
m_motion_state = 0;
m_first_time = true;
#ifdef HAVE_IRRLICHT
m_mesh = 0;
#else
m_model_transform = new ssgTransform();
m_model_transform->ref();
#endif
m_mesh = NULL;
m_node = NULL;
} // Moveable
//-----------------------------------------------------------------------------
@ -55,12 +51,8 @@ void Moveable::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
Vec3 xyz=getXYZ()+off_xyz;
Vec3 hpr=getHPR()+off_hpr;
sgCoord c=Coord(xyz, hpr).toSgCoord();
#ifdef HAVE_IRRLICHT
m_root->setPosition(xyz.toIrrVector());
m_root->setRotation(hpr.toIrrHPR());
#else
m_model_transform->setTransform(&c);
#endif
m_node->setPosition(xyz.toIrrVector());
m_node->setRotation(hpr.toIrrHPR());
} // updateGraphics
//-----------------------------------------------------------------------------

View File

@ -21,13 +21,8 @@
#ifndef HEADER_MOVEABLE_HPP
#define HEADER_MOVEABLE_HPP
#define _WINSOCKAPI_
#ifdef HAVE_IRRLICHT
# include "irrlicht.h"
using namespace irr;
#else
# include <plib/ssg.h>
#endif
#include "irrlicht.h"
using namespace irr;
#include "btBulletDynamicsCommon.h"
#include "user_pointer.hpp"
@ -51,27 +46,19 @@ private:
protected:
UserPointer m_user_pointer;
#ifdef HAVE_IRRLICHT
scene::IAnimatedMesh *m_animated_mesh;
scene::IMesh *m_mesh;
scene::ISceneNode *m_root;
#else
ssgTransform *m_model_transform; /**<The transform the model is attached to. */
#endif
int m_first_time ;
btRigidBody *m_body;
KartMotionState *m_motion_state;
scene::ISceneNode *m_node;
int m_first_time ;
btRigidBody *m_body;
KartMotionState *m_motion_state;
public:
Moveable();
virtual ~Moveable();
#ifdef HAVE_IRRLICHT
scene::ISceneNode
*getRoot() {return m_root; }
void setRoot(scene::ISceneNode *n){m_root = n; }
#else
ssgTransform *getModelTransform() {return m_model_transform; }
#endif
*getNode() {return m_node; }
void setNode(scene::ISceneNode *n){m_node = n; }
virtual const btVector3
&getVelocity() const {return m_body->getLinearVelocity();}
const btVector3