Classes | Typedefs | Functions
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< 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< SurgSim::Graphics::OsgMaterialcreatePlainMaterial (const std::string &name, SurgSim::Math::Vector4f diffuseColor, SurgSim::Math::Vector4f specularColor, float shininess)
 Create a basic material. More...
 
std::shared_ptr< SurgSim::Graphics::OsgMaterialcreateTexturedMaterial (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::OsgMaterialcreateNormalMappedMaterial (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::ScreenSpaceQuadRepresentationmakeDebugQuad (const std::string &name, std::shared_ptr< SurgSim::Graphics::Texture > texture, double x, double y, double width, double height)
 
std::shared_ptr< SurgSim::Graphics::RenderPasscreatePass (std::unordered_map< std::string, std::shared_ptr< Graphics::OsgMaterial >> materials, const std::string &passName, const std::string &materialName)
 
std::shared_ptr< Graphics::CameracreateBlurPass (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::RenderPasscreateDepthPass (float sphereRadius, float sphereScale, int textureWidth, int textureHeight, bool debug)
 
std::shared_ptr< Graphics::RenderPasscreateNormalPass (std::shared_ptr< Graphics::Camera > camera, std::shared_ptr< Graphics::Texture > depthMap, int textureWidth, int textureHeight, bool debug)
 
std::shared_ptr< Graphics::RenderPasscreateShadingPass (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::LinearSpringcreateLinearSpring (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::CamerasetupBlurPasses (std::shared_ptr< Graphics::RenderPass > shadowMapPass, int textureSize, double blurRadius, bool debug, std::vector< std::shared_ptr< Framework::SceneElement >> *elements)
 
std::shared_ptr< Graphics::RenderPasscreateLightMapPass (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::RenderPasscreateShadowMapPass (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
sceneThe scene to traverse for component lookup
materialFilenamethe YAML file that contains the descriptions
materialslookup 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
viewthe view to pull screen space dimensions from
lightthe scene light to be used to shade the surface
lightMapPassscene element containing the render pass for shadow casters
sphereRadiusthe radius in meters that each point sprite sphere should have
sphereScalethe scaling factor for the point sprite sphere based on distance from the camera
blurRadiussampling radius for the blur pass
diffuseColorthe color to use for the final surface shading
specularColorthe color to use for the specular highlight on the surface
diffuseEnvMapthe cube map to use for the diffuse environmental mapping
diffusePctthe amount to blend the environment map with the rest of diffuse lighting
specularEnvMapthe cube map to use for the specular environmental mapping
specularPctthe amount to blend the environment map with the rest of specular lighting
shininessthe shininess factor for the specular highlight
shadowBiasthe bias to be used when determining something is in shadow or not, increasing this can help remove sharp edges at glancing angles
shadowIntensitythe general intensity of the shadow, 1 means everything in shadow will be black, 0 means there won't be any shadows at all
showDebugwhether 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
stateThe state to initialize the spring with (rest length calculation)
nodeId0,nodeId1Node ids of the 2 connected masses
stiffness,dampingThe 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
namename of the material
diffuseColorBase diffuse color to use
specularColorBase specular color to use
shininessPhong shininess exponent
diffuseMapDiffuse 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
normalMapNormal 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
namename of the material
diffuseColorBase diffuse color to use
specularColorBase specular color to use
shininessPhong 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
camerathe view camera that is used for this pass
lightthe light that should be used for the shadows
depthTextureSizethe size of the texture for the depth map, main determinant for the quality of the shadows
shadowTextureSizethe size of shadowTexture pass and the blur textures
lightCameraProjectionparameters 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
biasthe bias to be used when determining something is in shadow or not, increasing this can help remove sharp edges at glancing angles
intensitythe general intensity of the shadow, 1 means everything in shadow will be black, 0 means there won't be any shadows at all
useBlurwhether to blur the output of the light map pass, this will remove some of the blockiness of the shadows
blurRadiussampling radius for the blur pass
showDebugwhether 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
namename of the material
diffuseColorBase diffuse color to use
specularColorBase specular color to use
shininessPhong shininess exponent
diffuseMapDiffuse 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()

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
materialThe material for adding the texture
uniformThe name of the uniform to use
unitThe texture unit to use
filenameThe file to use for the texture,
repeatwhether 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
sourceSource of search
targetTarget 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 
)