OpenWalnut  1.4.0
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< 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.
osg::Vec2 toUniformType (const WIntervalDouble &in)
 Creates an OSG vec2 when an interval is inserted.
template<typename InType >
UniformType< InType >::Type toUniformType (const InType &in)
 Create an instance of the uniform target type given some input type.
osg::ref_ptr< osg::Geode > generateBoundingBoxGeode (const WBoundingBox &bb, const WColor &color)
 Generates an OSG geode for the bounding box.
osg::ref_ptr< osg::Node > generateSolidBoundingBoxNode (const WBoundingBox &bb, const WColor &color, bool threeDTexCoords=true)
 Generates an OSG node for the specified bounding box.
osg::ref_ptr< osg::Geometry > createUnitCube (const WColor &color)
 Creates a osg::Geometry containing an unit cube, having 3D texture coordinates.
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.
osg::ref_ptr< osg::Geometry > createCube (const WPosition &position, const WPosition &size, const WColor &color)
 Create an arbitrary cube.
osg::ref_ptr< osg::Geometry > createUnitCubeAsLines (const WColor &color)
 Creates a osg::Geometry containing an unit cube as line-strips, having 3D texture coordinates.
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.
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.
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.
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.
osg::ref_ptr
< osg::PositionAttitudeTransform > 
addLabel (osg::Vec3 position, std::string text)
 helper function to add a label somewhere
osg::ref_ptr
< osg::PositionAttitudeTransform > 
vector2label (osg::Vec3 position)
 helper function to add a label with it's position vector
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.
osg::ref_ptr< osg::Group > creatCoordinateSystem (osg::Vec3 middle, double sizeX, double sizeY, double sizeZ)
 Create a coordinate system.
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.
osg::ref_ptr< osg::Vec3Array > generateCuboidQuads (const std::vector< WPosition > &corners)
 Creates out of eight corner vertices QUAD vertices.
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.
osg::ref_ptr< osg::Vec3Array > generateCuboidQuadNormals (const std::vector< WPosition > &corners)
 Generates for all QUADS of the Cuboid the normals in the following order:
WTriangleMesh::SPtr triangulate (const std::vector< WPosition > &points, double transformationFactor=0.0)
 Calculate the Delaunay Triangulation of the given points.
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.
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.
void unbindTexture (osg::ref_ptr< osg::Node > node, size_t unit, size_t count=1)
 Removes the binding associated with the specified unit.
size_t getMaxTexUnits ()
 Returns the maximum number of textures that can be bound to a node.
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.
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.
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.
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.
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.
void enableTransparency (osg::ref_ptr< osg::Node > node)
 Enable transparency for the given node.
WColor getRGBAColorFromDirection (const WPosition &pos1, const WPosition &pos2)
 Transforms a direction given via two points into a RGB color.
osg::ref_ptr< osg::Vec3Array > osgVec3Array (const std::vector< WPosition > &posArray)
 Converts a whole vector of WPositions into an osg::Vec3Array.
osg::Vec3 unprojectFromScreen (const osg::Vec3 screen, osg::ref_ptr< WGECamera > camera)
 Converts screen coordinates into Camera coordinates.
osg::Vec4 unprojectFromScreen (const osg::Vec4 screen, osg::ref_ptr< WGECamera > camera)
 Converts screen coordinates into Camera coordinates.
WColor createColorFromIndex (int index)
 creates the same color as the atlas colormap shader from the index
WColor createColorFromHSV (int h, float s=1.0, float v=1.0)
 creates a rgb WColor from a HSV value
WColor getNthHSVColor (int n)
 creates the nth color of a partition of the hsv color circle
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.
osg::ref_ptr< osg::Node > generateCullProxy (const WBoundingBox &bbox)
 Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling.
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.
template<>
void bindAsUniform< double > (osg::Node *node, double prop, std::string name)
 Template specialization for double values.
template<>
void bindAsUniform< size_t > (osg::Node *node, size_t prop, std::string name)
 Template specialization for size_t values.
template<>
void bindAsUniform< WPropDouble > (osg::Node *node, WPropDouble prop, std::string name)
 Template specialization for WPropDouble values.
template<>
void bindAsUniform< WPropColor > (osg::Node *node, WPropColor prop, std::string name)
 Template specialization for WPropColor values.
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.

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

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 548 of file WGEGeodeUtils.cpp.

References WPathHelper::getAllFonts().

Referenced by vector2label().

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.

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 168 of file WGEUtils.h.

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

Template specialization for double values.

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

Definition at line 183 of file WGEUtils.h.

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 242 of file WGEUtils.h.

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

Template specialization for size_t values.

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

Definition at line 198 of file WGEUtils.h.

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

Template specialization for WPropColor values.

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

Definition at line 228 of file WGEUtils.h.

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

Template specialization for WPropDouble values.

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

Definition at line 213 of file WGEUtils.h.

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

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

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 178 of file WDataTexture3D.cpp.

Referenced by WGEOffscreenRenderPass::bind(), WGETexture< TextureType >::bind(), and WGEColormapping::callback().

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
Notes:
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 324 of file WGEGeodeUtils.cpp.

Referenced by convertToOsgGeometry().

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
Notes:
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 473 of file WGEGeodeUtils.cpp.

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

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
Notes:
mesh cannot be const since osg::Geometry needs non-const pointers to the contained arrays

Definition at line 394 of file WGEGeodeUtils.cpp.

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 502 of file WGEGeodeUtils.cpp.

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 669 of file WGEGeodeUtils.cpp.

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

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.

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.
Returns:
the drawable.

Definition at line 98 of file WGEGeodeUtils.cpp.

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

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 231 of file WGEGeodeUtils.cpp.

References createCube().

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 239 of file WGEGeodeUtils.cpp.

References createCube().

Referenced by generateSolidBoundingBoxNode().

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

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

Parameters:
colorthe color to set for all vertices
Returns:
the geometry

Definition at line 245 of file WGEGeodeUtils.cpp.

Referenced by WGEGridNode::WGEGridNode().

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.

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

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

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.

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

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.

Notes:
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
Notes:
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().

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 288 of file WGEGeodeUtils.cpp.

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

Referenced by generateCullProxy().

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 583 of file WGEGeodeUtils.cpp.

References WPlane::getPointInPlane().

Referenced by WGEOffscreenTexturePass::setup(), and WGEViewerEffect::WGEViewerEffect().

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 625 of file WGEGeodeUtils.cpp.

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.

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

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 WGEPostprocessorLineAO::WGEPostprocessorLineAO(), and WGEPostprocessorSSAO::WGEPostprocessorSSAO().

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

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

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

WColor wge::getNthHSVColor ( int  n)

creates the nth color of a partition of the hsv color circle

Parameters:
nnumber of the color
Returns:
the color

Definition at line 168 of file WGEUtils.cpp.

References createColorFromHSV().

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

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 159 of file WGEUtils.h.

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

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

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 115 of file WGEUniformTypeTraits.h.

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 WGEGeometryUtilsTest::testTriangulate().

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

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 WROIBox::updateGFX(), and WROISphere::updateGFX().

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

Converts screen coordinates into Camera coordinates.

Notes:
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.

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 576 of file WGEGeodeUtils.cpp.

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