/usr/include/OGRE/Volume/OgreVolumeSource.h is in libogre-1.9-dev 1.9.0+dfsg1-7.
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 | /*
-----------------------------------------------------------------------------
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_Source_H__
#define __Ogre_Volume_Source_H__
#include <float.h>
#include "OgreVector3.h"
#include "OgreVolumePrerequisites.h"
#include "OgreRay.h"
namespace Ogre {
namespace Volume {
/** Abstract class defining the density function.
*/
class _OgreVolumeExport Source
{
protected:
/** Gets the start vector of an intersection. This is needed for restricted volumes
like discreet grids.
@param ray
The ray of the intersection.
@param maxDistance
The maximum distance to query the ray for intersections.
@return
The start point of the intersection ray.
*/
virtual Vector3 getIntersectionStart(const Ray &ray, Real maxDistance) const;
/** Gets the end vector of an intersection. This is needed for restricted volumes
like discreet grids.
@param ray
The ray of the intersection.
@param maxDistance
The maximum distance to query the ray for intersections.
@return
The end point of the intersection ray.
*/
virtual Vector3 getIntersectionEnd(const Ray &ray, Real maxDistance) const;
public:
/// The id of volume files.
static const uint32 VOLUME_CHUNK_ID;
/// The version of volume files.
static const uint16 VOLUME_CHUNK_VERSION;
/// The amount of items being written as one chunk during serialization.
static const size_t SERIALIZATION_CHUNK_SIZE;
/** Destructor.
*/
virtual ~Source(void);
/** Gets the density value and gradient at a specific position.
@param position
The position.
@return
A vector with x, y, z containing the gradient and w containing the density.
*/
virtual Vector4 getValueAndGradient(const Vector3 &position) const = 0;
/** Gets the density value at a specific position.
@param position
The position.
@return
The density.
*/
virtual Real getValue(const Vector3 &position) const = 0;
/** Serializes a volume source to a discrete grid file with deflated
compression. To achieve better compression, all density values are clamped
within a maximum absolute value of (to - from).length() / 16.0. The values
are scanned in this inner-loop-order: z, x, y. y last because there is usually
the least isosurface intersection to be expected in the use case of terrain and
so more often the maximum density value hit. The values are written as 16 Bit
floats to save space. Note that this process is not lossless, the tradeoff is
between accuracy of the source-reproduction (smaller voxelWidth) and smaller
filesize (bigger voxelWidth).
@param from
The start point to scan the volume.
@param to
The end point to scan the volume.
@param voxelWidth
The width of a single cube in the density grid.
@param file
The file to write the grid to.
*/
void serialize(const Vector3 &from, const Vector3 &to, float voxelWidth, const String &file);
/** Same as the other serialize function but with a user definable maximum absolute density value.
@param from
The start point to scan the volume.
@param to
The end point to scan the volume.
@param voxelWidth
The width of a single cube in the density grid.
@param maxClampedAbsoluteDensity
The maximum absolute density value to be written into the file, influencing the compression rate.
@param file
The file to write the grid to.
*/
void serialize(const Vector3 &from, const Vector3 &to, float voxelWidth, Real maxClampedAbsoluteDensity, const String &file);
/** Gets the first intersection of a ray with the volume.
If you are using this together with the VolumeChunk:
Beware of the possible scaling or other transformations you did on the Chunk! Do the inverse first
on the ray origin. Example of a scaling with the factor 10: ray.setOrigin(ray.getOrigin() / (Real)10.0);
@param ray
The ray.
@param result
Will hold the intersection point if there is an intersection.
@param scale
The scaling of the volume compared to the world.
@param maxIterations
The maximum amount of iterations on the ray before giving up.
@param maxDistance
The maximum distance of the intersection point.
*/
bool getFirstRayIntersection(const Ray &ray, Vector3 &result, Real scale = (Real)1.0, size_t maxIterations = 5000, Real maxDistance = (Real)10000.0) const;
/** Gets a factor to come from volume coordinate to world coordinate.
@return
The factor, 1.0 in the default implementation.
*/
Real getVolumeSpaceToWorldSpaceFactor(void) const;
};
}
}
#endif
|