15 #include <osgDB/ReaderWriter>
17 #include <boost/unordered_map.hpp>
18 #include <boost/unordered_set.hpp>
19 #include <osgDB/ReaderWriter>
21 #include <boost/thread/mutex.hpp>
22 #include <boost/signals2.hpp>
27 class GraphicsContext;
34 class DtMeifConverter;
35 class DtMetaFileManager;
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);
96 virtual void encodeOptionsString(
const LoadFileOptions& loadFileOptions,
97 osgDB::ReaderWriter::Options& options)
const;
100 virtual void decodeOptions(
const osgDB::ReaderWriter::Options& options,
101 LoadFileOptions& loadFileOptions)
const;
110 boost::signals2::signal<void (osg::Node*,
const std::string& origFileName,
117 boost::signals2::signal<void (osg::Image*,
const std::string& origFileName,
123 boost::signals2::signal<void (
const std::string& filename,
124 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
130 boost::signals2::signal<void (
const std::string& filename,
131 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
142 unsigned int min : 4;
143 unsigned int max : 4;
144 unsigned int wrap_s : 4;
145 unsigned int wrap_t : 4;
154 TextureList::iterator i = myTextures.begin();
155 TextureList::iterator e = myTextures.end();
158 if(i->second->referenceCount() > 1)
160 replacementList.push_back(*i);
163 if(replacementList.size() != myTextures.size())
165 myTextures.swap(replacementList);
167 return myTextures.size() == 0;
170 void releaseGLObjects()
172 TextureList::iterator i = myTextures.begin();
173 TextureList::iterator e = myTextures.end();
176 i->second->releaseGLObjects();
180 bool findTexture(
unsigned int minFilter,
unsigned int magFilter,
181 unsigned int wrapS,
unsigned wrapT, osg::ref_ptr<osg::Texture>& texture)
184 k.
min = ((minFilter ^ 0x2600) & 0x3) + ((minFilter ^ 0x2600) >> 7);
185 k.
max = ((magFilter ^ 0x2600) & 0x3) + ((magFilter ^ 0x2600) >> 7);
186 k.
wrap_s = (wrapS & 0x0F) | ((wrapS & 0x10) >> 3);
187 k.
wrap_t = (wrapT & 0x0F) | ((wrapT & 0x10) >> 3);
189 TextureList::iterator i = myTextures.begin();
190 TextureList::iterator e = myTextures.end();
193 if(i->first.key == k.
key)
205 pair.first.min = ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) & 0x3) +
206 ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) >> 7);
208 pair.first.max = ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) & 0x3) +
209 ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) >> 7);
211 pair.first.wrap_s = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
212 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
214 pair.first.wrap_t = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
215 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
216 pair.second = texture;
217 myTextures.push_back(pair);
227 friend class DtReadFileCallback;
230 virtual osg::ref_ptr<osg::Node> ts_readNodeFile(
const std::string& inputFilename,
234 virtual osg::ref_ptr<osg::Node> ts_findNodeFile(
const std::string& inputFilename );
237 virtual osg::ref_ptr<osg::Image> ts_readImageFile(
const std::string& inputFilename,
241 void ts_encryptImage(
const std::string& inputFileName,
242 const std::string& outputFilename,
bool printToConsole);
245 bool ts_resolveRelativeFilename(
const LoadFileOptions& loadFileOptions,
246 std::string& absoluteInputFilename );
249 virtual void ts_clearInstancingCache();
252 virtual void ts_flushInstancingCache(
bool multipass,
253 bool flushNodes,
bool flushTextures,
bool flushImages);
261 std::string ts_buildAcceleratedFilename(
const std::string& filePathIn,
262 const std::string& cachedDir,
263 const std::string& cachedExtension)
const;
267 virtual bool save(
const std::string& origFilename,
268 const std::string& cachedFilename,
bool optimize);
271 bool shouldSaveFile(
const std::string& filename);
274 bool saveToAcceleratedFile(
const std::string& origFileName,
275 osg::Node* nodeRef,
const std::string& cachedFilename,
276 bool writeExternalReferences);
279 virtual void addMetaFlightOptions(std::string& optionsString);
282 virtual bool needsShaderGeneration(
const std::string& filename,
const LoadFileOptions& options)
const;
316 #include <vrvOsg/DtOsgReferencedCollection.inl>