OpenWalnut  1.5.0dev
Classes | Functions
wge Namespace Reference

Extend the wge utils namespace with additional methods relating WDataTexture3D. More...

Classes

class  UniformType
 Class helping to adapt types specified as template parameter into the best matching osg::Uniform (GLSL) type. More...
 
class  UniformType< double >
 Maps doubles to floats as only floats are allowed in uniforms. More...
 
class  UniformType< WVector3d >
 Maps WVector3d/WPosition to osg::Vec3. More...
 
class  UniformType< WMatrix4d >
 Maps WMatrix4d to osg::Matrixd. More...
 
class  UniformType< WItemSelector >
 Maps Selection Properties to ints. More...
 
class  UniformType< WIntervalDouble >
 Maps Selection Properties to ints. More...
 
class  GLType
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< double >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< long double >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< float >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< int8_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< uint8_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< int16_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< uint16_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< int32_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< uint32_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< int64_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 
class  GLType< uint64_t >
 Class helping to adapt types specified as template parameter into the best matching OpenGL type. More...
 

Functions

void bindTexture (osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture, size_t unit=0, std::string prefix="")
 Binds the specified texture to the specified unit. More...
 
osg::Vec2 toUniformType (const WIntervalDouble &in)
 Creates an OSG vec2 when an interval is inserted. More...
 
template<typename InType >
UniformType< InType >::Type toUniformType (const InType &in)
 Create an instance of the uniform target type given some input type. More...
 
osg::ref_ptr< osg::Geode > generateBoundingBoxGeode (const WBoundingBox &bb, const WColor &color)
 Generates an OSG geode for the bounding box. More...
 
osg::ref_ptr< osg::Node > generateSolidBoundingBoxNode (const WBoundingBox &bb, const WColor &color, bool threeDTexCoords=true)
 Generates an OSG node for the specified bounding box. More...
 
osg::ref_ptr< osg::Geometry > createUnitCube (const WColor &color)
 Creates a osg::Geometry containing an unit cube, having 3D texture coordinates. More...
 
void createCube (osg::ref_ptr< osg::Geometry > geometry, const WPosition &position, const WPosition &size, const WColor &color)
 Create an arbitrary cube and insert it into the given geometry. More...
 
osg::ref_ptr< osg::Geometry > createCube (const WPosition &position, const WPosition &size, const WColor &color)
 Create an arbitrary cube. More...
 
osg::ref_ptr< osg::Geometry > createUnitCubeAsLines (const WColor &color, bool asLines=false)
 Creates a osg::Geometry containing an unit cube as line-strips, having 3D texture coordinates. More...
 
osg::ref_ptr< osg::Geometry > convertToOsgGeometry (WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool includeNormals=false, bool lighting=false, bool useMeshColor=true)
 Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry. More...
 
osg::ref_ptr< osg::Geometry > convertToOsgGeometryFlatShaded (WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool includeNormals=false, bool lighting=false, bool useMeshColor=true)
 Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry in order to produce a flat shaded rendering. More...
 
osg::ref_ptr< osg::Geometry > convertToOsgGeometry (WTriangleMesh::SPtr mesh, const WColoredVertices &colorMap, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool includeNormals=false, bool lighting=false)
 Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry. More...
 
osg::ref_ptr< osg::Geometry > convertToOsgGeometryLines (WTriangleMesh::SPtr mesh, const WColor &defaultColor=WColor(1.0, 1.0, 1.0, 1.0), bool useMeshColor=true)
 Convert triangle mesh to lines representing it. More...
 
osg::ref_ptr< osg::PositionAttitudeTransform > addLabel (osg::Vec3 position, std::string text)
 helper function to add a label somewhere More...
 
osg::ref_ptr< osg::PositionAttitudeTransform > vector2label (osg::Vec3 position)
 helper function to add a label with it's position vector More...
 
osg::ref_ptr< osg::Geode > genFinitePlane (double xSize, double ySize, const WPlane &p, const WColor &color=WColor(0.0, 0.7, 0.7, 1.0), bool border=false)
 Generates a geode out of a Plane with a fixed size in direction of the vectors which span that plane. More...
 
osg::ref_ptr< osg::Group > creatCoordinateSystem (osg::Vec3 middle, double sizeX, double sizeY, double sizeZ)
 Create a coordinate system. More...
 
osg::ref_ptr< osg::Geode > genFinitePlane (osg::Vec3 const &base, osg::Vec3 const &a, osg::Vec3 const &b, const WColor &color=defaultColor::WHITE)
 Generates a geode out of two vectors and an origin position. More...
 
osg::ref_ptr< osg::Vec3Array > generateCuboidQuads (const std::vector< WPosition > &corners)
 Creates out of eight corner vertices QUAD vertices. More...
 
osg::Vec3 getQuadNormal (const WPosition &a, const WPosition &b, const WPosition &c)
 Generates for a QUAD given via 3 three points ( the fourth is not needed ) the normal. More...
 
osg::ref_ptr< osg::Vec3Array > generateCuboidQuadNormals (const std::vector< WPosition > &corners)
 Generates for all QUADS of the Cuboid the normals in the following order: More...
 
WTriangleMesh::SPtr triangulate (const std::vector< WPosition > &points, double transformationFactor=0.0)
 Calculate the Delaunay Triangulation of the given points. More...
 
template<typename T >
void bindTexture (osg::ref_ptr< osg::Node > node, osg::ref_ptr< T > texture, size_t unit=0, std::string prefix="")
 Binds the specified texture to the specified unit. More...
 
template<typename T >
void bindTexture (osg::ref_ptr< osg::Node > node, osg::ref_ptr< WGETexture< T > > texture, size_t unit=0, std::string prefix="")
 Binds the specified texture to the specified unit. More...
 
void unbindTexture (osg::ref_ptr< osg::Node > node, size_t unit, size_t count=1)
 Removes the binding associated with the specified unit. More...
 
size_t getMaxTexUnits ()
 Returns the maximum number of textures that can be bound to a node. More...
 
osg::ref_ptr< WGETexture< osg::Texture1D > > genWhiteNoiseTexture (size_t sizeX, size_t channels)
 This generates an 1D texture only containing white noise in its channels. More...
 
osg::ref_ptr< WGETexture< osg::Texture2D > > genWhiteNoiseTexture (size_t sizeX, size_t sizeY, size_t channels)
 This generates an 2D texture only containing white noise in its channels. More...
 
osg::ref_ptr< WGETexture< osg::Texture3D > > genWhiteNoiseTexture (size_t sizeX, size_t sizeY, size_t sizeZ, size_t channels)
 This generates an 3D texture only containing white noise in its channels. More...
 
osg::ref_ptr< osg::Image > genWhiteNoiseImage (size_t sizeX, size_t sizeY, size_t sizeZ, size_t channels=1)
 Generates an image only containing white noise in its channels. More...
 
osg::ref_ptr< WGETexture< osg::Texture3D > > genTuringNoiseTexture (std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ, std::size_t channels=1)
 Generates a 3D turing noise texture. More...
 
void enableTransparency (osg::ref_ptr< osg::Node > node)
 Enable transparency for the given node. More...
 
WColor getRGBAColorFromDirection (const WPosition &pos1, const WPosition &pos2)
 Transforms a direction given via two points into a RGB color. More...
 
osg::ref_ptr< osg::Vec3Array > osgVec3Array (const std::vector< WPosition > &posArray)
 Converts a whole vector of WPositions into an osg::Vec3Array. More...
 
osg::Vec3 unprojectFromScreen (const osg::Vec3 screen, osg::ref_ptr< WGECamera > camera)
 Converts screen coordinates into Camera coordinates. More...
 
osg::Vec4 unprojectFromScreen (const osg::Vec4 screen, osg::ref_ptr< WGECamera > camera)
 Converts screen coordinates into Camera coordinates. More...
 
WColor createColorFromIndex (int index)
 creates the same color as the atlas colormap shader from the index More...
 
WColor createColorFromHSV (int h, float s=1.0, float v=1.0)
 creates a rgb WColor from a HSV value More...
 
WColor getNthHSVColor (int n)
 creates the nth color of a partition of the hsv color circle More...
 
template<typename T >
void bindAsUniform (osg::Node *node, T prop, std::string name)
 Creates a osg::Uniform with given type and name and applies it to the given node. More...
 
osg::ref_ptr< osg::Node > generateCullProxy (const WBoundingBox &bbox)
 Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling. More...
 
osg::ref_ptr< osg::Node > generateDynamicCullProxy (osg::ref_ptr< osg::Node > node)
 Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling. More...
 
template<>
void bindAsUniform< double > (osg::Node *node, double prop, std::string name)
 Template specialization for double values. More...
 
template<>
void bindAsUniform< size_t > (osg::Node *node, size_t prop, std::string name)
 Template specialization for size_t values. More...
 
template<>
void bindAsUniform< WPropDouble > (osg::Node *node, WPropDouble prop, std::string name)
 Template specialization for WPropDouble values. More...
 
template<>
void bindAsUniform< WPropColor > (osg::Node *node, WPropColor prop, std::string name)
 Template specialization for WPropColor values. More...
 
template<>
void bindAsUniform< WPropBool > (osg::Node *node, WPropBool prop, std::string name)
 Template specialization for WPropBool values. More...
 
template<>
void bindAsUniform< WPropInt > (osg::Node *node, WPropInt prop, std::string name)
 Template specialization for WPropInt values. More...
 
template<>
void bindAsUniform< osg::ref_ptr< osg::Uniform > > (osg::Node *node, osg::ref_ptr< osg::Uniform > uniform, std::string)
 Template specialization for osg::Uniform values. More...
 

Detailed Description

Extend the wge utils namespace with additional methods relating WDataTexture3D.

Convinient functions for use with the graphics engine of OpenWalnut.

ATM the namespace is filled by several files: WGEGeodeUtils, WGEGeometryUtils and WGEUtils.

Function Documentation

◆ addLabel()

osg::ref_ptr< osg::PositionAttitudeTransform > wge::addLabel ( osg::Vec3  position,
std::string  text 
)

helper function to add a label somewhere

Parameters
positionposition of the label
texttext
Returns
a positionattitudetransfom object containing the label

Definition at line 595 of file WGEGeodeUtils.cpp.

References WPathHelper::getAllFonts().

Referenced by vector2label().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bindAsUniform()

template<typename T >
void wge::bindAsUniform ( osg::Node *  node,
prop,
std::string  name 
)
inline

Creates a osg::Uniform with given type and name and applies it to the given node.

This is a shortcut for using WGEPropertyUniform in this way:

node->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< T >( name, prop ) );
Class implementing a uniform which can be controlled by a property instance.

*

Template Parameters
TThis is the data used for the uniform. It may be a PropertyType, an integral or an osg::Uniform.
Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 171 of file WGEUtils.h.

◆ bindAsUniform< double >()

template<>
void wge::bindAsUniform< double > ( osg::Node *  node,
double  prop,
std::string  name 
)
inline

Template specialization for double values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 186 of file WGEUtils.h.

◆ bindAsUniform< osg::ref_ptr< osg::Uniform > >()

template<>
void wge::bindAsUniform< osg::ref_ptr< osg::Uniform > > ( osg::Node *  node,
osg::ref_ptr< osg::Uniform >  uniform,
std::string   
)
inline

Template specialization for osg::Uniform values.

Parameters
nodeNode where the uniform should be bound to.
uniformThe type of the uniform.

Definition at line 275 of file WGEUtils.h.

◆ bindAsUniform< size_t >()

template<>
void wge::bindAsUniform< size_t > ( osg::Node *  node,
size_t  prop,
std::string  name 
)
inline

Template specialization for size_t values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 201 of file WGEUtils.h.

◆ bindAsUniform< WPropBool >()

template<>
void wge::bindAsUniform< WPropBool > ( osg::Node *  node,
WPropBool  prop,
std::string  name 
)
inline

Template specialization for WPropBool values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 246 of file WGEUtils.h.

◆ bindAsUniform< WPropColor >()

template<>
void wge::bindAsUniform< WPropColor > ( osg::Node *  node,
WPropColor  prop,
std::string  name 
)
inline

Template specialization for WPropColor values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 231 of file WGEUtils.h.

◆ bindAsUniform< WPropDouble >()

template<>
void wge::bindAsUniform< WPropDouble > ( osg::Node *  node,
WPropDouble  prop,
std::string  name 
)
inline

Template specialization for WPropDouble values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 216 of file WGEUtils.h.

◆ bindAsUniform< WPropInt >()

template<>
void wge::bindAsUniform< WPropInt > ( osg::Node *  node,
WPropInt  prop,
std::string  name 
)
inline

Template specialization for WPropInt values.

This is a shortcut for osg::Uniform generation and osg::StateSet-binding.

Parameters
nodeNode where the uniform should be bound to.
propThe type of the uniform.
nameThe name of the uniform.

Definition at line 261 of file WGEUtils.h.

◆ bindTexture() [1/3]

template<typename T >
void wge::bindTexture ( osg::ref_ptr< osg::Node >  node,
osg::ref_ptr< T >  texture,
size_t  unit = 0,
std::string  prefix = "" 
)

Binds the specified texture to the specified unit.

It automatically adds several uniforms which then can be utilized in the shader:

  • u_textureXUnit: the unit number (useful for accessing correct gl_TexCoord and so on)
  • u_textureXSampler: the needed sampler
  • u_textureXSizeX: width of the texture in pixels
  • u_textureXSizeY: height of the texture in pixels
  • u_textureXSizeZ: depth of the texture in pixels
Warning
this is not OSG-thread-safe. This method binds the texture immediately. So please use this only for nodes which are not yet used in the scene graph. For safely binding textures to a node already in the scene, utilize an update callback.
Parameters
nodewhere to bind
unitthe unit to use
texturethe texture to use.
prefixif specified, defines the uniform name prefix. (Sampler, Unit, Sizes, ...)
Template Parameters
Tthe type of texture. Usually osg::Texture3D or osg::Texture2D.

Definition at line 167 of file WGETextureUtils.h.

References string_utils::toString().

+ Here is the call graph for this function:

◆ bindTexture() [2/3]

void wge::bindTexture ( osg::ref_ptr< osg::Node >  node,
osg::ref_ptr< WDataTexture3D texture,
size_t  unit = 0,
std::string  prefix = "" 
)

Binds the specified texture to the specified unit.

It automatically adds several uniforms which then can be utilized in the shader:

  • u_textureXUnit: the unit number (useful for accessing correct gl_TexCoord and so on)
  • u_textureXSampler: the needed sampler
  • u_textureXSizeX: width of the texture in pixels
  • u_textureXSizeY: height of the texture in pixels
  • u_textureXSizeZ: depth of the texture in pixels If the specified texture is a WGETexture, it additionally adds u_textureXMin and u_textureXScale for unscaling.
Parameters
nodewhere to bind
unitthe unit to use
texturethe texture to use.
prefixif specified, defines the uniform name prefix. (Sampler, Unit, Sizes, ...)
Template Parameters
Tthe type of texture. Usually osg::Texture3D or osg::Texture2D.

Definition at line 182 of file WDataTexture3D.cpp.

Referenced by WGETexture< TextureType >::bind(), WGEOffscreenRenderPass::bind(), WGEColormapping::callback(), WMDirectVolumeRendering::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMProjectionsAsContext::moduleMain(), WMTemplateShaders::moduleMain(), and WMTransferFunctionColorBar::moduleMain().

+ Here is the caller graph for this function:

◆ bindTexture() [3/3]

template<typename T >
void wge::bindTexture ( osg::ref_ptr< osg::Node >  node,
osg::ref_ptr< WGETexture< T > >  texture,
size_t  unit = 0,
std::string  prefix = "" 
)

Binds the specified texture to the specified unit.

It automatically adds several uniforms which then can be utilized in the shader:

  • u_textureXUnit: the unit number (useful for accessing correct gl_TexCoord and so on)
  • u_textureXSampler: the needed sampler
  • u_textureXSizeX: width of the texture in pixels
  • u_textureXSizeY: height of the texture in pixels
  • u_textureXSizeZ: depth of the texture in pixels If the specified texture is a WGETexture, it additionally adds u_textureXMin and u_textureXScale for unscaling.
Warning
this is not OSG-thread-safe. This method binds the texture immediately. So please use this only for nodes which are not yet used in the scene graph. For safely binding textures to a node already in the scene, utilize an update callback.
Parameters
nodewhere to bind
unitthe unit to use
texturethe texture to use.
prefixif specified, defines the uniform name prefix. (Sampler, Unit, Sizes, ...)
Template Parameters
Tthe type of texture. Usually osg::Texture3D or osg::Texture2D.

Definition at line 184 of file WGETextureUtils.h.

References string_utils::toString().

+ Here is the call graph for this function:

◆ convertToOsgGeometry() [1/2]

osg::ref_ptr< osg::Geometry > wge::convertToOsgGeometry ( WTriangleMesh::SPtr  mesh,
const WColor &  defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ),
bool  includeNormals = false,
bool  lighting = false,
bool  useMeshColor = true 
)

Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry.

It can use the normals and per-vertex colors of the mesh.

Parameters
meshthe WTriangleMesh used as input
includeNormalsWhen true, calculate the vertex normals and include them into the geometry.
defaultColorThis color is used in case the useMeshColor parameter is false or no colors are defined in the mesh.
lightingif true, a standard lighting is activated for this geometry
useMeshColorif true, the mesh color is used. If false, the defaultColor is used.
Returns
an osg::Geometry containing the mesh
Note
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 368 of file WGEGeodeUtils.cpp.

Referenced by convertToOsgGeometry(), WMEEGView::drawHeadSurface(), WMSurfaceIllustrator::renderMesh(), and WMTriangleMeshRenderer::renderMesh().

+ Here is the caller graph for this function:

◆ convertToOsgGeometry() [2/2]

osg::ref_ptr< osg::Geometry > wge::convertToOsgGeometry ( WTriangleMesh::SPtr  mesh,
const WColoredVertices colorMap,
const WColor &  defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ),
bool  includeNormals = false,
bool  lighting = false 
)

Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry.

It can use the normals and per-vertex colors of the mesh. This method additionally uses the specified vertexID-color map to provide additional coloring.

Parameters
meshthe WTriangleMesh used as input
colorMapthe map from vertex to color.
includeNormalsWhen true, calculate the vertex normals and include them into the geometry.
defaultColorThis color is used in case the colorMap does not provide a color for a vertex
lightingif true, a standard lighting is activated for this geometry*
Returns
an osg::Geometry containing the mesh
Note
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 520 of file WGEGeodeUtils.cpp.

References convertToOsgGeometry(), and WColoredVertices::getData().

+ Here is the call graph for this function:

◆ convertToOsgGeometryFlatShaded()

osg::ref_ptr< osg::Geometry > wge::convertToOsgGeometryFlatShaded ( WTriangleMesh::SPtr  mesh,
const WColor &  defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ),
bool  includeNormals = false,
bool  lighting = false,
bool  useMeshColor = true 
)

Extract the vertices and triangles from a WTriangleMesh and save them into an osg::Geometry in order to produce a flat shaded rendering.

Parameters
meshthe WTriangleMesh used as input
includeNormalsWhen true, calculate the triangle normals and include them into the geometry.
defaultColorThis color is used in case the useMeshColor parameter is false or no colors are defined in the mesh.
lightingif true, a standard lighting is activated for this geometry
useMeshColorif true, the mesh color is used. If false, the defaultColor is used.
Returns
an osg::Geometry containing the mesh
Note
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 438 of file WGEGeodeUtils.cpp.

Referenced by WMTriangleMeshRenderer::renderMesh().

+ Here is the caller graph for this function:

◆ convertToOsgGeometryLines()

osg::ref_ptr< osg::Geometry > wge::convertToOsgGeometryLines ( WTriangleMesh::SPtr  mesh,
const WColor &  defaultColor = WColor( 1.0, 1.0, 1.0, 1.0 ),
bool  useMeshColor = true 
)

Convert triangle mesh to lines representing it.

Draws lines twice (ATM).

Parameters
meshThe WTriangleMesh used as input.
defaultColorThis color is used in case the useMeshColor parameter is false or no colors are defined in the mesh.
useMeshColorIf true, the mesh color is used. If false, the defaultColor is used.
Returns
an osg::Geometry containing the mesh as lines

Definition at line 549 of file WGEGeodeUtils.cpp.

Referenced by WMSurfaceIllustrator::renderMesh(), and WMTriangleMeshRenderer::renderMesh().

+ Here is the caller graph for this function:

◆ creatCoordinateSystem()

osg::ref_ptr< osg::Group > wge::creatCoordinateSystem ( osg::Vec3  middle,
double  sizeX,
double  sizeY,
double  sizeZ 
)

Create a coordinate system.

The coordinate system is build from cylinders and cones and includes a positive-to-negative color gradient.

Parameters
middleosg::Vec3( middleX, middleY, middleZ ) middle points of X, Y, Z
sizeXwhole lenght of X
sizeYwhole lenght of Y
sizeZwhole lenght of Z
Returns
Group Node

Definition at line 722 of file WGEGeodeUtils.cpp.

Referenced by WMTriangleMeshRenderer::renderMesh().

+ Here is the caller graph for this function:

◆ createColorFromHSV()

WColor wge::createColorFromHSV ( int  h,
float  s = 1.0,
float  v = 1.0 
)

creates a rgb WColor from a HSV value

Parameters
hhue
ssaturation
vvalue
Returns
the color

Definition at line 136 of file WGEUtils.cpp.

Referenced by getNthHSVColor().

+ Here is the caller graph for this function:

◆ createColorFromIndex()

WColor wge::createColorFromIndex ( int  index)

creates the same color as the atlas colormap shader from the index

Parameters
indexunsigned char that indexes the color
Returns
the color

Definition at line 62 of file WGEUtils.cpp.

Referenced by WMPaintTexture::createROI().

+ Here is the caller graph for this function:

◆ createCube() [1/2]

osg::ref_ptr< osg::Geometry > wge::createCube ( const WPosition position,
const WPosition size,
const WColor &  color 
)

Create an arbitrary cube.

Parameters
positionposition of the lower,left,front vertex
sizesize in x,y,z direction
colora color
Returns
the drawable.

Definition at line 232 of file WGEGeodeUtils.cpp.

References createCube().

+ Here is the call graph for this function:

◆ createCube() [2/2]

void wge::createCube ( osg::ref_ptr< osg::Geometry >  geometry,
const WPosition position,
const WPosition size,
const WColor &  color 
)

Create an arbitrary cube and insert it into the given geometry.

You will get a cube with normals, tex coords and a single color. This function is very restrictive with respect to the given geode. It is not recommended to use it in combination with an geometry you already filled with something. It is designed to be used to fill many cubes into one geometry.

Parameters
positionposition of the lower,left,front vertex
sizesize in x,y,z direction
colora color
geometrythe geometry where to add the cube. It can be completely empty (no arrays). If you use an invalid (in the following terms) geometry here, the graphics will fail. Ensure that you have a color array, tex array, normal array and vertex array, where the color array is used per primitive set and normals/tex are bound per vertex. The vertices/tex/normals need to be vec3 arrays. The color array needs to be a vec4 array.

Definition at line 99 of file WGEGeodeUtils.cpp.

Referenced by createCube(), createUnitCube(), WMVoxelizer::genDataSetGeode(), and WROIBox::updateGFX().

+ Here is the caller graph for this function:

◆ createUnitCube()

osg::ref_ptr< osg::Geometry > wge::createUnitCube ( const WColor &  color)

Creates a osg::Geometry containing an unit cube, having 3D texture coordinates.

Parameters
colorthe color to set for all vertices
Returns
the geometry

Definition at line 240 of file WGEGeodeUtils.cpp.

References createCube().

Referenced by generateSolidBoundingBoxNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createUnitCubeAsLines()

osg::ref_ptr< osg::Geometry > wge::createUnitCubeAsLines ( const WColor &  color,
bool  asLines = false 
)

Creates a osg::Geometry containing an unit cube as line-strips, having 3D texture coordinates.

Parameters
colorthe color to set for all vertices
asLinesforce the cube to be made only of lines, no line strips.
Returns
the geometry

Definition at line 246 of file WGEGeodeUtils.cpp.

Referenced by WGEGridNode::WGEGridNode().

+ Here is the caller graph for this function:

◆ enableTransparency()

void wge::enableTransparency ( osg::ref_ptr< osg::Node >  node)

Enable transparency for the given node.

This enabled blending and sets the node to the transparency bin.

Parameters
nodethe node

Definition at line 215 of file WGEUtils.cpp.

Referenced by WMIsosurfaceRaytracer::moduleMain(), WMPointRenderer::moduleMain(), and WMIsosurface::renderMesh().

+ Here is the caller graph for this function:

◆ generateBoundingBoxGeode()

osg::ref_ptr< osg::Geode > wge::generateBoundingBoxGeode ( const WBoundingBox bb,
const WColor &  color 
)

Generates an OSG geode for the bounding box.

Parameters
bbThe axis aligned bounding box to generate a geode from.
colorThe color in which the bounding box should be generated
Returns
The OSG geode containing the 12 edges of the box.

Definition at line 51 of file WGEGeodeUtils.cpp.

References WBoundingBoxImpl< VT >::getMax(), and WBoundingBoxImpl< VT >::getMin().

+ Here is the call graph for this function:

◆ generateCuboidQuadNormals()

osg::ref_ptr< osg::Vec3Array > wge::generateCuboidQuadNormals ( const std::vector< WPosition > &  corners)

Generates for all QUADS of the Cuboid the normals in the following order:

  z-axis  y-axis
  |      /
  | h___/_g
  |/:    /|
  d_:___c |
  | :...|.|
  |.e   | f
  |_____|/ ____x-axis
 a      b
  • a,b,c,d
  • b,f,g,c
  • f,e,h,g
  • e,a,d,h
  • d,c,g,h
  • a,b,f,e
Parameters
cornersCorner points of the cuboid.
Returns
Array of normals in the order as shown above.

Definition at line 84 of file WGEGeometryUtils.cpp.

References getQuadNormal().

+ Here is the call graph for this function:

◆ generateCuboidQuads()

osg::ref_ptr< osg::Vec3Array > wge::generateCuboidQuads ( const std::vector< WPosition > &  corners)

Creates out of eight corner vertices QUAD vertices.

Parameters
cornersThe eight corner vertices which must be in the following order:
 z-axis  y-axis
 |      /
 | h___/_g
 |/:    /|
 d_:___c |
 | :...|.|
 |.e   | f
 |_____|/ ____x-axis
a      b

The QUADS are generated in the following order:

  • a,b,c,d
  • b,f,g,c
  • f,e,h,g
  • e,a,d,h
  • d,c,g,h
  • a,b,f,e
Returns
OSG vertex array where every four vertices describing a QUAD.

Definition at line 37 of file WGEGeometryUtils.cpp.

◆ generateCullProxy()

osg::ref_ptr< osg::Node > wge::generateCullProxy ( const WBoundingBox bbox)

Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling.

This is especially useful if you create some geometry and modify it on the GPU by shaders. In these cases, OSG will not properly cull and near-far clip. This cull proxy is basically a cube, which gets shrinked to zero size on the GPU. This ensures you cannot see it, but it makes OSG see you proper bounding volume.

Parameters
bboxthe bounding box to cover
Returns
the proxy. Add it to your scene root.

Definition at line 236 of file WGEUtils.cpp.

References generateSolidBoundingBoxNode().

Referenced by generateDynamicCullProxy(), WMNavigationSlices::initOSG(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), and WMTemplateRenderPipelines::moduleMain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateDynamicCullProxy()

osg::ref_ptr< osg::Node > wge::generateDynamicCullProxy ( osg::ref_ptr< osg::Node >  node)

Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling.

This is especially useful if you create some geometry and modify it on the GPU by shaders. In these cases, OSG will not properly cull and near-far clip. This cull proxy is basically a cube, which gets shrinked to zero size on the GPU. This ensures you cannot see it, but it makes OSG see you proper bounding volume.

Note
dynamic cull proxys use the getBound method of the specified node before culling. So if you implement objects that change their size dynamically, add a osg::Node::ComputeBoundingSphereCallback to them
This method uses update callbacks. Remember to add your own callbacks via addUpdateCallback, instead of setUpdateCallback.
Parameters
nodethe node
Returns
the proxy. Add it to your scene root.

Definition at line 295 of file WGEUtils.cpp.

References generateCullProxy().

Referenced by WGEOffscreenRenderNode::addGeometryRenderPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateSolidBoundingBoxNode()

osg::ref_ptr< osg::Node > wge::generateSolidBoundingBoxNode ( const WBoundingBox bb,
const WColor &  color,
bool  threeDTexCoords = true 
)

Generates an OSG node for the specified bounding box.

It uses solid faces. This actually returns a MatrixTransform node and is especially useful for shader based raytracing.

Parameters
bbThe axis aligned bounding box
colorThe color in which the bounding box should be generated
threeDTexCoordsTrue if 3D texture coordinates should be created.
Returns
The OSG node containing the 12 edges of the box.

Definition at line 332 of file WGEGeodeUtils.cpp.

References createUnitCube(), WBoundingBoxImpl< VT >::getMax(), and WBoundingBoxImpl< VT >::getMin().

Referenced by generateCullProxy(), WMDirectVolumeRendering::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), and WMSurfaceParameterAnimator::renderSurface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genFinitePlane() [1/2]

osg::ref_ptr< osg::Geode > wge::genFinitePlane ( double  xSize,
double  ySize,
const WPlane p,
const WColor &  color = WColor( 0.0, 0.7, 0.7, 1.0 ),
bool  border = false 
)

Generates a geode out of a Plane with a fixed size in direction of the vectors which span that plane.

Parameters
xSizehow far the plane from its center along the x-axis should be drawn (both directions)
ySizehow far the plane from its center along the y-axis should be drawn (both directions)
pThe plane instance
colorThe color of the plane
borderIf true than a border around each plane is drawn in inverse color of the plane
Returns
The new assembled geode for this plane

Definition at line 630 of file WGEGeodeUtils.cpp.

References WPlane::getPointInPlane().

Referenced by WDemoGeometry::createPlaneGeometry(), WMNavigationSlices::initOSG(), WMImageSpaceLIC::initOSG(), WMImageSpaceTensorLIC::initOSG(), WMColormapper::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WGEOffscreenTexturePass::setup(), and WGEViewerEffect::WGEViewerEffect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genFinitePlane() [2/2]

osg::ref_ptr< osg::Geode > wge::genFinitePlane ( osg::Vec3 const &  base,
osg::Vec3 const &  a,
osg::Vec3 const &  b,
const WColor &  color = defaultColor::WHITE 
)

Generates a geode out of two vectors and an origin position.

Parameters
basethe origin position. NOT the center.
athe first vector spanning the plane
bthe second vector spanning the plane
colorthe color to use.
Returns
the geode

Definition at line 673 of file WGEGeodeUtils.cpp.

◆ genTuringNoiseTexture()

osg::ref_ptr< WGETexture< osg::Texture3D > > wge::genTuringNoiseTexture ( std::size_t  sizeX,
std::size_t  sizeY,
std::size_t  sizeZ,
std::size_t  channels = 1 
)

Generates a 3D turing noise texture.

For details, see:

Eichelbaum, Sebastian, et al. "Fabric-like visualization of tensor field data on arbitrary surfaces in image space." New Developments in the Visualization and Processing of Tensor Fields. Springer Berlin Heidelberg, 2012. 71-92.

Parameters
sizeXThe size of the textures in voxels, should be a power of 2.
sizeYThe size of the textures in voxels, should be a power of 2.
sizeZThe size of the textures in voxels, should be a power of 2.
channelsThe number of channels; either 1, 3 or 4.
Returns
The texture.

Definition at line 122 of file WGETextureUtils.cpp.

◆ genWhiteNoiseImage()

osg::ref_ptr< osg::Image > wge::genWhiteNoiseImage ( size_t  sizeX,
size_t  sizeY,
size_t  sizeZ,
size_t  channels = 1 
)

Generates an image only containing white noise in its channels.

Parameters
sizeXsize in x direction (in pixels)
sizeYsize in y direction (in pixels)
sizeZsize in z direction (in pixels)
channelsthe number of channels. Valid are 1, 3 and 4.
Returns
the generated image.

Definition at line 94 of file WGETextureUtils.cpp.

Referenced by genWhiteNoiseTexture().

+ Here is the caller graph for this function:

◆ genWhiteNoiseTexture() [1/3]

osg::ref_ptr< WGETexture< osg::Texture1D > > wge::genWhiteNoiseTexture ( size_t  sizeX,
size_t  channels 
)

This generates an 1D texture only containing white noise in its channels.

Parameters
sizeXsize in x direction (in pixels)
channelsthe number of channels. Valid are 1, 3 and 4.
Returns
the generated texture.

Definition at line 54 of file WGETextureUtils.cpp.

References genWhiteNoiseImage().

Referenced by WMImageSpaceLIC::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMTemplateShaders::moduleMain(), WGEPostprocessorHalftone::WGEPostprocessorHalftone(), WGEPostprocessorLineAO::WGEPostprocessorLineAO(), and WGEPostprocessorSSAO::WGEPostprocessorSSAO().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ genWhiteNoiseTexture() [2/3]

osg::ref_ptr< WGETexture< osg::Texture2D > > wge::genWhiteNoiseTexture ( size_t  sizeX,
size_t  sizeY,
size_t  channels 
)

This generates an 2D texture only containing white noise in its channels.

Parameters
sizeXsize in x direction (in pixels)
sizeYsize in y direction (in pixels)
channelsthe number of channels. Valid are 1, 3 and 4.
Returns
the generated texture.

Definition at line 66 of file WGETextureUtils.cpp.

References genWhiteNoiseImage().

+ Here is the call graph for this function:

◆ genWhiteNoiseTexture() [3/3]

osg::ref_ptr< WGETexture< osg::Texture3D > > wge::genWhiteNoiseTexture ( size_t  sizeX,
size_t  sizeY,
size_t  sizeZ,
size_t  channels 
)

This generates an 3D texture only containing white noise in its channels.

Parameters
sizeXsize in x direction (in pixels)
sizeYsize in y direction (in pixels)
sizeZsize in z direction (in pixels)
channelsthe number of channels. Valid are 1, 3 and 4.
Returns
the generated texture.

Definition at line 79 of file WGETextureUtils.cpp.

References genWhiteNoiseImage().

+ Here is the call graph for this function:

◆ getMaxTexUnits()

size_t wge::getMaxTexUnits ( )

Returns the maximum number of textures that can be bound to a node.

Call this only from withing the OSG thread!

Returns
the max number of texture units.

Definition at line 45 of file WGETextureUtils.cpp.

Referenced by WGEColormapping::callback().

+ Here is the caller graph for this function:

◆ getNthHSVColor()

WColor wge::getNthHSVColor ( int  n)

◆ getQuadNormal()

osg::Vec3 wge::getQuadNormal ( const WPosition a,
const WPosition b,
const WPosition c 
)

Generates for a QUAD given via 3 three points ( the fourth is not needed ) the normal.

Parameters
aFirst point of the QUAD
bSecond point of the QUAD
cThird point of the QUAD
Returns
OSG Vector of the normal of the QUAD

Definition at line 74 of file WGEGeometryUtils.cpp.

Referenced by generateCuboidQuadNormals().

+ Here is the caller graph for this function:

◆ getRGBAColorFromDirection()

WColor wge::getRGBAColorFromDirection ( const WPosition pos1,
const WPosition pos2 
)
inline

Transforms a direction given via two points into a RGB color.

Parameters
pos1First point
pos2Second point
Returns
converts a vector to a color

Definition at line 162 of file WGEUtils.h.

◆ osgVec3Array()

osg::ref_ptr< osg::Vec3Array > wge::osgVec3Array ( const std::vector< WPosition > &  posArray)

Converts a whole vector of WPositions into an osg::Vec3Array.

Parameters
posArrayThe given positions vector
Returns
Refernce to the same vector but as osg::Vec3Array.

Definition at line 40 of file WGEUtils.cpp.

Referenced by triangulate().

+ Here is the caller graph for this function:

◆ toUniformType() [1/2]

template<typename InType >
UniformType< InType >::Type wge::toUniformType ( const InType &  in)

Create an instance of the uniform target type given some input type.

Template Parameters
InTypethe input type
Parameters
inthe input value
Returns
the resulting uniform type

Definition at line 128 of file WGEUniformTypeTraits.h.

◆ toUniformType() [2/2]

osg::Vec2 wge::toUniformType ( const WIntervalDouble in)

Creates an OSG vec2 when an interval is inserted.

Parameters
inthe interval to convert
Returns
the vector

Definition at line 29 of file WGEUniformTypeTraits.cpp.

References WInterval< T >::getLower(), and WInterval< T >::getUpper().

Referenced by WGEPropertyUniformCallback< T >::operator()().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ triangulate()

WTriangleMesh::SPtr wge::triangulate ( const std::vector< WPosition > &  points,
double  transformationFactor = 0.0 
)

Calculate the Delaunay Triangulation of the given points.

If the parameter transformationFactor is not zero, the points will be transformed to calcule the triangles to get a better triangulation, but the returned mesh will consist of the original points. Every point which lies above the centroid of all points will be put away from this centroid by transformationFactor * height above the centroid. Any point below the centroid will be drawn to the centroid because its height is negative. This effect is inverted with a negative transformationFactor. This transformation is used to calculate the head surface between several electrodes, were a transformationFactor of -0.005 is reasonable.

Parameters
pointsvector of the points to triangulate
transformationFactormagnitude of the transformation before the triangulation
Returns
triangulation as WTriangleMesh

Definition at line 97 of file WGEGeometryUtils.cpp.

References osgVec3Array().

Referenced by WMEEGView::drawHeadSurface(), and WGEGeometryUtilsTest::testTriangulate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unbindTexture()

void wge::unbindTexture ( osg::ref_ptr< osg::Node >  node,
size_t  unit,
size_t  count = 1 
)

Removes the binding associated with the specified unit.

Parameters
unitthe unit to unbind
nodethe node from which the binding should be removed
countthe number of units beginning at the specified one should be unbound? 1 is the default.

Definition at line 36 of file WGETextureUtils.cpp.

Referenced by WGEColormapping::callback().

+ Here is the caller graph for this function:

◆ unprojectFromScreen() [1/2]

osg::Vec3 wge::unprojectFromScreen ( const osg::Vec3  screen,
osg::ref_ptr< WGECamera camera 
)

Converts screen coordinates into Camera coordinates.

Parameters
screenthe screen coordinates
cameraThe matrices of this camera will used for unprojecting.
Returns
un-projects a screen coordinate back to world space

Definition at line 52 of file WGEUtils.cpp.

Referenced by WMNavigationSlices::PickCallback::pick(), WROIBox::updateGFX(), and WROISphere::updateGFX().

+ Here is the caller graph for this function:

◆ unprojectFromScreen() [2/2]

osg::Vec4 wge::unprojectFromScreen ( const osg::Vec4  screen,
osg::ref_ptr< WGECamera camera 
)

Converts screen coordinates into Camera coordinates.

Note
this method can be useful to work with vectors (w component 0)
Parameters
screenthe screen coordinates
cameraThe matrices of this camera will used for unprojecting.
Returns
un-projects a screen coordinate back to world space

Definition at line 57 of file WGEUtils.cpp.

◆ vector2label()

osg::ref_ptr< osg::PositionAttitudeTransform > wge::vector2label ( osg::Vec3  position)

helper function to add a label with it's position vector

Parameters
positionposition of the label
Returns
a positionattitudetransfom object containing the label

Definition at line 623 of file WGEGeodeUtils.cpp.

References addLabel(), and string_utils::toString().

+ Here is the call graph for this function: