Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/worldentities/ControllableEntity.cc

    r5929 r6417  
    3636#include "core/GameMode.h"
    3737#include "core/XMLPort.h"
     38#include "network/NetworkFunction.h"
    3839
    3940#include "Scene.h"
     
    4748{
    4849    CreateFactory(ControllableEntity);
     50
     51    registerMemberNetworkFunction( ControllableEntity, fire );
     52    registerMemberNetworkFunction( ControllableEntity, setTargetInternal );
    4953
    5054    ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
     
    6266        this->camera_ = 0;
    6367        this->xmlcontroller_ = 0;
     68        this->controller_ = 0;
    6469        this->reverseCamera_ = 0;
    6570        this->bDestroyWhenPlayerLeft_ = false;
    6671        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     72        this->currentCameraPosition_ = 0;
    6773        this->bMouseLook_ = false;
    6874        this->mouseLookSpeed_ = 200;
     
    169175            {
    170176                this->cameraPositions_.front()->attachCamera(this->camera_);
     177                this->currentCameraPosition_ = this->cameraPositions_.front().get();
    171178            }
    172179            else if (this->cameraPositions_.size() > 0)
     
    178185                        ++it;
    179186                        if (it != this->cameraPositions_.end())
     187                        {
    180188                            (*it)->attachCamera(this->camera_);
     189                            this->currentCameraPosition_ = *it;
     190                        }
    181191                        else
     192                        {
    182193                            (*this->cameraPositions_.begin())->attachCamera(this->camera_);
     194                            this->currentCameraPosition_ = *this->cameraPositions_.begin();
     195                        }
    183196                        break;
    184197                    }
     
    188201            {
    189202                this->camera_->attachToNode(this->cameraPositionRootNode_);
     203                this->currentCameraPosition_ = 0;
    190204            }
    191205        }
     
    198212        if (!this->bMouseLook_)
    199213            this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
     214        if (this->getCamera())
     215        {
     216            if (!this->bMouseLook_&& this->currentCameraPosition_->getDrag())
     217                this->getCamera()->setDrag(true);
     218            else
     219                this->getCamera()->setDrag(false);
     220        }
    200221    }
    201222
     
    216237        if (this->bMouseLook_)
    217238            this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     239    }
     240
     241    void ControllableEntity::fire(unsigned int firemode)
     242    {
     243        if(GameMode::isMaster())
     244        {
     245            this->fired(firemode);
     246        }
     247        else
     248        {
     249            callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
     250        }
     251    }
     252
     253    void ControllableEntity::setTarget( WorldEntity* target )
     254    {
     255        this->target_ = target;
     256        if ( !GameMode::isMaster() )
     257        {
     258            if ( target != 0 )
     259            {
     260                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
     261            }
     262           else
     263           {
     264                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
     265           }
     266        }
     267    }
     268
     269    void ControllableEntity::setTargetInternal( uint32_t targetID )
     270    {
     271        this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) );
    218272    }
    219273
     
    279333            this->camera_ = new Camera(this);
    280334            this->camera_->requestFocus();
    281             if (this->cameraPositionTemplate_ != "")
     335            if (!this->cameraPositionTemplate_.empty())
    282336                this->addTemplate(this->cameraPositionTemplate_);
    283337            if (this->cameraPositions_.size() > 0)
     338            {
    284339                this->cameraPositions_.front()->attachCamera(this->camera_);
     340                this->currentCameraPosition_ = this->cameraPositions_.front();
     341            }
    285342            else
     343            {
    286344                this->camera_->attachToNode(this->cameraPositionRootNode_);
     345                this->currentCameraPosition_ = 0;
     346            }
    287347        }
    288348
    289349        if (!this->hud_ && GameMode::showsGraphics())
    290350        {
    291             if (this->hudtemplate_ != "")
     351            if (!this->hudtemplate_.empty())
    292352            {
    293353                this->hud_ = new OverlayGroup(this);
Note: See TracChangeset for help on using the changeset viewer.