18 #include <osgDB/ReaderWriter>
20 #include <boost/unordered_map.hpp>
21 #include <boost/unordered_set.hpp>
22 #include <osgDB/ReaderWriter>
24 #include <boost/thread/mutex.hpp>
25 #include <boost/signals2.hpp>
30 class GraphicsContext;
37 class DtMeifConverter;
55 virtual void releaseResources()
61 virtual void releaseResources(osg::State* state);
66 osg::Node* readNodeFile(
const std::string& inputFilename,
67 const LoadFileOptions& loadFileOptions);
71 inline osg::ref_ptr<osg::Node> findNodeFile(
const std::string& inputFilename )
73 return ts_findNodeFile(inputFilename);
79 osg::Image* readImageFile(
const std::string& inputFilename,
80 const LoadFileOptions& loadFileOptions);
84 virtual osg::Texture* getTextureInstance(
const std::string& filePath,
85 osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
86 osg::Texture::WrapMode s, osg::Texture::WrapMode t,
87 const LoadFileOptions& loadFileOptions);
90 virtual void encodeOptionsString(
const LoadFileOptions& loadFileOptions,
91 osgDB::ReaderWriter::Options& options)
const;
94 virtual void decodeOptions(
const osgDB::ReaderWriter::Options& options,
95 LoadFileOptions& loadFileOptions)
const;
101 boost::signals2::signal<void (osg::Node*,
const std::string& origFileName,
108 boost::signals2::signal<void (osg::Image*,
const std::string& origFileName,
114 boost::signals2::signal<void (
const std::string& filename,
115 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
121 boost::signals2::signal<void (
const std::string& filename,
122 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
133 unsigned int min : 4;
134 unsigned int max : 4;
135 unsigned int wrap_s : 4;
136 unsigned int wrap_t : 4;
145 TextureList::iterator i = myTextures.begin();
146 TextureList::iterator e = myTextures.end();
149 if(i->second->referenceCount() > 1)
151 replacementList.push_back(*i);
154 if(replacementList.size() != myTextures.size())
156 myTextures.swap(replacementList);
158 return myTextures.size() == 0;
161 void releaseGLObjects()
163 TextureList::iterator i = myTextures.begin();
164 TextureList::iterator e = myTextures.end();
167 i->second->releaseGLObjects();
171 bool findTexture(
unsigned int minFilter,
unsigned int magFilter,
172 unsigned int wrapS,
unsigned wrapT, osg::ref_ptr<osg::Texture>& texture)
175 k.
min = ((minFilter ^ 0x2600) & 0x3) + ((minFilter ^ 0x2600) >> 7);
176 k.
max = ((magFilter ^ 0x2600) & 0x3) + ((magFilter ^ 0x2600) >> 7);
177 k.
wrap_s = (wrapS & 0x0F) | ((wrapS & 0x10) >> 3);
178 k.
wrap_t = (wrapT & 0x0F) | ((wrapT & 0x10) >> 3);
180 TextureList::iterator i = myTextures.begin();
181 TextureList::iterator e = myTextures.end();
184 if(i->first.key == k.
key)
196 pair.first.min = ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) & 0x3) +
197 ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) >> 7);
199 pair.first.max = ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) & 0x3) +
200 ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) >> 7);
202 pair.first.wrap_s = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
203 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
205 pair.first.wrap_t = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
206 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
207 pair.second = texture;
208 myTextures.push_back(pair);
221 virtual osg::ref_ptr<osg::Node> ts_readNodeFile(
const std::string& inputFilename,
225 virtual osg::ref_ptr<osg::Node> ts_findNodeFile(
const std::string& inputFilename );
228 virtual osg::ref_ptr<osg::Image> ts_readImageFile(
const std::string& inputFilename,
232 void ts_encryptImage(
const std::string& inputFileName,
233 const std::string& outputFilename,
bool printToConsole);
236 bool ts_resolveRelativeFilename(
const LoadFileOptions& loadFileOptions,
237 std::string& absoluteInputFilename );
240 virtual void ts_clearInstancingCache();
243 virtual void ts_flushInstancingCache(
bool multipass,
244 bool flushNodes,
bool flushTextures,
bool flushImages);
252 std::string ts_buildAcceleratedFilename(
const std::string& filePathIn,
253 const std::string& cachedDir,
254 const std::string& cachedExtension)
const;
258 virtual bool save(
const std::string& origFilename,
259 const std::string& cachedFilename,
bool optimize);
262 bool shouldSaveFile(
const std::string& filename);
265 bool saveToAcceleratedFile(
const std::string& origFileName,
266 osg::Node* nodeRef,
const std::string& cachedFilename,
267 bool writeExternalReferences);
270 virtual void addMetaFlightOptions(std::string& optionsString);
303 #include <vrvOsg/DtOsgReferencedCollection.inl>