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-2014 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     /** \addtogroup Optional
37     *  @{
38     */
39     /** \addtogroup Volume
40     *  @{
41     */
42     /** A volume source from a 16 Bit float 3D grid capable of loading volume
43     serializations.
44     */
45     class _OgreVolumeExport HalfFloatGridSource : public GridSource
46     {
47     protected:
48 
49         /// The raw volume data.
50         uint16 *mData;
51 
52         /// To have a little bit faster data access.
53         int mDepthTimesHeight;
54 
55         /// The maximum absolute density value to be written into the data when combining,
56         /// influencing the compression rate on serialization.
57         Real mMaxClampedAbsoluteDensity;
58 
59         /** Overridden from GridSource.
60         */
61         virtual float getVolumeGridValue(size_t x, size_t y, size_t z) const;
62 
63         /** Overridden from GridSource.
64         */
65         virtual void setVolumeGridValue(int x, int y, int z, float value);
66 
67     public:
68 
69         /** Constructur.
70         @param serializedVolumeFile
71             Which volume serialization to get the data from.
72         @param trilinearValue
73             Whether to use trilinear filtering (true) or nearest neighbour (false) for the value.
74         @param trilinearGradient
75             Whether to use trilinear filtering (true) or nearest neighbour (false) for the gradient.
76         @param sobelGradient
77             Whether to add a bit of blur to the gradient like in a sobel filter.
78         */
79         explicit HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue = true, const bool trilinearGradient = false, const bool sobelGradient = false);
80 
81         /** Sets the maximum absolute density value to be written into the data when combining,
82         influencing the compression rate on serialization. Set it to 0.0 to deactivate.
83         @param maxClampedAbsoluteDensity
84             The maximum absolute density value.
85         */
86         void setMaxClampedAbsoluteDensity(Real maxClampedAbsoluteDensity);
87 
88         /** Gets the maximum absolute density value to be written into the data when combining,
89         influencing the compression rate on serialization.
90         @return
91             The maximum absolute density value, 0.0 when deactivated.
92         */
93         Real getMaxClampedAbsoluteDensity(void) const;
94 
95         /** Destructor.
96         */
97         ~HalfFloatGridSource(void);
98 
99     };
100     /** @} */
101     /** @} */
102 }
103 }
104 
105 #endif
106