Changeset 8079 for code/trunk/src/modules/designtools
- Timestamp:
- Mar 15, 2011, 9:47:11 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/designtools/ScreenshotManager.cc
r7284 r8079 25 25 { 26 26 Ogre::RenderWindow* pRenderWindow = GraphicsManager::getInstance().getRenderWindow(); 27 int gridSize = 3;28 std::string fileExtension = ".png";29 bool overlayFlag = true;30 27 31 28 //set file extension for the Screenshot files 32 mFileExtension = fileExtension;29 this->mFileExtension_ = ".png"; 33 30 // the gridsize 34 mGridSize = gridSize;31 this->mGridSize_ = 3; 35 32 // flag for overlay rendering 36 mDisableOverlays = overlayFlag;33 this->mDisableOverlays_ = true; 37 34 //get current window size 38 mWindowWidth= pRenderWindow->getWidth();39 mWindowHeight= pRenderWindow->getHeight();35 this->mWindowWidth_ = pRenderWindow->getWidth(); 36 this->mWindowHeight_ = pRenderWindow->getHeight(); 40 37 //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); 44 39 45 40 //get The current Render Target of the temp Texture 46 mRT = mTempTex->getBuffer()->getRenderTarget();41 this->mRT_ = this->mTempTex_->getBuffer()->getRenderTarget(); 47 42 48 43 //HardwarePixelBufferSharedPtr to the Buffer of the temp Texture 49 mBuffer = mTempTex->getBuffer();44 this->mBuffer_ = this->mTempTex_->getBuffer(); 50 45 51 46 //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_); 54 49 55 50 } … … 63 58 64 59 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. 60 /** 61 @brief 62 Creates a screenshot with the given camera. 63 @param camera 64 Pointer to the camera "looking at" the scene of interest 65 @param fileName 66 the filename of the screenshot file. 68 67 */ 69 68 void ScreenshotManager::makeScreenshot() const … … 73 72 74 73 //Remove all viewports, so the added Viewport(camera) ist the only 75 mRT ->removeAllViewports();76 mRT ->addViewport(camera);74 mRT_->removeAllViewports(); 75 mRT_->addViewport(camera); 77 76 78 77 //set the viewport settings 79 Ogre::Viewport *vp = mRT ->getViewport(0);78 Ogre::Viewport *vp = mRT_->getViewport(0); 80 79 vp->setClearEveryFrame(true); 81 80 vp->setOverlaysEnabled(false); … … 85 84 86 85 // we disable overlay rendering if it is set in config file and the viewport setting is enabled 87 if(mDisableOverlays && enableOverlayFlag)86 if(mDisableOverlays_ && enableOverlayFlag) 88 87 GraphicsManager::getInstance().getViewport()->setOverlaysEnabled(false); 89 88 90 if(mGridSize <= 1)89 if(mGridSize_ <= 1) 91 90 { 92 91 // Simple case where the contents of the screen are taken directly 93 92 // Also used when an invalid value is passed within gridSize (zero or negative grid size) 94 mRT ->update(); //render93 mRT_->update(); //render 95 94 96 95 //write the file on the Harddisk 97 mRT ->writeContentsToFile(fileName + "." + mFileExtension);96 mRT_->writeContentsToFile(fileName + "." + mFileExtension_); 98 97 } 99 98 else … … 105 104 106 105 // compute the Stepsize for the drid 107 Ogre::Real frustumGridStepHorizontal = (originalFrustumRight * 2) / mGridSize ;108 Ogre::Real frustumGridStepVertical = (originalFrustumTop * 2) / mGridSize ;106 Ogre::Real frustumGridStepHorizontal = (originalFrustumRight * 2) / mGridSize_; 107 Ogre::Real frustumGridStepVertical = (originalFrustumTop * 2) / mGridSize_; 109 108 110 109 // process each grid 111 110 Ogre::Real frustumLeft, frustumRight, frustumTop, frustumBottom; 112 for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize * mGridSize; nbScreenshots++)111 for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize_ * mGridSize_; nbScreenshots++) 113 112 { 114 int y = nbScreenshots / mGridSize ;115 int x = nbScreenshots - y * mGridSize ;113 int y = nbScreenshots / mGridSize_; 114 int x = nbScreenshots - y * mGridSize_; 116 115 117 116 // Shoggoth frustum extents setting … … 127 126 // ignore time duration between frames 128 127 Ogre::Root::getSingletonPtr()->clearEventTimes(); 129 mRT ->update(); //render128 mRT_->update(); //render 130 129 131 130 //define the current 132 Ogre::Box subBox = Ogre::Box(x* mWindowWidth ,y * mWindowHeight,x * mWindowWidth + mWindowWidth, y * mWindowHeight + mWindowHeight);131 Ogre::Box subBox = Ogre::Box(x* mWindowWidth_,y * mWindowHeight_,x * mWindowWidth_ + mWindowWidth_, y * mWindowHeight_ + mWindowHeight_); 133 132 //copy the content from the temp buffer into the final picture PixelBox 134 133 //Place the tempBuffer content at the right position 135 mBuffer ->blitToMemory(mFinalPicturePB.getSubVolume(subBox));134 mBuffer_->blitToMemory(mFinalPicturePB_.getSubVolume(subBox)); 136 135 137 136 } … … 142 141 Ogre::Image finalImage; //declare the final Image Object 143 142 //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);143 finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB_.data), mFinalPicturePB_.getWidth(), mFinalPicturePB_.getHeight(),Ogre::PF_B8G8R8); 145 144 // Save the Final image to a file 146 finalImage.save(fileName + "." + mFileExtension );145 finalImage.save(fileName + "." + mFileExtension_); 147 146 148 147 } … … 157 156 } 158 157 158 /** 159 @brief 160 Set the size of the grid. 161 @param size 162 The size of the grid. 163 */ 164 void ScreenshotManager::setGridSize(unsigned int size) 165 { 166 if(size == this->mGridSize_) 167 return; 168 169 this->mGridSize_ = size; 170 // New PixelBox for the changed size. 171 uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3]; 172 this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_); 173 } 174 175 /** 176 @brief 177 Get a timestamp for the curent time instant. 178 @return 179 Returns a string with the timestamp. 180 */ 159 181 std::string ScreenshotManager::getTimestamp() 160 182 { -
code/trunk/src/modules/designtools/ScreenshotManager.h
r7163 r8079 20 20 { 21 21 22 23 /* Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. 24 * pRenderWindow: Pointer to the render window. This could be "mWindow" from the ExampleApplication, 25 * the window automatically created obtained when calling 26 * Ogre::Root::getSingletonPtr()->initialise(false) and retrieved by calling 27 * "Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()", or the manually created 28 * window from calling "mRoot->createRenderWindow()". 29 * gridSize: The magnification factor. A 2 will create a 2x2 grid, doubling the size of the 30 screenshot. A 3 will create a 3x3 grid, tripling the size of the screenshot. 31 * fileExtension: The extension of the screenshot file name, hence the type of graphics file to generate. 32 * To generate "MyScreenshot.png" this parameter would contain ".png". 22 /** 23 @brief 24 Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots. 33 25 */ 34 26 class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager> … … 36 28 friend class Singleton<ScreenshotManager>; 37 29 38 public:39 ScreenshotManager();40 ~ScreenshotManager();30 public: 31 ScreenshotManager(); 32 virtual ~ScreenshotManager(); 41 33 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 */ 46 void makeScreenshot() const; 34 void makeScreenshot() const; //!< Creates a screenshot with the given camera. 47 35 48 static void makeScreenshot_s() 49 { getInstance().makeScreenshot(); } 36 /** 37 @brief Creates a screenshot with a given size. 38 @param size Size is factor by which the current screen size is scaled. 39 */ 40 static void makeScreenshot_s(unsigned int size) 41 { getInstance().setGridSize(size); getInstance().makeScreenshot(); } 50 42 51 protected: 52 static std::string getTimestamp(); 43 void setGridSize(unsigned int size); //!< Set the size of the grid. 53 44 54 std::string mFileExtension; 55 unsigned int mGridSize, mWindowWidth, mWindowHeight; 56 bool mDisableOverlays; 57 //temp texture with current screensize 58 Ogre::TexturePtr mTempTex; 59 Ogre::RenderTexture* mRT; 60 Ogre::HardwarePixelBufferSharedPtr mBuffer; 61 //PixelBox for a large Screenshot, if grid size is > 1 62 Ogre::PixelBox mFinalPicturePB; 63 uint8_t* data_; 45 protected: 46 static std::string getTimestamp(); 64 47 65 static ScreenshotManager* singletonPtr_s; 48 std::string mFileExtension_; 49 unsigned int mGridSize_; //!< The magnification factor. A 2 will create a 2x2 grid, doubling the size of the screenshot. A 3 will create a 3x3 grid, tripling the size of the screenshot. 50 unsigned int mWindowWidth_, mWindowHeight_; 51 bool mDisableOverlays_; 52 //! temp texture with current screensize 53 Ogre::TexturePtr mTempTex_; 54 Ogre::RenderTexture* mRT_; 55 Ogre::HardwarePixelBufferSharedPtr mBuffer_; 56 //! PixelBox for a large Screenshot, if grid size is > 1 57 Ogre::PixelBox mFinalPicturePB_; 58 uint8_t* data_; 59 60 static ScreenshotManager* singletonPtr_s; 66 61 }; 67 62 -
code/trunk/src/modules/designtools/SkyboxGenerator.cc
r7284 r8079 59 59 60 60 this->setConfigValues(); 61 t akeScreenshot_ = false;61 this->takeScreenshot_ = false; 62 62 this->captionsRemoved_ = false; 63 63 }
Note: See TracChangeset
for help on using the changeset viewer.