VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtEffectTextureRegistry.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
17 
19 
20 #include <osg/ExtendedMaterial>
21 
22 #include <string>
23 #include <boost/thread/shared_mutex.hpp>
24 
25 namespace makVrv
26 {
27  class DtDe;
28 
33  {
34  public:
37  {
39  TARGET_NONE = 0x00,
41  TARGET_GEOMETRY = 0x01,
43  TARGET_LIGHTS = 0x02,
45  TARGET_ALL = 0xFF
46  };
47 
48  protected:
51  {
53  std::string readableString;
54  std::string typeString;
56  std::set<osg::ExtendedMaterial::EffectTextureLayer> extendedMaterialLayer;
57  std::string effectTexturePostfix;
59  };
60 
61  protected:
62  //protected constructor so it can never be instantiated by accident.
64 
65  //destructor
67 
68  private:
72  DtEffectTextureRegistry &operator=(const DtEffectTextureRegistry &other);
73 
74  public:
75 
77  int effectTextureTypeFromName(const std::string& texName);
78 
80  bool isEffectTexture(const std::string& texName, const std::string& effectTypeCode);
81 
83  bool isEffectTexture(const osg::Texture* tex, const std::string& texName, const std::string& effectTypeCode);
84 
85  // get the name of the texture without path, extension,
86  // underScore(represent the original extension for meif texture)
87  // a/b/c_png.meif => c
88  // a.rgb=>a
89  std::string getTextureNameLessExtension(const std::string& baseFileName);
90 
91  // find the extended name for a texture file.
92  std::string getExtendedFileName(const std::string& baseFileName, const std::string& effectTypeCode);
93 
94  // get the effect texture type given the extended material type
95  int effectTextureTypeFrom(osg::ExtendedMaterial::EffectTextureLayer extendedMaterialLayer);
96 
97  // Given the file name of a base texture, populate the output
98  // vector with possible file names for corresponding effect textures.
99  void getPossibleEffectTextureFileNames(const std::string& baseFileName, std::vector<std::string>& output, const std::string& effectTypeCode);
100 
102  void registerEffectTextureType(int effectTextureType,
103  const std::string& readableString,
104  const std::string& typeString,
105  const std::string& postfix,
106  bool isExtendedMaterialType,
107  const std::set<osg::ExtendedMaterial::EffectTextureLayer>& extendedMaterialLayer = std::set<osg::ExtendedMaterial::EffectTextureLayer>());
108 
110  void registerIndirectShaderEffectTexturetype(int effectTextureType, const DtIndirectEffectTextureShader& indirectEffectTextureShader);
111 
113  bool hasIndirectShaderForType(int effectTextureType) const;
114 
116  DtIndirectEffectTextureShader indirectEffectTextureShaderForType(int effectTextureType) const;
117 
119  std::string toString(int effectTextureType);
121  std::string toDtEffectTextureTypeString(int effectTextureType);
122 
124  std::string toTextureMapNameString(int effectTextureType) const;
125 
127  std::string toTextureCoordNameString(int effectTextureType) const;
128 
130  std::string getTextureArrayPattern(const std::string& effectUnitName);
131 
133  std::string getTextureArrayReplacement(const std::string& effectUnitName);
134 
136  bool isSupportedByExtendedMaterial(int effectTextureType);
137 
140  bool effectTextureInstalled(const std::string& baseTextureName, const osg::StateSet* stateSet, const std::string& effectTypeCode);
141 
143  std::string getTextureFilePathAndSetNameIfNotSet(const osg::Texture* texture, bool doSetName);
144 
146  bool isRemoteTexture(const std::string& texturePath);
147 
150  DtIndirectEffectTexturesTemplate effectTexturesTemplate();
151 
153  void registerShaderEffectTarget(int effectTextureType, EffectTargetMask effectMask);
154 
156  bool supportsTarget(int effectTextureType, EffectTargetMask target) const;
157 
158  public:
159 
161  static DtEffectTextureRegistry& instance(DtDe& de);
162 
163  protected:
164 
165  typedef std::map<int, EffectTextureTypeInfo> IntEffectTextureTypeMap;
167 
168  std::map<int, DtIndirectEffectTextureShader> myMapTypeToFXTextureShader;
169 
170  std::map<int, EffectTargetMask> myMapTypeToEffectMask;
171 
173 
174  boost::shared_mutex myEffectTextureInfoTypeMapMutex;
175 
177 
179  mutable boost::shared_mutex myMutableMapTypeToFxTextureShaderMutex;
180 
181  protected:
183 
184  };
185 }
boost::shared_mutex myMutableMapTypeToFxTextureShaderMutex
mutable so the accessor function for the map can be const.
Definition: DtEffectTextureRegistry.h:179
std::map< int, EffectTextureTypeInfo > IntEffectTextureTypeMap
Definition: DtEffectTextureRegistry.h:165
Contains info about the shader file, execution priority and name of the shader corresponding to a par...
Definition: DtIndirectEffectTextureShader.h:25
Contains makVrv::DtEffectTextureType declaration.
std::string typeString
Definition: DtEffectTextureRegistry.h:54
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::map< int, EffectTargetMask > myMapTypeToEffectMask
Definition: DtEffectTextureRegistry.h:170
static const DtIndirectEffectTextureShader theDummyShader
Definition: DtEffectTextureRegistry.h:182
data only struct for holding information about a particular effect texture type
Definition: DtEffectTextureRegistry.h:50
std::map< int, DtIndirectEffectTextureShader > myMapTypeToFXTextureShader
Definition: DtEffectTextureRegistry.h:168
Contains the DtIndirectEffectTexturesTemplate class declaration.
Contains makVrv::DtVirtualBaseClass class.
class which holds some static utility functions for handling effect textures once we work out how to ...
Definition: DtEffectTextureRegistry.h:32
DtIndirectEffectTexturesTemplate myEffectTexturesTemplate
Definition: DtEffectTextureRegistry.h:176
bool isExtendedMaterialType
Definition: DtEffectTextureRegistry.h:55
Contains the DtIndirectEffectTextureShader class declaration.
EffectTargetMask
Enumeration defining masks which can be used to control Effect texture hookup.
Definition: DtEffectTextureRegistry.h:36
std::string effectTexturePostfix
Definition: DtEffectTextureRegistry.h:57
int effectTextureType
Definition: DtEffectTextureRegistry.h:52
std::set< osg::ExtendedMaterial::EffectTextureLayer > extendedMaterialLayer
Definition: DtEffectTextureRegistry.h:56
EffectTargetMask effectTargetMask
Definition: DtEffectTextureRegistry.h:58
DtDe & myDe
Definition: DtEffectTextureRegistry.h:172
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
std::string readableString
Definition: DtEffectTextureRegistry.h:53
IntEffectTextureTypeMap myEffectTextureTypeInfoMap
Definition: DtEffectTextureRegistry.h:166
boost::shared_mutex myEffectTextureInfoTypeMapMutex
Definition: DtEffectTextureRegistry.h:174

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)