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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.