Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6167


Ignore:
Timestamp:
Nov 26, 2009, 7:41:49 PM (15 years ago)
Author:
landauf
Message:
  • you don't have to set the syncMode of the CameraPosition to 0x0, this is already done in it's constructor
  • you also don't have to attach or destroy the CameraPosition once it was added to a CE (it's automatically done)
  • the same also holds for attached WorldEntities (like the model) - they get destroyed automatically unless they call setDeleteWithParent(false)
  • … and also for collision shapes
  • you probably don't want a ParticleSpawner for the fire trail. ParticleEmitter is more suitable (for continuous particle effects)

</teaching>

Location:
code/branches/presentation2/src/modules/weapons/projectiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/weapons/projectiles/Rocket.cc

    r6120 r6167  
    6161            this->bDestroy_ = false;
    6262       
    63             this->model_ = new Model(this);
    64             this->model_->setMeshSource("rocket.mesh");
    65             this->attach(this->model_);
    66             ParticleSpawner* fire = new ParticleSpawner(this);
     63            Model* model = new Model(this);
     64            model->setMeshSource("rocket.mesh");
     65            this->attach(model);
     66            ParticleEmitter* fire = new ParticleEmitter(this);
    6767            this->attach(fire);
    6868            fire->setOrientation(this->getOrientation());
     
    7373            this->setCollisionType(Kinematic);
    7474
    75             this->collisionShape_ = new ConeCollisionShape(this);
    76             this->collisionShape_->setRadius(3);
    77             this->collisionShape_->setHeight(500);
    78             this->attachCollisionShape(this->collisionShape_);
     75            ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
     76            collisionShape->setRadius(3);
     77            collisionShape->setHeight(500);
     78            this->attachCollisionShape(collisionShape);
    7979
    8080            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&Rocket::destroyObject, this)));
    8181        }
    8282       
    83         this->camPosition_ = new CameraPosition(this);
    84         this->camPosition_->setPosition(0,10,40);
    85         this->camPosition_->setSyncMode(0x0);
    86         this->camPosition_->setAllowMouseLook(true);
    87         this->attach( this->camPosition_ );
    88         this->addCameraPosition( this->camPosition_ );
     83        CameraPosition* camPosition = new CameraPosition(this);
     84        camPosition->setPosition(0,10,40);
     85        camPosition->setAllowMouseLook(true);
     86        this->addCameraPosition(camPosition);
    8987    }
    9088
     
    9795        if(this->isInitialized())
    9896        {
    99             if (GameMode::isMaster() && this->player_.get())
    100             {
    101                 this->model_->destroy();
    102                 this->collisionShape_->destroy();
     97            if (GameMode::isMaster() && this->player_)
    10398                this->player_->stopTemporaryControl();
    104             }
    105             this->camPosition_->destroy();
    10699        }
    107100    }
  • code/branches/presentation2/src/modules/weapons/projectiles/Rocket.h

    r6119 r6167  
    119119            ControllableEntity* originalControllableEntity_;
    120120           
    121             Model* model_;
    122             CameraPosition* camPosition_;
    123             ConeCollisionShape* collisionShape_;
    124121            WeakPtr<PlayerInfo> player_;
    125122            Timer destroyTimer_;
Note: See TracChangeset for help on using the changeset viewer.