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);
96 virtual void ts_getTextureInstance(
const std::string& filePath,
97 osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
98 osg::Texture::WrapMode s, osg::Texture::WrapMode t,
99 const LoadFileOptions& loadFileOptions, osg::ref_ptr<osg::Texture>& texture);
102 virtual void encodeOptionsString(
const LoadFileOptions& loadFileOptions,
103 osgDB::ReaderWriter::Options& options)
const;
106 virtual void decodeOptions(
const osgDB::ReaderWriter::Options& options,
107 LoadFileOptions& loadFileOptions)
const;
116 boost::signals2::signal<void (osg::Node*,
const std::string& origFileName,
123 boost::signals2::signal<void (osg::Image*,
const std::string& origFileName,
129 boost::signals2::signal<void (
const std::string& filename,
130 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
136 boost::signals2::signal<void (
const std::string& filename,
137 osgDB::ReaderWriter::ReadResult&,
const osgDB::ReaderWriter::Options*)>
148 unsigned int min : 4;
149 unsigned int max : 4;
150 unsigned int wrap_s : 4;
151 unsigned int wrap_t : 4;
160 TextureList::iterator i = myTextures.begin();
161 TextureList::iterator e = myTextures.end();
164 if(i->second->referenceCount() > 1)
166 replacementList.push_back(*i);
169 if(replacementList.size() != myTextures.size())
171 myTextures.swap(replacementList);
173 return myTextures.size() == 0;
176 void releaseGLObjects()
178 TextureList::iterator i = myTextures.begin();
179 TextureList::iterator e = myTextures.end();
182 i->second->releaseGLObjects();
186 bool findTexture(
unsigned int minFilter,
unsigned int magFilter,
187 unsigned int wrapS,
unsigned wrapT, osg::ref_ptr<osg::Texture>& texture)
190 k.
min = ((minFilter ^ 0x2600) & 0x3) + ((minFilter ^ 0x2600) >> 7);
191 k.
max = ((magFilter ^ 0x2600) & 0x3) + ((magFilter ^ 0x2600) >> 7);
192 k.
wrap_s = (wrapS & 0x0F) | ((wrapS & 0x10) >> 3);
193 k.
wrap_t = (wrapT & 0x0F) | ((wrapT & 0x10) >> 3);
195 TextureList::iterator i = myTextures.begin();
196 TextureList::iterator e = myTextures.end();
199 if(i->first.key == k.
key)
212 pair.first.min = ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) & 0x3) +
213 ((texture->getFilter(osg::Texture::MIN_FILTER) ^ 0x2600) >> 7);
215 pair.first.max = ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) & 0x3) +
216 ((texture->getFilter(osg::Texture::MAG_FILTER) ^ 0x2600) >> 7);
218 pair.first.wrap_s = (texture->getWrap(osg::Texture::WRAP_S) & 0x0F) |
219 ((texture->getWrap(osg::Texture::WRAP_S) & 0x10) >> 3);
221 pair.first.wrap_t = (texture->getWrap(osg::Texture::WRAP_T) & 0x0F) |
222 ((texture->getWrap(osg::Texture::WRAP_T) & 0x10) >> 3);
223 pair.second = texture;
224 myTextures.push_back(pair);
234 friend class DtReadFileCallback;
237 virtual osg::ref_ptr<osg::Node> ts_readNodeFile(
const std::string& inputFilename,
238 const LoadFileOptions& loadFileOptions,
const osg::UserDataContainer *optionsUserData);
241 virtual osg::ref_ptr<osg::Node> ts_findNodeFile(
const std::string& inputFilename );
244 virtual osg::ref_ptr<osg::Image> ts_readImageFile(
const std::string& inputFilename,
248 void ts_encryptImage(
const std::string& inputFileName,
249 const std::string& outputFilename,
bool printToConsole);
252 bool ts_resolveRelativeFilename(
const LoadFileOptions& loadFileOptions,
253 std::string& absoluteInputFilename );
256 virtual void ts_clearInstancingCache();
259 virtual void ts_flushInstancingCache(
bool multipass,
260 bool flushNodes,
bool flushTextures,
bool flushImages);
268 std::string ts_buildAcceleratedFilename(
const std::string& filePathIn,
269 const std::string& cachedDir,
270 const std::string& cachedExtension)
const;
274 virtual bool save(
const std::string& origFilename,
275 const std::string& cachedFilename,
bool optimize);
278 bool shouldSaveFile(
const std::string& filename);
281 bool saveToAcceleratedFile(
const std::string& origFileName,
282 osg::Node* nodeRef,
const std::string& cachedFilename,
283 bool writeExternalReferences);
286 virtual void addMetaFlightOptions(std::string& optionsString);
289 virtual bool needsShaderGeneration(
const std::string& filename,
const LoadFileOptions& options)
const;
292 virtual void updateGlobalOptions();
295 virtual void slot_onDdsFlipChanged(
bool flip);
298 virtual void slot_instancingChanged(
bool enabled);
335 #include <vrvOsg/DtOsgReferencedCollection.inl>