Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 30, 2011, 9:55:38 AM (13 years ago)
Author:
dafrick
Message:

Make the camera position stay the same between differnet stones in Tetris.

Location:
code/branches/presentation/src/orxonox/worldentities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/worldentities/ControllableEntity.cc

    r8580 r8680  
    120120
    121121        XMLPortParam(ControllableEntity, "hudtemplate", setHudTemplate, getHudTemplate, xmlelement, mode);
    122         XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemkplate, xmlelement, mode);
     122        XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemplate, xmlelement, mode);
    123123
    124124        XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);
     
    170170        }
    171171        return 0;
     172    }
     173
     174    unsigned int ControllableEntity::getCurrentCameraIndex() const
     175    {
     176        if (this->cameraPositions_.size() <= 0)
     177            return 0;
     178
     179        unsigned int counter = 0;
     180        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     181        {
     182            if ((*it) == this->currentCameraPosition_)
     183                break;
     184            counter++;
     185        }
     186        if (counter >= this->cameraPositions_.size())
     187            return 0;
     188
     189        return counter;
     190    }
     191   
     192    bool ControllableEntity::setCameraPosition(unsigned int index)
     193    {
     194        if(this->camera_ != NULL && this->cameraPositions_.size() > 0)
     195        {
     196            if(index >= this->cameraPositions_.size())
     197                index = 0;
     198
     199            CameraPosition* position = this->getCameraPosition(index);
     200            position->attachCamera(this->camera_);
     201            this->currentCameraPosition_ = position;
     202            return true;
     203        }
     204
     205        return false;
    172206    }
    173207
  • code/branches/presentation/src/orxonox/worldentities/ControllableEntity.h

    r8580 r8680  
    116116            inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const
    117117                { return this->cameraPositions_; }
     118            unsigned int getCurrentCameraIndex() const;
     119            bool setCameraPosition(unsigned int index);
    118120
    119121            inline void setCameraPositionTemplate(const std::string& name)
    120122                { this->cameraPositionTemplate_ = name; }
    121             inline const std::string& getCameraPositionTemkplate() const
     123            inline const std::string& getCameraPositionTemplate() const
    122124                { return this->cameraPositionTemplate_; }
    123125
Note: See TracChangeset for help on using the changeset viewer.