The code in here is supposed to help create materials correctly, a lot of it is boilerplate that is repeated over for each material.
More...
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
std::shared_ptr< 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. More...
|
|
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. More...
|
|
The code in here is supposed to help create materials correctly, a lot of it is boilerplate that is repeated over for each material.
It will have to be changed if the shaders being used change.
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 |