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;
51 virtual void releaseResources()
57 virtual void releaseResources(osg::State* state);
65 static void optimizeNodeGeometry(osg::Node* node);
70 osg::Node* readNodeFile(
const std::string& inputFilename,
71 const LoadFileOptions& loadFileOptions);
75 inline osg::ref_ptr<osg::Node> findNodeFile(
const std::string& inputFilename )
77 return ts_findNodeFile(inputFilename);
83 osg::Image* readImageFile(
const std::string& inputFilename,
84 const LoadFileOptions& loadFileOptions);
88 virtual osg::Texture* getTextureInstance(
const std::string& filePath,
89 osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
90 osg::Texture::WrapMode s, osg::Texture::WrapMode t,
91 const LoadFileOptions& loadFileOptions);
94 virtual void encodeOptionsString(
const LoadFileOptions& loadFileOptions,
95 osgDB::ReaderWriter::Options& options)
const;
98 virtual void decodeOptions(
const osgDB::ReaderWriter::Options& options,
99 LoadFileOptions& loadFileOptions)
const;
108 boost::signals2::signal<void (osg::Node*,
const std::string& origFileName,
115 boost::signals2::signal<void (osg::Image*,
const std::string& origFileName,
121 boost::signals2::signal<void (
const std::string& filename,
122 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
128 boost::signals2::signal<void (
const std::string& filename,
129 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
140 unsigned int min : 4;
141 unsigned int max : 4;
142 unsigned int wrap_s : 4;
143 unsigned int wrap_t : 4;
152 TextureList::iterator i = myTextures.begin();
153 TextureList::iterator e = myTextures.end();
156 if(i->second->referenceCount() > 1)
158 replacementList.push_back(*i);
161 if(replacementList.size() != myTextures.size())
163 myTextures.swap(replacementList);
165 return myTextures.size() == 0;
168 void releaseGLObjects()
170 TextureList::iterator i = myTextures.begin();
171 TextureList::iterator e = myTextures.end();
174 i->second->releaseGLObjects();
178 bool findTexture(
unsigned int minFilter,
unsigned int magFilter,
179 unsigned int wrapS,
unsigned wrapT, osg::ref_ptr<osg::Texture>& texture)
182 k.
min = ((minFilter ^ 0x2600) & 0x3) + ((minFilter ^ 0x2600) >> 7);
183 k.
max = ((magFilter ^ 0x2600) & 0x3) + ((magFilter ^ 0x2600) >> 7);
184 k.
wrap_s = (wrapS & 0x0F) | ((wrapS & 0x10) >> 3);
185 k.
wrap_t = (wrapT & 0x0F) | ((wrapT & 0x10) >> 3);
187 TextureList::iterator i = myTextures.begin();
188 TextureList::iterator e = myTextures.end();
191 if(i->first.key == k.
key)
204 pair.first.min = ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) & 0x3) +
205 ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) >> 7);
207 pair.first.max = ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) & 0x3) +
208 ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) >> 7);
210 pair.first.wrap_s = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
211 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
213 pair.first.wrap_t = (texture->getWrap(osg::Texture::WRAP_T) & 0x0F) |
214 ((texture->getWrap(osg::Texture::WRAP_T) & 0x10) >> 3);
215 pair.second = texture;
216 myTextures.push_back(pair);
226 friend class DtReadFileCallback;
229 virtual osg::ref_ptr<osg::Node> ts_readNodeFile(
const std::string& inputFilename,
233 virtual osg::ref_ptr<osg::Node> ts_findNodeFile(
const std::string& inputFilename );
236 virtual osg::ref_ptr<osg::Image> ts_readImageFile(
const std::string& inputFilename,
240 void ts_encryptImage(
const std::string& inputFileName,
241 const std::string& outputFilename,
bool printToConsole);
244 bool ts_resolveRelativeFilename(
const LoadFileOptions& loadFileOptions,
245 std::string& absoluteInputFilename );
248 virtual void ts_clearInstancingCache();
251 virtual void ts_flushInstancingCache(
bool multipass,
252 bool flushNodes,
bool flushTextures,
bool flushImages);
260 std::string ts_buildAcceleratedFilename(
const std::string& filePathIn,
261 const std::string& cachedDir,
262 const std::string& cachedExtension)
const;
266 virtual bool save(
const std::string& origFilename,
267 const std::string& cachedFilename,
bool optimize);
270 bool shouldSaveFile(
const std::string& filename);
273 bool saveToAcceleratedFile(
const std::string& origFileName,
274 osg::Node* nodeRef,
const std::string& cachedFilename,
275 bool writeExternalReferences);
278 virtual void addMetaFlightOptions(std::string& optionsString);
281 virtual bool needsShaderGeneration(
const std::string& filename,
const LoadFileOptions& options)
const;
284 virtual void updateGlobalOptions();
287 virtual void slot_onDdsFlipChanged(
bool flip);
290 virtual void slot_instancingChanged(
bool enabled);
327 #include <vrvOsg/DtOsgReferencedCollection.inl>