/usr/include/OGRE/Volume/OgreVolumeGridSource.h is in libogre-1.9-dev 1.9.0+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __Ogre_Volume_GridSource_H__
#define __Ogre_Volume_GridSource_H__
#include "OgreVector4.h"
#include "OgreVolumePrerequisites.h"
#include "OgreVolumeSource.h"
#include "OgreVolumeCSGSource.h"
namespace Ogre {
namespace Volume {
/** A volume source from a discrete 3d grid.
*/
class _OgreVolumeExport GridSource : public Source
{
protected:
/// The texture width.
size_t mWidth;
/// The texture height.
size_t mHeight;
/// The texture depth.
size_t mDepth;
/// The scale of the position based on the world width.
Real mPosXScale;
/// The scale of the position based on the world height.
Real mPosYScale;
/// The scale of the position based on the world depth.
Real mPosZScale;
/// Whether to use trilinear filtering or not for the value.
bool mTrilinearValue;
/// Whether to use trilinear filtering or not for the gradient.
const bool mTrilinearGradient;
/// Whether to blur the gradient a bit Sobel like.
const bool mSobelGradient;
/// Factor to come from volume coordinate to world coordinate.
Real mVolumeSpaceToWorldSpaceFactor;
/** Overridden from VolumeSource.
*/
virtual Vector3 getIntersectionStart(const Ray &ray, Real maxDistance) const;
/** Overridden from VolumeSource.
*/
virtual Vector3 getIntersectionEnd(const Ray &ray, Real maxDistance) const;
/** Gets the volume value of a position.
@param x
The x position.
@param y
The y position.
@param z
The z position.
@return
The density.
*/
virtual float getVolumeGridValue(size_t x, size_t y, size_t z) const = 0;
/** Sets the volume value of a position.
@param x
The x position.
@param y
The y position.
@param z
The z position.
@param value
The density to be set.
*/
virtual void setVolumeGridValue(int x, int y, int z, float value) = 0;
/** Gets a gradient of a point with optional sobel blurring.
@param x
The x coordinate of the point.
@param y
The x coordinate of the point.
@param z
The x coordinate of the point.
*/
inline const Vector3 getGradient(size_t x, size_t y, size_t z) const
{
if (mSobelGradient)
{
// Calculate gradient like in the original MC paper but mix a bit of Sobel in
return Vector3(
(getVolumeGridValue(x + 1, y - 1, z) - getVolumeGridValue(x - 1, y - 1, z))
+ (Real)2.0 * (getVolumeGridValue(x + 1, y, z) - getVolumeGridValue(x - 1, y, z))
+ (getVolumeGridValue(x + 1, y + 1, z) - getVolumeGridValue(x - 1, y + 1, z)),
(getVolumeGridValue(x, y + 1, z - 1) - getVolumeGridValue(x, y - 1, z - 1))
+ (Real)2.0 * (getVolumeGridValue(x, y + 1, z) - getVolumeGridValue(x, y - 1, z))
+ (getVolumeGridValue(x, y + 1, z + 1) - getVolumeGridValue(x, y - 1, z + 1)),
(getVolumeGridValue(x - 1, y, z + 1) - getVolumeGridValue(x - 1, y, z - 1))
+ (Real)2.0 * (getVolumeGridValue(x, y, z + 1) - getVolumeGridValue(x, y, z - 1))
+ (getVolumeGridValue(x + 1, y, z + 1) - getVolumeGridValue(x + 1, y, z - 1))) / (Real)4.0;
}
// Calculate gradient like in the original MC paper
return Vector3(
getVolumeGridValue(x + 1, y, z) - getVolumeGridValue(x - 1, y, z),
getVolumeGridValue(x, y + 1, z) - getVolumeGridValue(x, y - 1, z),
getVolumeGridValue(x, y, z + 1) - getVolumeGridValue(x, y, z - 1));
}
public:
GridSource(bool trilinearValue, bool trilinearGradient, bool sobelGradient);
/** Destructor.
*/
virtual ~GridSource(void);
/** Overridden from VolumeSource.
*/
virtual Vector4 getValueAndGradient(const Vector3 &position) const;
/** Overridden from VolumeSource.
*/
virtual Real getValue(const Vector3 &position) const;
/** Gets the width of the texture.
@return
The width of the texture.
*/
size_t getWidth(void) const;
/** Gets the height of the texture.
@return
The height of the texture.
*/
size_t getHeight(void) const;
/** Gets the depth of the texture.
@return
The depth of the texture.
*/
size_t getDepth(void) const;
/** Updates this grid with another source in a certain area. Use
it for example to add spheres as a brush.
@param operation
The operation to use, will use this source and the other given one as operands. Beware that
this function overrides the maybe existing sources in the operation.
@param source
The other source to combine this one with.
@param center
The rough center of the affected area by the operation. If the other source is a sphere, take
its center for example.
@param radius
The radius of the affected area. For the example sphere, you might use its radius times two
because the density outside of the sphere is needed, too.
*/
virtual void combineWithSource(CSGOperationSource *operation, Source *source, const Vector3 ¢er, Real radius);
/** Overridden from VolumeSource.
*/
Real getVolumeSpaceToWorldSpaceFactor(void) const;
};
}
}
#endif
|