OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::Volume::TextureSource Class Reference

A volume source from a 3D texture. More...

#include <OgreVolumeTextureSource.h>

+ Inheritance diagram for Ogre::Volume::TextureSource:
+ Collaboration diagram for Ogre::Volume::TextureSource:

Public Member Functions

 TextureSource (const String &volumeTextureName, const Real worldWidth, const Real worldHeight, const Real worldDepth, const bool trilinearValue=true, const bool trilinearGradient=false, const bool sobelGradient=false)
 Constructur. More...
 
 ~TextureSource (void)
 Destructor. More...
 
virtual void combineWithSource (CSGOperationSource *operation, Source *source, const Vector3 &center, Real radius)
 Updates this grid with another source in a certain area. More...
 
size_t getDepth (void) const
 Gets the depth of the texture. More...
 
bool getFirstRayIntersection (const Ray &ray, Vector3 &result, Real scale=(Real) 1.0, size_t maxIterations=5000, Real maxDistance=(Real) 10000.0) const
 Gets the first intersection of a ray with the volume. More...
 
size_t getHeight (void) const
 Gets the height of the texture. More...
 
virtual Real getValue (const Vector3 &position) const
 Overridden from VolumeSource. More...
 
virtual Vector4 getValueAndGradient (const Vector3 &position) const
 Overridden from VolumeSource. More...
 
Real getVolumeSpaceToWorldSpaceFactor (void) const
 Overridden from VolumeSource. More...
 
size_t getWidth (void) const
 Gets the width of the texture. More...
 
void serialize (const Vector3 &from, const Vector3 &to, float voxelWidth, const String &file)
 Serializes a volume source to a discrete grid file with deflated compression. More...
 
void serialize (const Vector3 &from, const Vector3 &to, float voxelWidth, Real maxClampedAbsoluteDensity, const String &file)
 Same as the other serialize function but with a user definable maximum absolute density value. More...
 

Static Public Attributes

static const size_t SERIALIZATION_CHUNK_SIZE
 The amount of items being written as one chunk during serialization. More...
 
static const uint32 VOLUME_CHUNK_ID
 The id of volume files. More...
 
static const uint16 VOLUME_CHUNK_VERSION
 The version of volume files. More...
 

Protected Member Functions

const Vector3 getGradient (size_t x, size_t y, size_t z) const
 Gets a gradient of a point with optional sobel blurring. More...
 
virtual Vector3 getIntersectionEnd (const Ray &ray, Real maxDistance) const
 Overridden from VolumeSource. More...
 
virtual Vector3 getIntersectionStart (const Ray &ray, Real maxDistance) const
 Overridden from VolumeSource. More...
 
virtual float getVolumeGridValue (size_t x, size_t y, size_t z) const
 Overridden from GridSource. More...
 
virtual void setVolumeGridValue (int x, int y, int z, float value)
 Overridden from GridSource. More...
 

Protected Attributes

float * mData
 The raw volume data. More...
 
size_t mDepth
 The texture depth. More...
 
size_t mHeight
 The texture height. More...
 
Real mPosXScale
 The scale of the position based on the world width. More...
 
Real mPosYScale
 The scale of the position based on the world height. More...
 
Real mPosZScale
 The scale of the position based on the world depth. More...
 
const bool mSobelGradient
 Whether to blur the gradient a bit Sobel like. More...
 
const bool mTrilinearGradient
 Whether to use trilinear filtering or not for the gradient. More...
 
bool mTrilinearValue
 Whether to use trilinear filtering or not for the value. More...
 
Real mVolumeSpaceToWorldSpaceFactor
 Factor to come from volume coordinate to world coordinate. More...
 
size_t mWidth
 The texture width. More...
 
unsigned long mWidthTimesHeight
 To have a little bit faster data access. More...
 

Detailed Description

A volume source from a 3D texture.

Definition at line 39 of file OgreVolumeTextureSource.h.

Constructor & Destructor Documentation

Ogre::Volume::TextureSource::TextureSource ( const String volumeTextureName,
const Real  worldWidth,
const Real  worldHeight,
const Real  worldDepth,
const bool  trilinearValue = true,
const bool  trilinearGradient = false,
const bool  sobelGradient = false 
)
explicit

Constructur.

Parameters
volumeTextureNameWhich volume texture to get the data from.
worldWidthThe world width.
worldHeightThe world height.
worldDepthThe world depth.
trilinearValueWhether to use trilinear filtering (true) or nearest neighbour (false) for the value.
trilinearGradientWhether to use trilinear filtering (true) or nearest neighbour (false) for the gradient.
sobelGradientWhether to add a bit of blur to the gradient like in a sobel filter.
Ogre::Volume::TextureSource::~TextureSource ( void  )

Destructor.

Member Function Documentation

virtual void Ogre::Volume::GridSource::combineWithSource ( CSGOperationSource operation,
Source source,
const Vector3 center,
Real  radius 
)
virtualinherited

Updates this grid with another source in a certain area.

Use it for example to add spheres as a brush.

Parameters
operationThe 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.
sourceThe other source to combine this one with.
centerThe rough center of the affected area by the operation. If the other source is a sphere, take its center for example.
radiusThe 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.
size_t Ogre::Volume::GridSource::getDepth ( void  ) const
inherited

Gets the depth of the texture.

Returns
The depth of the texture.
bool Ogre::Volume::Source::getFirstRayIntersection ( const Ray ray,
Vector3 result,
Real  scale = (Real) 1.0,
size_t  maxIterations = 5000,
Real  maxDistance = (Real) 10000.0 
) const
inherited

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);

Parameters
rayThe ray.
resultWill hold the intersection point if there is an intersection.
scaleThe scaling of the volume compared to the world.
maxIterationsThe maximum amount of iterations on the ray before giving up.
maxDistanceThe maximum distance of the intersection point.
const Vector3 Ogre::Volume::GridSource::getGradient ( size_t  x,
size_t  y,
size_t  z 
) const
inlineprotectedinherited

Gets a gradient of a point with optional sobel blurring.

Parameters
xThe x coordinate of the point.
yThe x coordinate of the point.
zThe x coordinate of the point.

Definition at line 116 of file OgreVolumeGridSource.h.

size_t Ogre::Volume::GridSource::getHeight ( void  ) const
inherited

Gets the height of the texture.

Returns
The height of the texture.
virtual Vector3 Ogre::Volume::GridSource::getIntersectionEnd ( const Ray ray,
Real  maxDistance 
) const
protectedvirtualinherited

Overridden from VolumeSource.

Reimplemented from Ogre::Volume::Source.

virtual Vector3 Ogre::Volume::GridSource::getIntersectionStart ( const Ray ray,
Real  maxDistance 
) const
protectedvirtualinherited

Overridden from VolumeSource.

Reimplemented from Ogre::Volume::Source.

virtual Real Ogre::Volume::GridSource::getValue ( const Vector3 position) const
virtualinherited

Overridden from VolumeSource.

Implements Ogre::Volume::Source.

virtual Vector4 Ogre::Volume::GridSource::getValueAndGradient ( const Vector3 position) const
virtualinherited

Overridden from VolumeSource.

Implements Ogre::Volume::Source.

virtual float Ogre::Volume::TextureSource::getVolumeGridValue ( size_t  x,
size_t  y,
size_t  z 
) const
protectedvirtual

Overridden from GridSource.

Implements Ogre::Volume::GridSource.

Real Ogre::Volume::GridSource::getVolumeSpaceToWorldSpaceFactor ( void  ) const
inherited

Overridden from VolumeSource.

size_t Ogre::Volume::GridSource::getWidth ( void  ) const
inherited

Gets the width of the texture.

Returns
The width of the texture.
void Ogre::Volume::Source::serialize ( const Vector3 from,
const Vector3 to,
float  voxelWidth,
const String file 
)
inherited

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).

Parameters
fromThe start point to scan the volume.
toThe end point to scan the volume.
voxelWidthThe width of a single cube in the density grid.
fileThe file to write the grid to.
void Ogre::Volume::Source::serialize ( const Vector3 from,
const Vector3 to,
float  voxelWidth,
Real  maxClampedAbsoluteDensity,
const String file 
)
inherited

Same as the other serialize function but with a user definable maximum absolute density value.

Parameters
fromThe start point to scan the volume.
toThe end point to scan the volume.
voxelWidthThe width of a single cube in the density grid.
maxClampedAbsoluteDensityThe maximum absolute density value to be written into the file, influencing the compression rate.
fileThe file to write the grid to.
virtual void Ogre::Volume::TextureSource::setVolumeGridValue ( int  x,
int  y,
int  z,
float  value 
)
protectedvirtual

Overridden from GridSource.

Implements Ogre::Volume::GridSource.

Member Data Documentation

float* Ogre::Volume::TextureSource::mData
protected

The raw volume data.

Definition at line 47 of file OgreVolumeTextureSource.h.

size_t Ogre::Volume::GridSource::mDepth
protectedinherited

The texture depth.

Definition at line 53 of file OgreVolumeGridSource.h.

size_t Ogre::Volume::GridSource::mHeight
protectedinherited

The texture height.

Definition at line 50 of file OgreVolumeGridSource.h.

Real Ogre::Volume::GridSource::mPosXScale
protectedinherited

The scale of the position based on the world width.

Definition at line 56 of file OgreVolumeGridSource.h.

Real Ogre::Volume::GridSource::mPosYScale
protectedinherited

The scale of the position based on the world height.

Definition at line 59 of file OgreVolumeGridSource.h.

Real Ogre::Volume::GridSource::mPosZScale
protectedinherited

The scale of the position based on the world depth.

Definition at line 62 of file OgreVolumeGridSource.h.

const bool Ogre::Volume::GridSource::mSobelGradient
protectedinherited

Whether to blur the gradient a bit Sobel like.

Definition at line 71 of file OgreVolumeGridSource.h.

const bool Ogre::Volume::GridSource::mTrilinearGradient
protectedinherited

Whether to use trilinear filtering or not for the gradient.

Definition at line 68 of file OgreVolumeGridSource.h.

bool Ogre::Volume::GridSource::mTrilinearValue
protectedinherited

Whether to use trilinear filtering or not for the value.

Definition at line 65 of file OgreVolumeGridSource.h.

Real Ogre::Volume::GridSource::mVolumeSpaceToWorldSpaceFactor
protectedinherited

Factor to come from volume coordinate to world coordinate.

Definition at line 74 of file OgreVolumeGridSource.h.

size_t Ogre::Volume::GridSource::mWidth
protectedinherited

The texture width.

Definition at line 47 of file OgreVolumeGridSource.h.

unsigned long Ogre::Volume::TextureSource::mWidthTimesHeight
protected

To have a little bit faster data access.

Definition at line 44 of file OgreVolumeTextureSource.h.

const size_t Ogre::Volume::Source::SERIALIZATION_CHUNK_SIZE
staticinherited

The amount of items being written as one chunk during serialization.

Definition at line 76 of file OgreVolumeSource.h.

const uint32 Ogre::Volume::Source::VOLUME_CHUNK_ID
staticinherited

The id of volume files.

Definition at line 70 of file OgreVolumeSource.h.

const uint16 Ogre::Volume::Source::VOLUME_CHUNK_VERSION
staticinherited

The version of volume files.

Definition at line 73 of file OgreVolumeSource.h.


The documentation for this class was generated from the following file: