Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/modularships/src/orxonox/worldentities/pawns/Pawn.cc @ 10007

Last change on this file since 10007 was 10007, checked in by noep, 10 years ago

More research done on collisionshape-entity-structure, and started cleaning up the debug-output.

  • Property svn:eol-style set to native
File size: 24.6 KB
Line 
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:
25 *      Simon Miescher
26 *
27 */
28
29#include "Pawn.h"
30
31#include <algorithm>
32
33#include "core/CoreIncludes.h"
34#include "core/GameMode.h"
35#include "core/XMLPort.h"
36#include "network/NetworkFunction.h"
37
38#include "infos/PlayerInfo.h"
39#include "controllers/Controller.h"
40#include "gametypes/Gametype.h"
41#include "graphics/ParticleSpawner.h"
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"
48#include "sound/WorldSound.h"
49
50#include "controllers/FormationController.h"
51
52#include "collisionshapes/WorldEntityCollisionShape.h"
53#include <BulletCollision/CollisionShapes/btCollisionShape.h>
54#include <BulletCollision/CollisionShapes/btCompoundShape.h>
55#include "graphics/Model.h"
56
57
58namespace orxonox
59{
60    RegisterClass(Pawn);
61
62    Pawn::Pawn(Context* context)
63        : ControllableEntity(context)
64        , RadarViewable(this, static_cast<WorldEntity*>(this))
65    {
66        RegisterObject(Pawn);
67
68        this->bAlive_ = true;
69        this->bReload_ = false;
70
71        this->health_ = 0;
72        this->maxHealth_ = 0;
73        this->initialHealth_ = 0;
74
75        this->shieldHealth_ = 0;
76        this->initialShieldHealth_ = 0;
77        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
78        this->shieldAbsorption_ = 0.5;
79
80        this->reloadRate_ = 0;
81        this->reloadWaitTime_ = 1.0f;
82        this->reloadWaitCountdown_ = 0;
83
84        this->lastHitOriginator_ = 0;
85
86        // set damage multiplier to default value 1, meaning nominal damage
87        this->damageMultiplier_ = 1;
88
89        this->spawnparticleduration_ = 3.0f;
90
91        this->aimPosition_ = Vector3::ZERO;
92
93        if (GameMode::isMaster())
94        {
95            this->weaponSystem_ = new WeaponSystem(this->getContext());
96            this->weaponSystem_->setPawn(this);
97        }
98        else
99            this->weaponSystem_ = 0;
100
101        this->setRadarObjectColour(ColourValue::Red);
102        this->setRadarObjectShape(RadarViewable::Dot);
103
104        this->registerVariables();
105
106        this->isHumanShip_ = this->hasLocalController();
107
108        this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition
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        }
119    }
120
121    Pawn::~Pawn()
122    {
123        if (this->isInitialized())
124        {
125            if (this->weaponSystem_)
126                this->weaponSystem_->destroy();
127        }
128    }
129
130    void Pawn::XMLPort(Element& xmlelement, XMLPort::Mode mode)
131    {
132        SUPER(Pawn, XMLPort, xmlelement, mode);
133
134        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
135        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
136        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
137
138        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
139        XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
140        XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
141        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
142
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
147        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
148        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
149        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
150
151        XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
152        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
153
154        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
155
156        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
157    }
158
159    void Pawn::registerVariables()
160    {
161        registerVariable(this->bAlive_,           VariableDirection::ToClient);
162        registerVariable(this->health_,           VariableDirection::ToClient);
163        registerVariable(this->maxHealth_,        VariableDirection::ToClient);
164        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
165        registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
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
169    }
170
171    void Pawn::tick(float dt)
172    {
173        SUPER(Pawn, tick, dt);
174
175        this->bReload_ = false;
176
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
188        if (GameMode::isMaster())
189        {
190            if (this->health_ <= 0 && bAlive_)
191            {
192                this->fireEvent(); // Event to notify anyone who wants to know about the death.
193                this->death();
194            }
195        }
196    }
197
198    void Pawn::preDestroy()
199    {
200        // yay, multiple inheritance!
201        this->ControllableEntity::preDestroy();
202        this->PickupCarrier::preDestroy();
203    }
204
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
221
222    void Pawn::setHealth(float health)
223    {
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
225    }
226
227    void Pawn::setShieldHealth(float shieldHealth)
228    {
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
252    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
253    {
254        // Applies multiplier given by the DamageBoost Pickup.
255        if (originator)
256            damage *= originator->getDamageMultiplier();
257
258        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
259        {
260            if (shielddamage >= this->getShieldHealth())
261            {
262                this->setShieldHealth(0);
263                this->setHealth(this->health_ - (healthdamage + damage));
264            }
265            else
266            {
267                this->setShieldHealth(this->shieldHealth_ - shielddamage);
268
269                // remove remaining shieldAbsorpton-Part of damage from shield
270                shielddamage = damage * this->shieldAbsorption_;
271                shielddamage = std::min(this->getShieldHealth(),shielddamage);
272                this->setShieldHealth(this->shieldHealth_ - shielddamage);
273
274                // set remaining damage to health
275                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
276            }
277
278            this->lastHitOriginator_ = originator;
279        }
280    }
281
282    void Pawn::customDamage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
283    {
284        orxout() << "damage(): Collision detected on " << this->getRadarName() << ", btCS*: " << cs << endl;
285
286        int collisionShapeIndex = this->isMyCollisionShape(cs);
287        orxout() << collisionShapeIndex << endl;
288
289        // Applies multiplier given by the DamageBoost Pickup.
290        if (originator)
291            damage *= originator->getDamageMultiplier();
292
293        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
294        {
295            if (shielddamage >= this->getShieldHealth())
296            {
297                this->setShieldHealth(0);
298                this->setHealth(this->health_ - (healthdamage + damage));
299            }
300            else
301            {
302                this->setShieldHealth(this->shieldHealth_ - shielddamage);
303
304                // remove remaining shieldAbsorpton-Part of damage from shield
305                shielddamage = damage * this->shieldAbsorption_;
306                shielddamage = std::min(this->getShieldHealth(),shielddamage);
307                this->setShieldHealth(this->shieldHealth_ - shielddamage);
308
309                // set remaining damage to health
310                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
311            }
312
313            this->lastHitOriginator_ = originator;
314        }
315    }
316
317// TODO: Still valid?
318/* HIT-Funktionen
319    Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
320
321*/
322    void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
323    {
324        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
325        {
326            this->damage(damage, healthdamage, shielddamage, originator);
327            this->setVelocity(this->getVelocity() + force);
328        }
329    }
330
331    void Pawn::customHit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
332    {
333        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
334        {
335            this->customDamage(damage, healthdamage, shielddamage, originator, cs);
336            this->setVelocity(this->getVelocity() + force);
337        }
338    }
339
340    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
341    {
342        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
343        {
344            this->damage(damage, healthdamage, shielddamage, originator);
345
346            if ( this->getController() )
347                this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
348        }
349    }
350
351    void Pawn::customHit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)
352    {
353        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
354        {
355            this->customDamage(damage, healthdamage, shielddamage, originator, cs);
356
357            if ( this->getController() )
358                this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
359        }
360    }
361
362
363    void Pawn::kill()
364    {
365        this->damage(this->health_);
366        this->death();
367    }
368
369    void Pawn::spawneffect()
370    {
371        // play spawn effect
372        if (!this->spawnparticlesource_.empty())
373        {
374            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
375            effect->setPosition(this->getPosition());
376            effect->setOrientation(this->getOrientation());
377            effect->setDestroyAfterLife(true);
378            effect->setSource(this->spawnparticlesource_);
379            effect->setLifetime(this->spawnparticleduration_);
380        }
381    }
382
383
384    void Pawn::death()
385    {
386        this->setHealth(1);
387        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
388        {
389            // Set bAlive_ to false and wait for PawnManager to do the destruction
390            this->bAlive_ = false;
391
392            this->setDestroyWhenPlayerLeft(false);
393
394            if (this->getGametype())
395                this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
396
397            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
398            {
399                // Start to control a new entity if you're the master of a formation
400                if(this->hasSlaves())
401                {
402                    Controller* slave = this->getSlave();
403                    ControllableEntity* entity = slave->getControllableEntity();
404
405
406                    if(!entity->hasHumanController())
407                    {
408                        // delete the AIController // <-- TODO: delete? nothing is deleted here... should we delete the controller?
409                        slave->setControllableEntity(0);
410
411                        // set a new master within the formation
412                        orxonox_cast<FormationController*>(this->getController())->setNewMasterWithinFormation(orxonox_cast<FormationController*>(slave));
413
414                        // start to control a slave
415                        this->getPlayer()->startControl(entity);
416                    }
417                    else
418                    {
419                        this->getPlayer()->stopControl();
420                    }
421
422                }
423                else
424                {
425                    this->getPlayer()->stopControl();
426                }
427            }
428            if (GameMode::isMaster())
429            {
430//                this->deathEffect();
431                this->goWithStyle();
432            }
433        }
434    }
435    void Pawn::goWithStyle()
436    {
437        this->bAlive_ = false;
438        this->setDestroyWhenPlayerLeft(false);
439
440        BigExplosion* chunk = new BigExplosion(this->getContext());
441        chunk->setPosition(this->getPosition());
442        chunk->setVelocity(this->getVelocity());
443
444        this->explosionSound_->setPosition(this->getPosition());
445        this->explosionSound_->play();
446    }
447    void Pawn::deatheffect()
448    {
449        // play death effect
450        {
451            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
452            effect->setPosition(this->getPosition());
453            effect->setOrientation(this->getOrientation());
454            effect->setDestroyAfterLife(true);
455            effect->setSource("Orxonox/explosion2b");
456            effect->setLifetime(4.0f);
457        }
458        {
459            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
460            effect->setPosition(this->getPosition());
461            effect->setOrientation(this->getOrientation());
462            effect->setDestroyAfterLife(true);
463            effect->setSource("Orxonox/smoke6");
464            effect->setLifetime(4.0f);
465        }
466        {
467            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
468            effect->setPosition(this->getPosition());
469            effect->setOrientation(this->getOrientation());
470            effect->setDestroyAfterLife(true);
471            effect->setSource("Orxonox/sparks");
472            effect->setLifetime(4.0f);
473        }
474        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
475        {
476            ExplosionChunk* chunk = new ExplosionChunk(this->getContext());
477            chunk->setPosition(this->getPosition());
478        }
479    }
480
481    void Pawn::fired(unsigned int firemode)
482    {
483        if (this->weaponSystem_)
484            this->weaponSystem_->fire(firemode);
485    }
486
487    void Pawn::reload()
488    {
489        this->bReload_ = true;
490    }
491
492    void Pawn::postSpawn()
493    {
494        this->setHealth(this->initialHealth_);
495        if (GameMode::isMaster())
496            this->spawneffect();
497    }
498
499    /* WeaponSystem:
500    *   functions load Slot, Set, Pack from XML and make sure all parent-pointers are set.
501    *   with setWeaponPack you can not just load a Pack from XML but if a Pack already exists anywhere, you can attach it.
502    *       --> e.g. Pickup-Items
503    */
504    void Pawn::addWeaponSlot(WeaponSlot * wSlot)
505    {
506        this->attach(wSlot);
507        if (this->weaponSystem_)
508            this->weaponSystem_->addWeaponSlot(wSlot);
509    }
510
511    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
512    {
513        if (this->weaponSystem_)
514            return this->weaponSystem_->getWeaponSlot(index);
515        else
516            return 0;
517    }
518
519    void Pawn::addWeaponSet(WeaponSet * wSet)
520    {
521        if (this->weaponSystem_)
522            this->weaponSystem_->addWeaponSet(wSet);
523    }
524
525    WeaponSet * Pawn::getWeaponSet(unsigned int index) const
526    {
527        if (this->weaponSystem_)
528            return this->weaponSystem_->getWeaponSet(index);
529        else
530            return 0;
531    }
532
533    void Pawn::addWeaponPack(WeaponPack * wPack)
534    {
535        if (this->weaponSystem_)
536        {
537            this->weaponSystem_->addWeaponPack(wPack);
538            this->addedWeaponPack(wPack);
539        }
540    }
541
542    void Pawn::addWeaponPackXML(WeaponPack * wPack)
543    {
544        if (this->weaponSystem_)
545        {
546            if (!this->weaponSystem_->addWeaponPack(wPack))
547                wPack->destroy();
548            else
549                this->addedWeaponPack(wPack);
550        }
551    }
552
553    WeaponPack * Pawn::getWeaponPack(unsigned int index) const
554    {
555        if (this->weaponSystem_)
556            return this->weaponSystem_->getWeaponPack(index);
557        else
558            return 0;
559    }
560
561    //Tell the Map (RadarViewable), if this is a playership
562    void Pawn::startLocalHumanControl()
563    {
564//        SUPER(ControllableEntity, changedPlayer());
565        ControllableEntity::startLocalHumanControl();
566        this->isHumanShip_ = true;
567    }
568
569    void Pawn::changedVisibility(void)
570    {
571        SUPER(Pawn, changedVisibility);
572
573        // enable proper radarviewability when the visibility is changed
574        this->RadarViewable::settingsChanged();
575    }
576
577
578    // A function to check if this pawn's controller is the master of any formationcontroller
579    bool Pawn::hasSlaves()
580    {
581        for (ObjectList<FormationController>::iterator it =
582             ObjectList<FormationController>::begin();
583             it != ObjectList<FormationController>::end(); ++it )
584        {
585            // checks if the pawn's controller has a slave
586            if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
587                return true;
588        }
589        return false;
590    }
591
592    // A function that returns a slave of the pawn's controller
593    Controller* Pawn::getSlave(){
594        for (ObjectList<FormationController>::iterator it =
595                ObjectList<FormationController>::begin();
596                it != ObjectList<FormationController>::end(); ++it )
597        {
598            if (this->hasHumanController() && it->getMaster() == this->getPlayer()->getController())
599                return it->getController();
600        }
601        return 0;
602    }
603
604
605    void Pawn::setExplosionSound(const std::string &explosionSound)
606    {
607        if(explosionSound_ )
608            explosionSound_->setSource(explosionSound);
609        else
610            assert(0); // This should never happen, because soundpointer is only available on master
611    }
612
613    const std::string& Pawn::getExplosionSound()
614    {
615        if( explosionSound_ )
616            return explosionSound_->getSource();
617        else
618            assert(0);
619        return BLANKSTRING;
620    }
621
622    // WIP function that (once I get it working) determines to which attached entity a collisionshape belongs.
623    // Shame that this doesn't seem to work as intended. It behaves differently (different number of childshapes) every reload. D:
624    int Pawn::isMyCollisionShape(const btCollisionShape* cs)
625    {
626        // This entities WECS
627        WorldEntityCollisionShape* ownWECS = this->getWorldEntityCollisionShape();
628
629        // e.g. "Box 4: Searching for CS 0x1ad49200"
630        orxout() << this->getRadarName() << ": Searching for btCS* " << cs << endl;
631        // e.g. "Box 4 is WorldEntityCollisionShape 0x126dd060"
632        orxout() << "  " << this->getRadarName() << " is WorldEntityCollisionShape* " << ownWECS << endl;
633        // e.g. "Box 4 is WorldEntity 0x126dd060"
634        orxout() << "  " << this->getRadarName() << " is WorldEntity* " << this << endl;
635        // e.g. "Box 4 is objectID 943"
636        orxout() << "  " << this->getRadarName() << " is objectID " << this->getObjectID() << endl;
637
638        // List all attached Objects
639        orxout() << "  " << this->getRadarName() << " has the following Objects attached:" << endl;
640        for (int i=0; i<10; i++)
641        {
642            if (this->getAttachedObject(i)==NULL)
643                break;
644            orxout() << " " << i << ": " << this->getAttachedObject(i);
645            if(!orxonox_cast<Model*>(this->getAttachedObject(i)))
646                orxout() << " (SE)";
647            orxout() << endl;
648        }
649
650        if (this->health_ < 800)
651            this->detach(this->getAttachedObject(2));
652
653        // print child shapes of this WECS
654        printBtChildShapes((btCompoundShape*)(ownWECS->getCollisionShape()), 2, 0);
655
656        int temp = entityOfCollisionShape(cs);
657        if (temp==0)
658            orxout() << this->getRadarName() << " has been hit on it's main body." << endl;
659        else
660            orxout() << this->getRadarName() << " has been hit on the attached entity no. " << temp << endl;
661
662        // end
663        return -1;
664    }
665
666    void Pawn::printBtChildShapes(btCompoundShape* cs, int indent, int subshape)
667    {
668        // e.g. "  Childshape 1 (WECS 0x126dc8c0) has 2 childshapes:"
669        printSpaces(indent);  orxout() << "Childshape " << subshape << " (btCS* " << cs << ") has " << cs->getNumChildShapes() << " childshapes:" << endl;
670
671        for (int i=0; i < cs->getNumChildShapes(); i++)
672        {
673            printSpaces(indent+2);  orxout() << "- " << i << " - - -" << endl;
674
675            // For each childshape, print: (as long as it's not another CompoundCollisionShape)
676            if (!orxonox_cast<btCompoundShape*>(cs->getChildShape(i)))
677            {
678                // pointer to the btCollisionShape
679                printSpaces(indent+2);  orxout() << "btCollisionShape*: " << cs->getChildShape(i) << endl;
680
681                // pointer to the btCollisionShape
682                printSpaces(indent+2);  orxout() << "m_userPointer*: " << cs->getChildShape(i)->getUserPointer() << endl;
683            }
684
685            // if the childshape is a CompoundCollisionShape, print its children.
686            if (cs->getChildShape(i)->isCompound())
687                printBtChildShapes((btCompoundShape*)(cs->getChildShape(i)), indent+2, i);
688
689        }
690    }
691
692    int Pawn::entityOfCollisionShape(const btCollisionShape* cs)
693    {
694        btCompoundShape* ownBtCS = (btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape());
695
696        return -1;
697    }
698
699    void Pawn::printSpaces(int num)
700    {
701        for(int i=0; i<num; i++)
702            orxout() << " ";
703    }
704}
Note: See TracBrowser for help on using the repository browser.