15 #include <osgDB/ReaderWriter>
17 #include <osgDB/ReaderWriter>
19 #include <boost/signals2.hpp>
24 class GraphicsContext;
31 class DtMeifConverter;
32 class DtMetaFileManager;
33 class DtOsgShaderManager;
34 class DtOsgShaderFilesCache;
35 class DtEffectControllerFactory;
53 virtual void releaseResources()
59 virtual void releaseResources(osg::State* state);
67 static void optimizeNodeGeometry(osg::Node* node);
72 osg::Node* readNodeFile(
const std::string& inputFilename,
73 const LoadFileOptions& loadFileOptions);
77 inline osg::ref_ptr<osg::Node> findNodeFile(
const std::string& inputFilename )
79 return ts_findNodeFile(inputFilename);
85 osg::Image* readImageFile(
const std::string& inputFilename,
86 const LoadFileOptions& loadFileOptions);
90 virtual osg::Texture* getTextureInstance(
const std::string& filePath,
91 osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
92 osg::Texture::WrapMode s, osg::Texture::WrapMode t,
93 const LoadFileOptions& loadFileOptions);
98 virtual void ts_getTextureInstance(
const std::string& filePath,
99 osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
100 osg::Texture::WrapMode s, osg::Texture::WrapMode t,
101 const LoadFileOptions& loadFileOptions, osg::ref_ptr<osg::Texture>& texture);
104 virtual void encodeOptionsString(
const LoadFileOptions& loadFileOptions,
105 osgDB::ReaderWriter::Options& options)
const;
108 virtual void decodeOptions(
const osgDB::ReaderWriter::Options& options,
109 LoadFileOptions& loadFileOptions)
const;
118 boost::signals2::signal<void (osg::Node*,
const std::string& origFileName,
125 boost::signals2::signal<void (osg::Image*,
const std::string& origFileName,
131 boost::signals2::signal<void (
const std::string&
filename,
132 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
138 boost::signals2::signal<void (
const std::string&
filename,
139 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
150 unsigned int min : 4;
151 unsigned int max : 4;
152 unsigned int wrap_s : 4;
153 unsigned int wrap_t : 4;
162 TextureList::iterator i = myTextures.begin();
163 TextureList::iterator e = myTextures.end();
166 if(i->second->referenceCount() > 1)
168 replacementList.push_back(*i);
171 if(replacementList.size() != myTextures.size())
173 myTextures.swap(replacementList);
175 return myTextures.size() == 0;
178 void releaseGLObjects()
180 TextureList::iterator i = myTextures.begin();
181 TextureList::iterator e = myTextures.end();
184 i->second->releaseGLObjects();
188 bool findTexture(
unsigned int minFilter,
unsigned int magFilter,
189 unsigned int wrapS,
unsigned wrapT, osg::ref_ptr<osg::Texture>& texture)
192 k.
min = ((minFilter ^ 0x2600) & 0x3) + ((minFilter ^ 0x2600) >> 7);
193 k.
max = ((magFilter ^ 0x2600) & 0x3) + ((magFilter ^ 0x2600) >> 7);
194 k.
wrap_s = (wrapS & 0x0F) | ((wrapS & 0x10) >> 3);
195 k.
wrap_t = (wrapT & 0x0F) | ((wrapT & 0x10) >> 3);
197 TextureList::iterator i = myTextures.begin();
198 TextureList::iterator e = myTextures.end();
201 if(i->first.key == k.
key)
214 pair.first.min = ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) & 0x3) +
215 ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) >> 7);
217 pair.first.max = ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) & 0x3) +
218 ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) >> 7);
220 pair.first.wrap_s = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
221 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
223 pair.first.wrap_t = (texture->getWrap(osg::Texture::WRAP_T) & 0x0F) |
224 ((texture->getWrap(osg::Texture::WRAP_T) & 0x10) >> 3);
225 pair.second = texture;
226 myTextures.push_back(pair);
237 return myShaderManager;
242 return myShaderManager;
247 return myShaderFilesCache;
252 return myEffectControllerFactory;
257 friend class DtReadFileCallback;
260 virtual osg::ref_ptr<osg::Node> ts_readNodeFile(
const std::string& inputFilename,
261 const LoadFileOptions& loadFileOptions,
const osg::UserDataContainer *optionsUserData);
264 virtual osg::ref_ptr<osg::Node> ts_findNodeFile(
const std::string& inputFilename );
267 virtual osg::ref_ptr<osg::Image> ts_readImageFile(
const std::string& inputFilename,
269 const osg::UserDataContainer* optionsUserData =0L);
272 void ts_encryptImage(
const std::string& inputFileName,
273 const std::string& outputFilename,
const osgDB::ReaderWriter::Options* options,
bool printToConsole);
276 bool ts_resolveRelativeFilename(
const LoadFileOptions& loadFileOptions,
277 std::string& absoluteInputFilename );
280 virtual void ts_clearInstancingCache();
283 virtual void ts_flushInstancingCache(
bool multipass,
284 bool flushNodes,
bool flushTextures,
bool flushImages);
292 std::string ts_buildAcceleratedFilename(
const std::string& filePathIn,
293 const std::string& cachedDir,
294 const std::string& cachedExtension)
const;
298 virtual bool save(
const std::string& origFilename,
299 const std::string& cachedFilename,
bool optimize);
302 bool shouldSaveFile(
const std::string&
filename);
305 bool saveToAcceleratedFile(
const std::string& origFileName,
306 osg::Node* nodeRef,
const std::string& cachedFilename,
307 bool writeExternalReferences);
310 virtual void addMetaFlightOptions(std::string& optionsString);
316 virtual void updateGlobalOptions();
319 virtual void slot_onDdsFlipChanged(
bool flip);
322 virtual void slot_instancingChanged(
bool enabled);
363 #include <vrvOsg/DtOsgReferencedCollection.inl>