1 /* 2 ----------------------------------------------------------------------------- 3 This source file is part of OGRE 4 (Object-oriented Graphics Rendering Engine) 5 For the latest info, see http://www.ogre3d.org/ 6 7 Copyright (c) 2000-2013 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef __Ogre_Volume_HalfFloatGridSource_H__ 29 #define __Ogre_Volume_HalfFloatGridSource_H__ 30 31 32 #include "OgreVolumeGridSource.h" 33 34 namespace Ogre { 35 namespace Volume { 36 37 /** A volume source from a 16 Bit float 3D grid capable of loading volume 38 serializations. 39 */ 40 class _OgreVolumeExport HalfFloatGridSource : public GridSource 41 { 42 protected: 43 44 /// The raw volume data. 45 uint16 *mData; 46 47 /// To have a little bit faster data access. 48 int mDepthTimesHeight; 49 50 /// The maximum absolute density value to be written into the data when combining, 51 /// influencing the compression rate on serialization. 52 Real mMaxClampedAbsoluteDensity; 53 54 /** Overridden from GridSource. 55 */ 56 virtual float getVolumeGridValue(size_t x, size_t y, size_t z) const; 57 58 /** Overridden from GridSource. 59 */ 60 virtual void setVolumeGridValue(int x, int y, int z, float value); 61 62 public: 63 64 /** Constructur. 65 @param serializedVolumeFile 66 Which volume serialization to get the data from. 67 @param trilinearValue 68 Whether to use trilinear filtering (true) or nearest neighbour (false) for the value. 69 @param trilinearGradient 70 Whether to use trilinear filtering (true) or nearest neighbour (false) for the gradient. 71 @param sobelGradient 72 Whether to add a bit of blur to the gradient like in a sobel filter. 73 */ 74 explicit HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue = true, const bool trilinearGradient = false, const bool sobelGradient = false); 75 76 /** Sets the maximum absolute density value to be written into the data when combining, 77 influencing the compression rate on serialization. Set it to 0.0 to deactivate. 78 @param maxClampedAbsoluteDensity 79 The maximum absolute density value. 80 */ 81 void setMaxClampedAbsoluteDensity(Real maxClampedAbsoluteDensity); 82 83 /** Gets the maximum absolute density value to be written into the data when combining, 84 influencing the compression rate on serialization. 85 @return 86 The maximum absolute density value, 0.0 when deactivated. 87 */ 88 Real getMaxClampedAbsoluteDensity(void) const; 89 90 /** Destructor. 91 */ 92 ~HalfFloatGridSource(void); 93 94 }; 95 96 } 97 } 98 99 #endif