opensurgsim
GraphicsUtilities.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_BLOCKS_GRAPHICSUTILITIES_H
17 #define SURGSIM_BLOCKS_GRAPHICSUTILITIES_H
18 
19 #include <memory>
20 #include <unordered_map>
21 #include <string>
22 #include "SurgSim/Math/Vector.h"
23 
27 namespace SurgSim
28 {
29 namespace Graphics
30 {
31 class OsgMaterial;
32 }
33 namespace Framework
34 {
35 class Scene;
36 }
37 
38 namespace Blocks
39 {
40 
41 typedef std::unordered_map<std::string, std::shared_ptr<SurgSim::Graphics::OsgMaterial>> Materials;
42 
52 void enable2DTexture(std::shared_ptr<SurgSim::Graphics::OsgMaterial> material,
53  const std::string& uniform,
54  int unit,
55  const std::string& filename = "", bool repeat = false);
56 
62 std::shared_ptr<SurgSim::Graphics::OsgMaterial> createPlainMaterial(
63  const std::string& name,
64  SurgSim::Math::Vector4f diffuseColor,
65  SurgSim::Math::Vector4f specularColor,
66  float shininess);
67 
75 std::shared_ptr<SurgSim::Graphics::OsgMaterial> createTexturedMaterial(
76  const std::string& name,
77  SurgSim::Math::Vector4f diffuseColor,
78  SurgSim::Math::Vector4f specularColor,
79  float shininess,
80  const std::string& diffuseMap = "");
81 
91 std::shared_ptr<SurgSim::Graphics::OsgMaterial> createNormalMappedMaterial(
92  const std::string& name,
93  SurgSim::Math::Vector4f diffuseColor,
94  SurgSim::Math::Vector4f specularColor,
95  float shininess,
96  const std::string& diffuseMap = "",
97  const std::string& normalMap = "");
98 
119 void applyMaterials(std::shared_ptr<SurgSim::Framework::Scene> scene,
120  std::string materialFilename,
121  const Materials& materials);
122 
123 
124 }
125 }
126 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Eigen::Matrix< float, 4, 1 > Vector4f
A 4D vector of floats.
Definition: Vector.h:45
Definitions of small fixed-size vector types.