Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 14, 2011, 5:36:36 PM (14 years ago)
Author:
dafrick
Message:

Adding screenshot to KeybindMenu and making "size" of screenhsot generated by printScreenshotHD adjustable.

Location:
code/branches/usability
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/usability/data/gui/scripts/KeyBindMenu.lua

    r8032 r8076  
    3535    table.insert(commandList, "mouseLook")
    3636    table.insert(commandList, "pause")
     37    table.insert(commandList, "printScreen")
     38    if orxonox.GUIManager:inDevMode() then
     39        table.insert(commandList, "printScreenHD 3")
     40    end
    3741
    3842    nameList = {}
     
    6569    table.insert(nameList, "Look Around")
    6670    table.insert(nameList, "Pause")
     71    table.insert(nameList, "Screenshot")
     72    if orxonox.GUIManager:inDevMode() then
     73        table.insert(nameList, "HD screenshot")
     74    end
    6775
    6876    linesList = {}
  • code/branches/usability/src/modules/designtools/ScreenshotManager.cc

    r7284 r8076  
    2525    {
    2626        Ogre::RenderWindow* pRenderWindow = GraphicsManager::getInstance().getRenderWindow();
    27         int gridSize = 3;
    28         std::string fileExtension = ".png";
    29         bool overlayFlag = true;
    3027
    3128        //set file extension for the Screenshot files
    32         mFileExtension   = fileExtension;
     29        this->mFileExtension_  = ".png";
    3330        // the gridsize
    34         mGridSize        = gridSize;
     31        this->mGridSize_ = 3;
    3532        // flag for overlay rendering
    36         mDisableOverlays = overlayFlag;
     33        this->mDisableOverlays_ = true;
    3734        //get current window size
    38         mWindowWidth   = pRenderWindow->getWidth();
    39         mWindowHeight  = pRenderWindow->getHeight();
     35        this->mWindowWidth_   = pRenderWindow->getWidth();
     36        this->mWindowHeight_  = pRenderWindow->getHeight();
    4037        //create temporary texture
    41         mTempTex = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex",
    42                                                                   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
    43                                                                     mWindowWidth, mWindowHeight,0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET);
     38        this->mTempTex_ = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, this->mWindowWidth_, this->mWindowHeight_, 0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET);
    4439
    4540        //get The current Render Target of the temp Texture
    46         mRT = mTempTex->getBuffer()->getRenderTarget();
     41        this->mRT_ = this->mTempTex_->getBuffer()->getRenderTarget();
    4742
    4843        //HardwarePixelBufferSharedPtr to the Buffer of the temp Texture
    49         mBuffer = mTempTex->getBuffer();
     44        this->mBuffer_ = this->mTempTex_->getBuffer();
    5045
    5146        //create PixelBox
    52             uint8_t* data_ = new uint8_t[(mWindowWidth * mGridSize) * (mWindowHeight * mGridSize) * 3];
    53         mFinalPicturePB = Ogre::PixelBox(mWindowWidth * mGridSize,mWindowHeight * mGridSize,1,Ogre::PF_B8G8R8,data_);
     47        uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3];
     48        this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_);
    5449
    5550    }
     
    6358
    6459
    65     /* Creates a screenshot with the given camera.
    66     * @param camera Pointer to the camera "looking at" the scene of interest
    67     * @param fileName the filename of the screenshot file.
    68     */
     60    /**
     61     * @brief Creates a screenshot with the given camera.
     62     * @param camera Pointer to the camera "looking at" the scene of interest
     63     * @param fileName the filename of the screenshot file.
     64     */
    6965    void ScreenshotManager::makeScreenshot() const
    7066    {
     
    7369
    7470        //Remove all viewports, so the added Viewport(camera) ist the only
    75         mRT->removeAllViewports();
    76         mRT->addViewport(camera);
     71        mRT_->removeAllViewports();
     72        mRT_->addViewport(camera);
    7773
    7874        //set the viewport settings
    79         Ogre::Viewport *vp = mRT->getViewport(0);
     75        Ogre::Viewport *vp = mRT_->getViewport(0);
    8076        vp->setClearEveryFrame(true);
    8177        vp->setOverlaysEnabled(false);
     
    8581
    8682        // we disable overlay rendering if it is set in config file and the viewport setting is enabled
    87         if(mDisableOverlays && enableOverlayFlag)
     83        if(mDisableOverlays_ && enableOverlayFlag)
    8884            GraphicsManager::getInstance().getViewport()->setOverlaysEnabled(false);
    8985
    90         if(mGridSize <= 1)
     86        if(mGridSize_ <= 1)
    9187        {
    9288            // Simple case where the contents of the screen are taken directly
    9389            // Also used when an invalid value is passed within gridSize (zero or negative grid size)
    94             mRT->update();    //render
     90            mRT_->update();    //render
    9591
    9692            //write the file on the Harddisk
    97             mRT->writeContentsToFile(fileName + "." + mFileExtension);
     93            mRT_->writeContentsToFile(fileName + "." + mFileExtension_);
    9894        }
    9995        else
     
    105101
    106102            // compute the Stepsize for the drid
    107             Ogre::Real frustumGridStepHorizontal  = (originalFrustumRight * 2) / mGridSize;
    108             Ogre::Real frustumGridStepVertical  = (originalFrustumTop * 2) / mGridSize;
     103            Ogre::Real frustumGridStepHorizontal  = (originalFrustumRight * 2) / mGridSize_;
     104            Ogre::Real frustumGridStepVertical  = (originalFrustumTop * 2) / mGridSize_;
    109105
    110106            // process each grid
    111107            Ogre::Real frustumLeft, frustumRight, frustumTop, frustumBottom;
    112             for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize * mGridSize; nbScreenshots++)
     108            for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize_ * mGridSize_; nbScreenshots++)
    113109            {
    114                 int y = nbScreenshots / mGridSize;
    115                 int x = nbScreenshots - y * mGridSize;
     110                int y = nbScreenshots / mGridSize_;
     111                int x = nbScreenshots - y * mGridSize_;
    116112
    117113                // Shoggoth frustum extents setting
     
    127123                // ignore time duration between frames
    128124                Ogre::Root::getSingletonPtr()->clearEventTimes();
    129                 mRT->update();    //render
     125                mRT_->update();    //render
    130126
    131127                //define the current
    132                 Ogre::Box subBox = Ogre::Box(x* mWindowWidth,y * mWindowHeight,x * mWindowWidth + mWindowWidth, y * mWindowHeight + mWindowHeight);
     128                Ogre::Box subBox = Ogre::Box(x* mWindowWidth_,y * mWindowHeight_,x * mWindowWidth_ + mWindowWidth_, y * mWindowHeight_ + mWindowHeight_);
    133129                //copy the content from the temp buffer into the final picture PixelBox
    134130                //Place the tempBuffer content at the right position
    135                 mBuffer->blitToMemory(mFinalPicturePB.getSubVolume(subBox));
     131                mBuffer_->blitToMemory(mFinalPicturePB_.getSubVolume(subBox));
    136132
    137133            }
     
    142138            Ogre::Image finalImage; //declare the final Image Object
    143139            //insert the PixelBox data into the Image Object
    144             finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB.data), mFinalPicturePB.getWidth(),mFinalPicturePB.getHeight(),Ogre::PF_B8G8R8);
     140            finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB_.data), mFinalPicturePB_.getWidth(), mFinalPicturePB_.getHeight(),Ogre::PF_B8G8R8);
    145141            // Save the Final image to a file
    146             finalImage.save(fileName + "." + mFileExtension);
     142            finalImage.save(fileName + "." + mFileExtension_);
    147143
    148144        }
  • code/branches/usability/src/modules/designtools/ScreenshotManager.h

    r7163 r8076  
    4040        ~ScreenshotManager();
    4141
    42       /* Creates a screenshot with the given camera.
    43         * @param camera Pointer to the camera "looking at" the scene of interest
    44         * @param fileName the filename of the screenshot file.
    45       */
     42        /**
     43         * @briefCreates a screenshot with the given camera.
     44         * @param camera Pointer to the camera "looking at" the scene of interest
     45         * @param fileName the filename of the screenshot file.
     46         */
    4647        void makeScreenshot() const;
    4748
    48         static void makeScreenshot_s()
    49             { getInstance().makeScreenshot(); }
     49        //static void makeScreenshot_s()
     50        //    { getInstance().makeScreenshot(); }
     51        static void makeScreenshot_s(unsigned int size)
     52            { getInstance().setGridSize(size); getInstance().makeScreenshot(); }
     53
     54        void setGridSize(unsigned int size)
     55        {
     56            this->mGridSize_ = size;
     57            uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3];
     58            this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_);
     59        }
    5060
    5161    protected:
    5262        static std::string getTimestamp();
    5363
    54         std::string    mFileExtension;
    55         unsigned int   mGridSize, mWindowWidth, mWindowHeight;
    56         bool           mDisableOverlays;
     64        std::string    mFileExtension_;
     65        unsigned int   mGridSize_, mWindowWidth_, mWindowHeight_;
     66        bool           mDisableOverlays_;
    5767        //temp texture with current screensize
    58         Ogre::TexturePtr mTempTex;
    59         Ogre::RenderTexture* mRT;
    60         Ogre::HardwarePixelBufferSharedPtr mBuffer;
     68        Ogre::TexturePtr mTempTex_;
     69        Ogre::RenderTexture* mRT_;
     70        Ogre::HardwarePixelBufferSharedPtr mBuffer_;
    6171        //PixelBox for a large Screenshot, if grid size is > 1
    62         Ogre::PixelBox  mFinalPicturePB;
     72        Ogre::PixelBox  mFinalPicturePB_;
    6373        uint8_t* data_;
    6474
Note: See TracChangeset for help on using the changeset viewer.