VR-Forces 4.0.4 Class Documentation
include/vrvOsg/DtMergeDuplicateTextureVisitor.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2008 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: DtMergeDuplicateTextureVisitor.h,v $ $Revision: 1.7 $ $State: Exp $
00007 ******************************************************************************/
00008 
00012 
00013 #pragma once
00014 #include <vrvOsg/vrvOsg.h>
00015 #include <vrvOsg/DtOsgFileCache.h>
00016 #include <osg/NodeVisitor>
00017 #include <boost/unordered_map.hpp>
00018 #include <vector>
00019 
00020 namespace makVrv
00021 {
00025    class DT_DLL_VRVOSG DtMergeDuplicateTextureVisitor : public osg::NodeVisitor
00026    {
00027    public:
00028       typedef boost::unordered_map<std::string,osg::ref_ptr<DtOsgFileCache::TextureCollection> > TextureMap;
00029       typedef std::vector<std::pair<std::string,DtOsgFileCache::TextureCollection* > > TextureList;
00030 
00032       DtMergeDuplicateTextureVisitor(
00033          TextureMap& textureMap,
00034          TextureList& textureList,
00035          const std::string& parentFilePath,
00036          bool replaceTexturesWithLoadOnDemandImages,
00037          bool compressTextures,
00038          bool followProxyNodes);
00039 
00041       virtual void apply(osg::Geode& geode);
00042 
00044       virtual void apply(osg::Node& node);
00045 
00047       virtual void apply(osg::StateSet& stateset);
00048 
00050       virtual void apply(osg::ProxyNode& node);
00051 
00053       void clearTextures();
00054 
00055    protected:
00056 
00057       //Attempt to find a duplicate texture. It looks up the texture
00058       //Via the image in the map and returns a valid texture point to a new
00059       //Texture object to replace the original with.
00060       //If no duplicate texture is found the returned texture pointer is NULL.
00061       osg::ref_ptr<osg::Texture> findDuplicateTexture(osg::Texture& texture);
00062 
00063       void processTexture( osg::Texture &texture, const osg::Image* img );
00064 
00065    protected:
00066       std::string myFilePath;
00067       TextureMap& myTextureMapRef;
00068       TextureList& myTextureList;
00069       bool myUnloadImageDataFlag;
00070       bool myCompressTextures;
00071       bool myProcessProxyNodes;
00072    };
00073 }

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)