Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentationFS14/src/orxonox/worldentities/pawns/Pawn.cc @ 10073

Last change on this file since 10073 was 10073, checked in by smerkli, 10 years ago

Merged modularships branch

  • Property svn:eol-style set to native
File size: 22.3 KB
RevLine 
[2072]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
[8706]25 *      Simon Miescher
[2072]26 *
27 */
28
29#include "Pawn.h"
30
[3280]31#include <algorithm>
32
[3196]33#include "core/CoreIncludes.h"
[2896]34#include "core/GameMode.h"
[2072]35#include "core/XMLPort.h"
[3196]36#include "network/NetworkFunction.h"
37
[5735]38#include "infos/PlayerInfo.h"
[6417]39#include "controllers/Controller.h"
[5735]40#include "gametypes/Gametype.h"
[5737]41#include "graphics/ParticleSpawner.h"
[5735]42#include "worldentities/ExplosionChunk.h"
43#include "worldentities/BigExplosion.h"
44#include "weaponsystem/WeaponSystem.h"
45#include "weaponsystem/WeaponSlot.h"
46#include "weaponsystem/WeaponPack.h"
47#include "weaponsystem/WeaponSet.h"
[9939]48#include "sound/WorldSound.h"
[2072]49
[9625]50#include "controllers/FormationController.h"
51
[10073]52#include "collisionshapes/WorldEntityCollisionShape.h"
53#include <BulletCollision/CollisionShapes/btCollisionShape.h>
54#include <BulletCollision/CollisionShapes/btCompoundShape.h>
55#include "graphics/Model.h"
56
57
[2072]58namespace orxonox
59{
[9667]60    RegisterClass(Pawn);
[2072]61
[9667]62    Pawn::Pawn(Context* context)
63        : ControllableEntity(context)
64        , RadarViewable(this, static_cast<WorldEntity*>(this))
[2072]65    {
66        RegisterObject(Pawn);
67
[2662]68        this->bAlive_ = true;
[3053]69        this->bReload_ = false;
[2072]70
71        this->health_ = 0;
72        this->maxHealth_ = 0;
73        this->initialHealth_ = 0;
[8706]74
[7163]75        this->shieldHealth_ = 0;
[8706]76        this->initialShieldHealth_ = 0;
77        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
[7163]78        this->shieldAbsorption_ = 0.5;
[2072]79
[8706]80        this->reloadRate_ = 0;
81        this->reloadWaitTime_ = 1.0f;
82        this->reloadWaitCountdown_ = 0;
83
[2072]84        this->lastHitOriginator_ = 0;
85
[9348]86        // set damage multiplier to default value 1, meaning nominal damage
87        this->damageMultiplier_ = 1;
88
[2662]89        this->spawnparticleduration_ = 3.0f;
[2098]90
[6417]91        this->aimPosition_ = Vector3::ZERO;
92
[2896]93        if (GameMode::isMaster())
[2662]94        {
[9667]95            this->weaponSystem_ = new WeaponSystem(this->getContext());
[3053]96            this->weaponSystem_->setPawn(this);
[2662]97        }
98        else
99            this->weaponSystem_ = 0;
100
101        this->setRadarObjectColour(ColourValue::Red);
102        this->setRadarObjectShape(RadarViewable::Dot);
103
[2072]104        this->registerVariables();
[3089]105
106        this->isHumanShip_ = this->hasLocalController();
[8891]107
[8329]108        this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
[9939]109
110        if (GameMode::isMaster())
111        {
112            this->explosionSound_ = new WorldSound(this->getContext());
113            this->explosionSound_->setVolume(1.0f);
114        }
115        else
116        {
117            this->explosionSound_ = 0;
118        }
[2072]119    }
120
121    Pawn::~Pawn()
122    {
[2662]123        if (this->isInitialized())
124        {
125            if (this->weaponSystem_)
[5929]126                this->weaponSystem_->destroy();
[2662]127        }
[2072]128    }
129
130    void Pawn::XMLPort(Element& xmlelement, XMLPort::Mode mode)
131    {
132        SUPER(Pawn, XMLPort, xmlelement, mode);
133
[2662]134        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
[2072]135        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
136        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
[7163]137
138        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
[8706]139        XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
140        XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
[7163]141        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
142
[2662]143        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
144        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
145        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
146
[3053]147        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
148        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
[6417]149        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
[8706]150
151        XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
152        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
[9254]153
[9939]154        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
155
[9257]156        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
[2072]157    }
158
159    void Pawn::registerVariables()
160    {
[7163]161        registerVariable(this->bAlive_,           VariableDirection::ToClient);
162        registerVariable(this->health_,           VariableDirection::ToClient);
[8706]163        registerVariable(this->maxHealth_,        VariableDirection::ToClient);
[7163]164        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
[8706]165        registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
[7163]166        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
167        registerVariable(this->bReload_,          VariableDirection::ToServer);
168        registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
[2072]169    }
170
171    void Pawn::tick(float dt)
172    {
[2809]173        SUPER(Pawn, tick, dt);
[2072]174
[3053]175        this->bReload_ = false;
[2662]176
[8706]177        // TODO: use the existing timer functions instead
178        if(this->reloadWaitCountdown_ > 0)
179        {
180            this->decreaseReloadCountdownTime(dt);
181        }
182        else
183        {
184            this->addShieldHealth(this->getReloadRate() * dt);
185            this->resetReloadCountdown();
186        }
187
[3084]188        if (GameMode::isMaster())
[8706]189        {
[3087]190            if (this->health_ <= 0 && bAlive_)
[6864]191            {
[8706]192                this->fireEvent(); // Event to notify anyone who wants to know about the death.
[3087]193                this->death();
[6864]194            }
[8706]195        }
[2072]196    }
197
[7889]198    void Pawn::preDestroy()
199    {
200        // yay, multiple inheritance!
201        this->ControllableEntity::preDestroy();
202        this->PickupCarrier::preDestroy();
203    }
204
[2826]205    void Pawn::setPlayer(PlayerInfo* player)
206    {
207        ControllableEntity::setPlayer(player);
208
209        if (this->getGametype())
210            this->getGametype()->playerStartsControllingPawn(player, this);
211    }
212
213    void Pawn::removePlayer()
214    {
215        if (this->getGametype())
216            this->getGametype()->playerStopsControllingPawn(this->getPlayer(), this);
217
218        ControllableEntity::removePlayer();
219    }
220
[8706]221
[2072]222    void Pawn::setHealth(float health)
223    {
[8706]224        this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit
[2072]225    }
226
[8706]227    void Pawn::setShieldHealth(float shieldHealth)
[2072]228    {
[8706]229        this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
230    }
231
232    void Pawn::setMaxShieldHealth(float maxshieldhealth)
233    {
234        this->maxShieldHealth_ = maxshieldhealth;
235    }
236
237    void Pawn::setReloadRate(float reloadrate)
238    {
239        this->reloadRate_ = reloadrate;
240    }
241
242    void Pawn::setReloadWaitTime(float reloadwaittime)
243    {
244        this->reloadWaitTime_ = reloadwaittime;
245    }
246
247    void Pawn::decreaseReloadCountdownTime(float dt)
248    {
249        this->reloadWaitCountdown_ -= dt;
250    }
251
[10073]252    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
[8706]253    {
[10073]254        //FIXME: (noep) remove debug
255        //orxout() << "damage(): Collision detected on " << this->getName() << ", btCS*: " << cs << endl;
256
257        //int collisionShapeIndex = this->isMyCollisionShape(cs);
258        //orxout() << collisionShapeIndex << endl;
259
[9348]260        // Applies multiplier given by the DamageBoost Pickup.
261        if (originator)
262            damage *= originator->getDamageMultiplier();
263
[2826]264        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
265        {
[8706]266            if (shielddamage >= this->getShieldHealth())
[7163]267            {
268                this->setShieldHealth(0);
[8706]269                this->setHealth(this->health_ - (healthdamage + damage));
[7163]270            }
[8706]271            else
272            {
273                this->setShieldHealth(this->shieldHealth_ - shielddamage);
[7163]274
[8706]275                // remove remaining shieldAbsorpton-Part of damage from shield
276                shielddamage = damage * this->shieldAbsorption_;
277                shielddamage = std::min(this->getShieldHealth(),shielddamage);
278                this->setShieldHealth(this->shieldHealth_ - shielddamage);
[7163]279
[8706]280                // set remaining damage to health
281                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
[7163]282            }
283
[2826]284            this->lastHitOriginator_ = originator;
285        }
[2072]286    }
287
[8706]288// TODO: Still valid?
289/* HIT-Funktionen
290    Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
291
292*/
[10073]293    void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
[2072]294    {
[6417]295        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
[2826]296        {
[10073]297            this->damage(damage, healthdamage, shielddamage, originator, cs);
[2826]298            this->setVelocity(this->getVelocity() + force);
299        }
[2072]300    }
301
[10073]302    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
[6417]303    {
304        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
305        {
[10073]306            this->damage(damage, healthdamage, shielddamage, originator, cs);
[6417]307
308            if ( this->getController() )
[8706]309                this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
[6417]310        }
311    }
312
[8706]313
[2072]314    void Pawn::kill()
315    {
[9945]316        this->damage(this->health_);
[2072]317        this->death();
318    }
319
[2662]320    void Pawn::spawneffect()
[2072]321    {
322        // play spawn effect
[6417]323        if (!this->spawnparticlesource_.empty())
[2662]324        {
[9667]325            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
[2662]326            effect->setPosition(this->getPosition());
327            effect->setOrientation(this->getOrientation());
328            effect->setDestroyAfterLife(true);
329            effect->setSource(this->spawnparticlesource_);
330            effect->setLifetime(this->spawnparticleduration_);
331        }
[2072]332    }
333
[9625]334
[2072]335    void Pawn::death()
336    {
[3033]337        this->setHealth(1);
[2826]338        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
339        {
[9945]340            // Set bAlive_ to false and wait for PawnManager to do the destruction
[2826]341            this->bAlive_ = false;
[2662]342
[2826]343            this->setDestroyWhenPlayerLeft(false);
[2662]344
[2826]345            if (this->getGametype())
346                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
[2662]347
[3038]348            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
[9625]349            {
[9663]350                // Start to control a new entity if you're the master of a formation
351                if(this->hasSlaves())
352                {
353                    Controller* slave = this->getSlave();
354                    ControllableEntity* entity = slave->getControllableEntity();
[2072]355
[9625]356
[9663]357                    if(!entity->hasHumanController())
358                    {
[9666]359                        // delete the AIController // <-- TODO: delete? nothing is deleted here... should we delete the controller?
[9663]360                        slave->setControllableEntity(0);
[9625]361
[9663]362                        // set a new master within the formation
363                        orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
[9625]364
[9663]365                        // start to control a slave
366                        this->getPlayer()->startControl(entity);
367                    }
368                    else
369                    {
370                        this->getPlayer()->stopControl();
371                    }
[9625]372
[9663]373                }
374                else
375                {
376                    this->getPlayer()->stopControl();
377                }
[9625]378            }
[2896]379            if (GameMode::isMaster())
[3087]380            {
381//                this->deathEffect();
382                this->goWithStyle();
383            }
[2826]384        }
[2662]385    }
[3087]386    void Pawn::goWithStyle()
387    {
388        this->bAlive_ = false;
389        this->setDestroyWhenPlayerLeft(false);
[2072]390
[9949]391        BigExplosion* chunk = new BigExplosion(this->getContext());
[3087]392        chunk->setPosition(this->getPosition());
[9949]393        chunk->setVelocity(this->getVelocity());
[3087]394
[9947]395        this->explosionSound_->setPosition(this->getPosition());
396        this->explosionSound_->play();
[3087]397    }
[2662]398    void Pawn::deatheffect()
399    {
[2072]400        // play death effect
[2662]401        {
[9667]402            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
[2662]403            effect->setPosition(this->getPosition());
404            effect->setOrientation(this->getOrientation());
405            effect->setDestroyAfterLife(true);
406            effect->setSource("Orxonox/explosion2b");
407            effect->setLifetime(4.0f);
408        }
409        {
[9667]410            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
[2662]411            effect->setPosition(this->getPosition());
412            effect->setOrientation(this->getOrientation());
413            effect->setDestroyAfterLife(true);
414            effect->setSource("Orxonox/smoke6");
415            effect->setLifetime(4.0f);
416        }
417        {
[9667]418            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
[2662]419            effect->setPosition(this->getPosition());
420            effect->setOrientation(this->getOrientation());
421            effect->setDestroyAfterLife(true);
422            effect->setSource("Orxonox/sparks");
423            effect->setLifetime(4.0f);
424        }
425        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
426        {
[9667]427            ExplosionChunk* chunk = new ExplosionChunk(this->getContext());
[2662]428            chunk->setPosition(this->getPosition());
429        }
[2072]430    }
431
[6417]432    void Pawn::fired(unsigned int firemode)
[2098]433    {
[6417]434        if (this->weaponSystem_)
435            this->weaponSystem_->fire(firemode);
[2098]436    }
437
[3053]438    void Pawn::reload()
439    {
440        this->bReload_ = true;
441    }
442
[2072]443    void Pawn::postSpawn()
444    {
445        this->setHealth(this->initialHealth_);
[2896]446        if (GameMode::isMaster())
[2662]447            this->spawneffect();
[2072]448    }
[2662]449
[2893]450    /* WeaponSystem:
451    *   functions load Slot, Set, Pack from XML and make sure all parent-pointers are set.
452    *   with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it.
453    *       --> e.g. Pickup-Items
454    */
[3053]455    void Pawn::addWeaponSlot(WeaponSlot * wSlot)
[2662]456    {
457        this->attach(wSlot);
458        if (this->weaponSystem_)
[3053]459            this->weaponSystem_->addWeaponSlot(wSlot);
[2662]460    }
461
462    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
463    {
464        if (this->weaponSystem_)
[3053]465            return this->weaponSystem_->getWeaponSlot(index);
[2662]466        else
467            return 0;
468    }
469
[3053]470    void Pawn::addWeaponSet(WeaponSet * wSet)
[2662]471    {
472        if (this->weaponSystem_)
[3053]473            this->weaponSystem_->addWeaponSet(wSet);
[2662]474    }
475
[3053]476    WeaponSet * Pawn::getWeaponSet(unsigned int index) const
[2662]477    {
478        if (this->weaponSystem_)
[3053]479            return this->weaponSystem_->getWeaponSet(index);
[2662]480        else
481            return 0;
482    }
483
[3053]484    void Pawn::addWeaponPack(WeaponPack * wPack)
[2662]485    {
486        if (this->weaponSystem_)
[7163]487        {
[3053]488            this->weaponSystem_->addWeaponPack(wPack);
[7163]489            this->addedWeaponPack(wPack);
490        }
[2662]491    }
492
[6417]493    void Pawn::addWeaponPackXML(WeaponPack * wPack)
494    {
495        if (this->weaponSystem_)
[7163]496        {
[6417]497            if (!this->weaponSystem_->addWeaponPack(wPack))
498                wPack->destroy();
[7163]499            else
500                this->addedWeaponPack(wPack);
501        }
[6417]502    }
503
[3053]504    WeaponPack * Pawn::getWeaponPack(unsigned int index) const
[2662]505    {
506        if (this->weaponSystem_)
[3053]507            return this->weaponSystem_->getWeaponPack(index);
[2662]508        else
509            return 0;
510    }
511
[3089]512    //Tell the Map (RadarViewable), if this is a playership
513    void Pawn::startLocalHumanControl()
514    {
515//        SUPER(ControllableEntity, changedPlayer());
516        ControllableEntity::startLocalHumanControl();
517        this->isHumanShip_ = true;
518    }
[8891]519
520    void Pawn::changedVisibility(void)
521    {
522        SUPER(Pawn, changedVisibility);
[9254]523
524        // enable proper radarviewability when the visibility is changed
525        this->RadarViewable::settingsChanged();
[8891]526    }
527
[9625]528
529    // A function to check if this pawn's controller is the master of any formationcontroller
530    bool Pawn::hasSlaves()
531    {
[9663]532        for (ObjectList<FormationController>::iterator it =
533             ObjectList<FormationController>::begin();
534             it != ObjectList<FormationController>::end(); ++it )
535        {
536            // checks if the pawn's controller has a slave
537            if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
538                return true;
539        }
540        return false;
[9625]541    }
542
543    // A function that returns a slave of the pawn's controller
544    Controller* Pawn::getSlave(){
[9663]545        for (ObjectList<FormationController>::iterator it =
546                ObjectList<FormationController>::begin();
547                it != ObjectList<FormationController>::end(); ++it )
548        {
549            if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
550                return it->getController();
551        }
552        return 0;
[9625]553    }
554
555
[9939]556    void Pawn::setExplosionSound(const std::string &explosionSound)
557    {
558        if(explosionSound_ )
559            explosionSound_->setSource(explosionSound);
560        else
561            assert(0); // This should never happen, because soundpointer is only available on master
562    }
[9625]563
[9939]564    const std::string& Pawn::getExplosionSound()
565    {
566        if( explosionSound_ )
567            return explosionSound_->getSource();
568        else
569            assert(0);
570        return BLANKSTRING;
571    }
572
573
[10073]574    int Pawn::isMyCollisionShape(const btCollisionShape* cs)
575    {
576        // This entities WECS
577        WorldEntityCollisionShape* ownWECS = this->getWorldEntityCollisionShape();
578
579        // e.g. "Box 4: Searching for CS 0x1ad49200"
580        orxout() << this->getName() << ": Searching for btCS* " << cs << endl;
581        // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
582        orxout() << "  " << this->getName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
583        // e.g. "Box 4 is WorldEntity 0x126dd060"
584        orxout() << "  " << this->getName() << " is WorldEntity* " << this << endl;
585        // e.g. "Box 4 is objectID 943"
586        orxout() << "  " << this->getName() << " is objectID " << this->getObjectID() << endl;
587
588        // List all attached Objects
589        orxout() << "  " << this->getName() << " has the following Objects attached:" << endl;
590        for (int i=0; i<50; i++)
591        {
592            if (this->getAttachedObject(i)==NULL)
593                break;
594            orxout() << " " << i << ": " << this->getAttachedObject(i) << " (" << this->getAttachedObject(i)->getName() << ")";
595            if(!orxonox_cast<Model*>(this->getAttachedObject(i)))
596                orxout() << " (SE)";
597            orxout() << endl;
598        }
599
600
601        // print child shapes of this WECS
602        printBtChildShapes((btCompoundShape*)(ownWECS->getCollisionShape()), 2, 0);
603
604        int temp = entityOfCollisionShape(cs);
605        if (temp==0)
606            orxout() << this->getName() << " has been hit on it's main body." << endl;
607        else
608            orxout() << this->getName() << " has been hit on the attached entity no. " << temp << endl;
609
610        // end
611        return -1;
612    }
613
614    void Pawn::printBtChildShapes(btCompoundShape* cs, int indent, int subshape)
615    {
616        // e.g. "  Childshape 1 (WECS 0x126dc8c0) has 2 childshapes:"
617        printSpaces(indent);  orxout() << "Childshape " << subshape << " (btCS* " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
618
619        for (int i=0; i < cs->getNumChildShapes(); i++)
620        {
621            printSpaces(indent+2);  orxout() << "- " << i << " - - -" << endl;
622
623            // For each childshape, print: (as long as it's not another CompoundCollisionShape)
624            if (!orxonox_cast<btCompoundShape*>(cs->getChildShape(i)))
625            {
626                // pointer to the btCollisionShape
627                printSpaces(indent+2);  orxout() << "btCollisionShape*: " << cs->getChildShape(i) << endl;
628
629                // pointer to the btCollisionShape
630                printSpaces(indent+2);  orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << " (name_: " << ((BaseObject*)(cs->getChildShape(i)->getUserPointer()))->getName() << ")" << endl;
631            }
632
633            // if the childshape is a CompoundCollisionShape, print its children.
634            if (cs->getChildShape(i)->isCompound())
635                printBtChildShapes((btCompoundShape*)(cs->getChildShape(i)), indent+2, i);
636
637        }
638    }
639
640    int Pawn::entityOfCollisionShape(const btCollisionShape* cs)
641    {
642        btCompoundShape* ownBtCS = (btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape());
643
644        return -1;
645    }
646
647    void Pawn::printSpaces(int num)
648    {
649        for(int i=0; i<num; i++)
650            orxout() << " ";
651    }
[2072]652}
Note: See TracBrowser for help on using the repository browser.