Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Tried (and failed) to fix output of CollisionShape-structure

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