MergeSchemeHandler.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
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 */
17 #ifndef _MERGESCHEMEHANDLER_HH_
18 #define _MERGESCHEMEHANDLER_HH_
19 
20 #include <OgreMaterialManager.h>
21 #include <string>
22 #include <vector>
23 
25 #include "gazebo/util/system.hh"
26 
27 namespace gazebo
28 {
29  namespace rendering
30  {
34  public Ogre::MaterialManager::Listener
35  {
36  public: MergeSchemeHandler(bool _useDSF) : useDSF(_useDSF)
37  {
38  if (this->useDSF)
39  {
40  this->materialGenerator =
41  new MergeMaterialGenerator("InferredLighting", true);
42  this->techName = "InferredLighting";
43  }
44  else
45  {
46  this->materialGenerator =
47  new MergeMaterialGenerator("DeferredLighting", false);
48  this->techName = "DeferredLighting";
49  }
50  }
51 
53  public: virtual Ogre::Technique *handleSchemeNotFound(
54  uint16_t _schemeIndex,
55  const Ogre::String &_schemeName,
56  Ogre::Material *_originalMaterial,
57  uint16_t _lodIndex,
58  const Ogre::Renderable* rend);
59 
62  protected: static const std::string normal_map_pattern;
63  protected: bool useDSF;
64  protected: Ogre::String techName;
66 
68  protected: struct PassProperties
69  {
70  PassProperties() : isDeferred(true), normalMap(0), isSkinned(false),
71  hasDiffuseColor(true) {}
72 
73  bool isDeferred;
74  Ogre::TextureUnitState *normalMap;
75  bool isSkinned;
77  Ogre::vector<Ogre::TextureUnitState*>::type regularTextures;
78  };
79 
81  protected: PassProperties InspectPass(Ogre::Pass *_pass,
82  uint16_t _lodIndex, const Ogre::Renderable *_rend);
83 
86  protected: MaterialGenerator::Perm GetPermutation(
87  const PassProperties &_props);
88 
90  protected: void FillPass(Ogre::Pass *_gBufferPass,
91  Ogre::Pass *_originalPass, const PassProperties &_props);
92 
95  protected: bool CheckNormalMap(Ogre::TextureUnitState *_tus,
96  PassProperties &_props);
97  };
98  }
99 }
100 #endif
PassProperties()
Definition: MergeSchemeHandler.hh:70
Ogre::TextureUnitState * normalMap
Definition: MergeSchemeHandler.hh:74
A structure for containing the properties of a material.
Definition: MergeSchemeHandler.hh:68
Ogre::vector< Ogre::TextureUnitState * >::type regularTextures
Definition: MergeSchemeHandler.hh:77
bool useDSF
Definition: MergeSchemeHandler.hh:63
Class for handling materials who did not specify techniques for the merging step of deferred/inferred...
Definition: MergeSchemeHandler.hh:33
Class for generating materials for objects to render themselves in the merging step of deferred light...
Definition: MergeMaterialGenerator.hh:38
bool isDeferred
Definition: MergeSchemeHandler.hh:73
static const std::string normal_map_pattern
The string that will be checked in textures to determine whether they are normal maps.
Definition: MergeSchemeHandler.hh:62
MergeMaterialGenerator * materialGenerator
Definition: MergeSchemeHandler.hh:65
Ogre::String techName
Definition: MergeSchemeHandler.hh:64
bool isSkinned
Definition: MergeSchemeHandler.hh:75
MergeSchemeHandler(bool _useDSF)
Definition: MergeSchemeHandler.hh:36
bool hasDiffuseColor
Definition: MergeSchemeHandler.hh:76
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
uint32_t Perm
Bitfield used to signify a material permutations.
Definition: MaterialGenerator.hh:42