GraphicsUtilities.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_BLOCKS_GRAPHICSUTILITIES_H
#define SURGSIM_BLOCKS_GRAPHICSUTILITIES_H
#include <memory>
#include <unordered_map>
#include <string>
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Graphics
{
class OsgMaterial;
}
namespace Framework
{
class Scene;
}
namespace Blocks
{
typedef std::unordered_map<std::string, std::shared_ptr<SurgSim::Graphics::OsgMaterial>> Materials;
void enable2DTexture(std::shared_ptr<SurgSim::Graphics::OsgMaterial> material,
const std::string& uniform,
int unit,
const std::string& filename = "", bool repeat = false);
std::shared_ptr<SurgSim::Graphics::OsgMaterial> createPlainMaterial(
const std::string& name,
SurgSim::Math::Vector4f diffuseColor,
SurgSim::Math::Vector4f specularColor,
float shininess);
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 = "");
std::shared_ptr<SurgSim::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 = "");
void applyMaterials(std::shared_ptr<SurgSim::Framework::Scene> scene,
std::string materialFilename,
const Materials& materials);
}
}
#endif
SurgSim::Blocks::applyMaterials
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 ma...
Definition: GraphicsUtilities.cpp:163
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Blocks::Materials
std::unordered_map< std::string, std::shared_ptr< SurgSim::Graphics::OsgMaterial > > Materials
Definition: GraphicsUtilities.h:41
SurgSim::Math::Vector4f
Eigen::Matrix< float, 4, 1 > Vector4f
A 4D vector of floats.
Definition: Vector.h:45
SurgSim::Blocks::enable2DTexture
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 g...
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Blocks::createNormalMappedMaterial
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.
Definition: GraphicsUtilities.cpp:128
SurgSim::Blocks::createTexturedMaterial
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.
Definition: GraphicsUtilities.cpp:101
SurgSim::Blocks::createPlainMaterial
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.
Definition: GraphicsUtilities.cpp:77