SurgSim::Blocks Namespace Reference

## Classes

class | CompoundShapeToGraphics
| Keep a set of Graphics representations in sync with a CompoundShape, the shape can either be set directly or pulled from a Physics or Collision Representation. More...
class | DebugDumpBehavior
| Provides keyboard access to debugging functionality F1 - call the graphics manager dumpDebugInfo, this will write the current scenegraph to a file in the working directory. More...
class | DriveElementFromInputBehavior
| Behavior to copy a pose from an input component to a SceneElement By adding this behavior to a SceneElement, that SceneElement will be moved in correspondance to the input. More...
class | FunctionBehavior
| A Behavior that can run any callable target in its update function. More...
class | KeyBehavior
| Behavior to abstract the functionality of keyboard driven behaviors, can be programmed to react to a single keystroke. More...
class | KeyboardCallbackBehavior
| This behavior will call the registered callback function when the registered key is pressed. More...
class | KeyboardTogglesComponentBehavior
| This behavior is used to control the activity of registered components. More...
class | MassSpring1DRepresentation
class | MassSpring2DRepresentation
class | MassSpring3DRepresentation
class | PoseInterpolator
| Perform linear interpolation on two poses. More...
class | SingleKeyBehavior
| Behavior to abstract the functionality of keyboard driven behaviors, can be programmed to react to a single keystroke. More...
class | SphereElement
class | TransferParticlesToPointCloudBehavior
| Behavior to copy positions of a Particles::Representation to a PointCloud. More...
class | TransferPhysicsToGraphicsMeshBehavior
| Behavior to copy positions of a PhysicsRepresentation to a GraphicsMesh. More...
class | TransferPhysicsToPointCloudBehavior
| Behavior to copy positions of a PhysicsRepresentation to a PointCloud. More...
class | TransferPhysicsToVerticesBehavior
| Transfer Physics State to any representation that has a Vertices property, the "Vertices" property on the targets side needs to accept DataStructures::VerticesPlain for the type. More...
class | VisualizeConstraints
| SceneElement that generates the VisualizeConstraintBehavior and the appropriate graphics Vectorfield. More...
class | VisualizeConstraintsBehavior
| Behavior to visualize information about the constraints as they are in the physics manager this will show the constraint location and the force from the last iteration of the physics manager. More...
class | VisualizeContactsBehavior
| This behavior is used to visualize the contacts on collision representation through vector field. More...

## Typedefs

typedef std::unordered_map< std::string, std::shared_ptr< SurgSim::Graphics::OsgMaterial > > | Materials

## Functions

void | enable2DTexture (std::shared_ptr< Graphics::OsgMaterial > material, const std::string &uniform, int unit, const std::string &filename, bool repeat)
std::shared_ptr< SurgSim::Graphics::OsgMaterial > | createPlainMaterial (const std::string &name, SurgSim::Math::Vector4f diffuseColor, SurgSim::Math::Vector4f specularColor, float shininess)
| Create a basic material. More...
std::shared_ptr< SurgSim::Graphics::OsgMaterial > | createTexturedMaterial (const std::string &name, SurgSim::Math::Vector4f diffuseColor, SurgSim::Math::Vector4f specularColor, float shininess, const std::string &diffuseMap="")
| Create a basic textured material. More...
std::shared_ptr< Graphics::OsgMaterial > | createNormalMappedMaterial (const std::string &name, SurgSim::Math::Vector4f diffuseColor, SurgSim::Math::Vector4f specularColor, float shininess, const std::string &diffuseMap="", const std::string &normalMap="")
| Create a basic textured material. More...
void | applyMaterials (std::shared_ptr< SurgSim::Framework::Scene > scene, std::string materialFilename, const Materials &materials)
| Reads a material file, iterates over the components listed up in the material file and applies the materials and the appropriate material properties (if present) to the component, if the component is not found it will be ignored The material file is a yaml file with the following format. More...
std::shared_ptr< SurgSim::Graphics::ScreenSpaceQuadRepresentation > | makeDebugQuad (const std::string &name, std::shared_ptr< SurgSim::Graphics::Texture > texture, double x, double y, double width, double height)
std::shared_ptr< SurgSim::Graphics::RenderPass > | createPass (std::unordered_map< std::string, std::shared_ptr< Graphics::OsgMaterial >> materials, const std::string &passName, const std::string &materialName)
void | enable2DTexture (std::shared_ptr< SurgSim::Graphics::OsgMaterial > material, const std::string &uniform, int unit, const std::string &filename="", bool repeat=false)
| Provide a consistent interface to add texture uniforms on materials, adds the actual texture with a given minimum unit, or provides a placeholder uniform for the unit. More...
std::shared_ptr< Graphics::Camera > | createBlurPass (std::shared_ptr< Graphics::RenderPass > depthPass, int textureWidth, int textureHeight, double blurRadius, std::vector< std::shared_ptr< Framework::SceneElement >> *elements, bool debug)
std::shared_ptr< Graphics::RenderPass > | createDepthPass (float sphereRadius, float sphereScale, int textureWidth, int textureHeight, bool debug)
std::shared_ptr< Graphics::RenderPass > | createNormalPass (std::shared_ptr< Graphics::Camera > camera, std::shared_ptr< Graphics::Texture > depthMap, int textureWidth, int textureHeight, bool debug)

std::shared_ptr< Graphics::RenderPass >

createShadingPass (std::shared_ptr< Graphics::View > view, std::shared_ptr< Graphics::Camera > camera, std::shared_ptr< Graphics::Light > light, std::shared_ptr< Graphics::RenderPass > lightMapPass, std::shared_ptr< Graphics::Texture > depthMap, std::shared_ptr< Graphics::Texture > normalMap, const Math::Vector4f &diffuseColor, const Math::Vector4f &specularColor, const std::string diffuseEnvMap, float diffusePct, const std::string specularEnvMap, float specularPct, float shininess, float shadowBias, float shadowIntensity)

std::vector< std::shared_ptr< Framework::SceneElement > >

createImplicitSurfaceEffect (std::shared_ptr< Framework::Component > view, std::shared_ptr< Framework::Component > light, std::shared_ptr< Framework::SceneElement > lightMapPass, float sphereRadius, float sphereScale, float blurRadius, const Math::Vector4f &diffuseColor, const Math::Vector4f &specularColor, const std::string diffuseEnvMap, float diffusePct, const std::string specularEnvMap, float specularPct, float shininess, float shadowBias, float shadowIntensity, bool showDebug)

| Builds a series of SceneElements enabling the rendering of a screen-space surface, all graphics objects that should be rendered as a surface need to be in the render group GROUP_IMPLICIT_SURFACE. More...
std::shared_ptr< SurgSim::Physics::LinearSpring > | createLinearSpring (const std::shared_ptr< SurgSim::Math::OdeState > state, size_t nodeId0, size_t nodeId1, double stiffness, double damping)
| Helper method to create a LinearSpring. More...
std::shared_ptr< Graphics::Camera > | setupBlurPasses (std::shared_ptr< Graphics::RenderPass > shadowMapPass, int textureSize, double blurRadius, bool debug, std::vector< std::shared_ptr< Framework::SceneElement >> *elements)
std::shared_ptr< Graphics::RenderPass > | createLightMapPass (int textureSize, bool debug)
| Create the pass that renders the scene from the view of the light source the identifier GROUP_SHADOW_CASTER is used in all graphic objects to mark them as used in this pass. More...
std::shared_ptr< Graphics::RenderPass > | createShadowMapPass (int textureSize, double bias, double intensity, bool debug)
| Create the pass that renders shadowed pixels into the scene, the identifier GROUPD_SHADOW_RECEIVER is used in all graphics objects to mark them as used in this pass. More...
std::vector< std::shared_ptr< Framework::SceneElement > > | createShadowMapping (std::shared_ptr< Framework::Component > camera, std::shared_ptr< Framework::Component > light, int depthTextureSize, int shadowTextureSize, std::array< double, 6 > lightCameraProjection, double bias, double intensity, bool useBlur, double blurRadius, bool showDebug)
| Builds a series of SceneElements enabling the rendering of shadows, all graphics object that should cast shadows need to be in the render group GROUP_SHADOW_CASTER, all objects that should receive shadows should be in the render group GROUP_SHADOW_RECEIVER. More...
std::vector< std::pair< size_t, size_t > > | generateIndexMap (const std::shared_ptr< DataStructures::TriangleMeshPlain > &source, const std::shared_ptr< DataStructures::TriangleMeshPlain > &target)
| Generate a mapping, for each point in source find the points target that coincide. More...

## Typedef Documentation

## Materials

typedef std::unordered_map<std::string, std::shared_ptr<SurgSim::Graphics::OsgMaterial> > SurgSim::Blocks::Materials

## Function Documentation

## applyMaterials()

void SurgSim::Blocks::applyMaterials | ( | std::shared_ptr< SurgSim::Framework::Scene > | scene,
|  | std::string | materialFilename,
|  | const Materials & | materials
| ) |  |

Reads a material file, iterates over the components listed up in the material file and applies the materials and the appropriate material properties (if present) to the component, if the component is not found it will be ignored The material file is a yaml file with the following format.

- SceneElementName/ComponentName> Material: MaterialName Properties:
  - [GLSLUniformType, UniformName, YamlEncodedValue]
  - [GLSLUniformType, UniformName, YamlEncodedValue]
- SceneElementName/ComponentName Material: ...

The name of the SceneElement and the Component addressed need to be be separated by a '/' character. For each of the properties a uniform is created with the given GLSL type, name, and the YAML node will be passed to the uniform setter for conversion. If the type does not match what the appropriate GLSL type is, there will be an error. GLSLUniformType is e.g. vec3, vec4, float, mat4 ...

Parameters

  scene | The scene to traverse for component lookup
  materialFilename | the YAML file that contains the descriptions
  materials | lookup table for all the materials that are available

## createBlurPass()

std::shared_ptr<Graphics::Camera> SurgSim::Blocks::createBlurPass | ( | std::shared_ptr< Graphics::RenderPass > | depthPass,
|  | int | textureWidth,
|  | int | textureHeight,
|  | double | blurRadius,
|  | std::vector< std::shared_ptr< Framework::SceneElement >> * | elements,
|  | bool | debug
| ) |  |

## createDepthPass()

std::shared_ptr<Graphics::RenderPass> SurgSim::Blocks::createDepthPass | ( | float | sphereRadius,
|  | float | sphereScale,
|  | int | textureWidth,
|  | int | textureHeight,
|  | bool | debug
| ) |  |

## createImplicitSurfaceEffect()

std::vector< std::shared_ptr< Framework::SceneElement > > SurgSim::Blocks::createImplicitSurfaceEffect | ( | std::shared_ptr< Framework::Component > | view,
|  | std::shared_ptr< Framework::Component > | light,
|  | std::shared_ptr< Framework::SceneElement > | lightMapPass,
|  | float | sphereRadius,
|  | float | sphereScale,
|  | float | blurRadius,
|  | const Math::Vector4f & | diffuseColor,
|  | const Math::Vector4f & | specularColor,
|  | const std::string | diffuseEnvMap,
|  | float | diffusePct,
|  | const std::string | specularEnvMap,
|  | float | specularPct,
|  | float | shininess,
|  | float | shadowBias,
|  | float | shadowIntensity,
|  | bool | showDebug
| ) |  |

Builds a series of SceneElements enabling the rendering of a screen-space surface, all graphics objects that should be rendered as a surface need to be in the render group GROUP_IMPLICIT_SURFACE.

The rest is done by the graphics system. All of the elements added are

See also
  RenderPass elements

Parameters

  view | the view to pull screen space dimensions from
  light | the scene light to be used to shade the surface
  lightMapPass | scene element containing the render pass for shadow casters
  sphereRadius | the radius in meters that each point sprite sphere should have
  sphereScale | the scaling factor for the point sprite sphere based on distance from the camera
  blurRadius | sampling radius for the blur pass
  diffuseColor | the color to use for the final surface shading
  specularColor | the color to use for the specular highlight on the surface
  diffuseEnvMap | the cube map to use for the diffuse environmental mapping
  diffusePct | the amount to blend the environment map with the rest of diffuse lighting
  specularEnvMap | the cube map to use for the specular environmental mapping
  specularPct | the amount to blend the environment map with the rest of specular lighting
  shininess | the shininess factor for the specular highlight
  shadowBias | the bias to be used when determining something is in shadow or not, increasing this can help remove sharp edges at glancing angles
  shadowIntensity | the general intensity of the shadow, 1 means everything in shadow will be black, 0 means there won't be any shadows at all
  showDebug | whether to show debug information

## createLightMapPass()

std::shared_ptr<Graphics::RenderPass> SurgSim::Blocks::createLightMapPass | ( | int | textureSize,
|  | bool | debug
| ) |  |

Create the pass that renders the scene from the view of the light source the identifier GROUP_SHADOW_CASTER is used in all graphic objects to mark them as used in this pass.

## createLinearSpring()

std::shared_ptr< SurgSim::Physics::LinearSpring > SurgSim::Blocks::createLinearSpring | ( | const std::shared_ptr< SurgSim::Math::OdeState > | state,
|  | size_t | nodeId0,
|  | size_t | nodeId1,
|  | double | stiffness,
|  | double | damping
| ) |  |

Helper method to create a LinearSpring.

Parameters

  state | The state to initialize the spring with (rest length calculation)
  nodeId0,nodeId1 | Node ids of the 2 connected masses
  stiffness,damping | The spring parameters

Returns
  The newly create spring

## createNormalMappedMaterial()

std::shared_ptr< SurgSim::Graphics::OsgMaterial > SurgSim::Blocks::createNormalMappedMaterial | ( | const std::string & | name,
|  | SurgSim::Math::Vector4f | diffuseColor,
|  | SurgSim::Math::Vector4f | specularColor,
|  | float | shininess,
|  | const std::string & | diffuseMap = `""`,
|  | const std::string & | normalMap = `""`
| ) |  |

Create a basic textured material.

Parameters

  name | name of the material
  diffuseColor | Base diffuse color to use
  specularColor | Base specular color to use
  shininess | Phong shininess exponent
  diffuseMap | Diffuse texture map name to use, if the texture is embedded in the object pass an empty string here, it has to occupy the correct texture unit as defined by

See also
  DIFFUSE_TEXTURE_UNIT.

Parameters

  normalMap | Normal texture map to use, if the texture is embedded in the object pass an empty string here, it has to occupy the correct texture unit as defined by

See also
  NORMAL_TEXTURE_UNIT.

## createNormalPass()

std::shared_ptr<Graphics::RenderPass> SurgSim::Blocks::createNormalPass | ( | std::shared_ptr< Graphics::Camera > | camera,
|  | std::shared_ptr< Graphics::Texture > | depthMap,
|  | int | textureWidth,
|  | int | textureHeight,
|  | bool | debug
| ) |  |

## createPass()

std::shared_ptr<SurgSim::Graphics::RenderPass> SurgSim::Blocks::createPass | ( | std::unordered_map< std::string, std::shared_ptr< Graphics::OsgMaterial >> | materials,
|  | const std::string & | passName,
|  | const std::string & | materialName
| ) |  |

## createPlainMaterial()

std::shared_ptr< SurgSim::Graphics::OsgMaterial > SurgSim::Blocks::createPlainMaterial | ( | const std::string & | name,
|  | SurgSim::Math::Vector4f | diffuseColor,
|  | SurgSim::Math::Vector4f | specularColor,
|  | float | shininess
| ) |  |

Create a basic material.

Parameters

  name | name of the material
  diffuseColor | Base diffuse color to use
  specularColor | Base specular color to use
  shininess | Phong shininess exponent

## createShadingPass()

std::shared_ptr<Graphics::RenderPass> SurgSim::Blocks::createShadingPass | ( | std::shared_ptr< Graphics::View > | view,
|  | std::shared_ptr< Graphics::Camera > | camera,
|  | std::shared_ptr< Graphics::Light > | light,
|  | std::shared_ptr< Graphics::RenderPass > | lightMapPass,
|  | std::shared_ptr< Graphics::Texture > | depthMap,
|  | std::shared_ptr< Graphics::Texture > | normalMap,
|  | const Math::Vector4f & | diffuseColor,
|  | const Math::Vector4f & | specularColor,
|  | const std::string | diffuseEnvMap,
|  | float | diffusePct,
|  | const std::string | specularEnvMap,
|  | float | specularPct,
|  | float | shininess,
|  | float | shadowBias,
|  | float | shadowIntensity
| ) |  |

## createShadowMapPass()

std::shared_ptr<Graphics::RenderPass> SurgSim::Blocks::createShadowMapPass | ( | int | textureSize,
|  | double | bias,
|  | double | intensity,
|  | bool | debug
| ) |  |

Create the pass that renders shadowed pixels into the scene, the identifier GROUPD_SHADOW_RECEIVER is used in all graphics objects to mark them as used in this pass.

## createShadowMapping()

std::vector< std::shared_ptr< Framework::SceneElement > > SurgSim::Blocks::createShadowMapping | ( | std::shared_ptr< Framework::Component > | camera,
|  | std::shared_ptr< Framework::Component > | light,
|  | int | depthTextureSize,
|  | int | shadowTextureSize,
|  | std::array< double, 6 > | lightCameraProjection,
|  | double | bias,
|  | double | intensity,
|  | bool | useBlur,
|  | double | blurRadius,
|  | bool | showDebug
| ) |  |

Builds a series of SceneElements enabling the rendering of shadows, all graphics object that should cast shadows need to be in the render group GROUP_SHADOW_CASTER, all objects that should receive shadows should be in the render group GROUP_SHADOW_RECEIVER.

The rest is done by the graphics system. All of the elements added are

See also
  RenderPass elements

Parameters

  camera | the view camera that is used for this pass
  light | the light that should be used for the shadows
  depthTextureSize | the size of the texture for the depth map, main determinant for the quality of the shadows
  shadowTextureSize | the size of shadowTexture pass and the blur textures
  lightCameraProjection | parameters for an orthogonal projection that will be used to render the scene from the lights point of view, needs to be set so it encompasses all the shadow casters and receivers
  bias | the bias to be used when determining something is in shadow or not, increasing this can help remove sharp edges at glancing angles
  intensity | the general intensity of the shadow, 1 means everything in shadow will be black, 0 means there won't be any shadows at all
  useBlur | whether to blur the output of the light map pass, this will remove some of the blockiness of the shadows
  blurRadius | sampling radius for the blur pass
  showDebug | whether to show debug information

## createTexturedMaterial()

std::shared_ptr< SurgSim::Graphics::OsgMaterial > SurgSim::Blocks::createTexturedMaterial | ( | const std::string & | name,
|  | SurgSim::Math::Vector4f | diffuseColor,
|  | SurgSim::Math::Vector4f | specularColor,
|  | float | shininess,
|  | const std::string & | diffuseMap = `""`
| ) |  |

Create a basic textured material.

Parameters

  name | name of the material
  diffuseColor | Base diffuse color to use
  specularColor | Base specular color to use
  shininess | Phong shininess exponent
  diffuseMap | Diffuse texture map name to use, if the texture is embedded in the object pass an empty string here, it has to occupy the correct texture unit though.

## enable2DTexture() [1/2]

void SurgSim::Blocks::enable2DTexture | ( | std::shared_ptr< Graphics::OsgMaterial > | material,
|  | const std::string & | uniform,
|  | int | unit,
|  | const std::string & | filename,
|  | bool | repeat
| ) |  |

## enable2DTexture() [2/2]

void SurgSim::Blocks::enable2DTexture | ( | std::shared_ptr< SurgSim::Graphics::OsgMaterial > | material,
|  | const std::string & | uniform,
|  | int | unit,
|  | const std::string & | filename = `""`,
|  | bool | repeat = `false`
| ) |  |

Provide a consistent interface to add texture uniforms on materials, adds the actual texture with a given minimum unit, or provides a placeholder uniform for the unit.

Parameters

  material | The material for adding the texture
  uniform | The name of the uniform to use
  unit | The texture unit to use
  filename | The file to use for the texture,
  repeat | whether to create the texture as repeating

Note
  if the texture filename is empty a placeholder uniform will be created using the unit as a value this for using objects with textures built in without having to assign the texture to the material on creation

## generateIndexMap()

std::vector< std::pair< size_t, size_t > > SurgSim::Blocks::generateIndexMap | ( | const std::shared_ptr< DataStructures::TriangleMeshPlain > & | source,
|  | const std::shared_ptr< DataStructures::TriangleMeshPlain > & | target
| ) |  |

Generate a mapping, for each point in source find the points target that coincide.

Parameters

  source | Source of search
  target | Target of search

Note
  source and target need to be triangle meshes

Returns
  the map of matching points, pair.first are all points from source, pair.second will be points in target

## makeDebugQuad()

std::shared_ptr<SurgSim::Graphics::ScreenSpaceQuadRepresentation> SurgSim::Blocks::makeDebugQuad | ( | const std::string & | name,
|  | std::shared_ptr< SurgSim::Graphics::Texture > | texture,
|  | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

## setupBlurPasses()

std::shared_ptr<Graphics::Camera> SurgSim::Blocks::setupBlurPasses | ( | std::shared_ptr< Graphics::RenderPass > | shadowMapPass,
|  | int | textureSize,
|  | double | blurRadius,
|  | bool | debug,
|  | std::vector< std::shared_ptr< Framework::SceneElement >> * | elements
| ) |  |