[Aqsis-commits] SF.net SVN: aqsis: [1937] branches/texfiltering/aqsis
Brought to you by:
ltatkinson,
pgregory
From: <c4...@us...> - 2008-02-22 08:15:03
|
Revision: 1937 http://aqsis.svn.sourceforge.net/aqsis/?rev=1937&view=rev Author: c42f Date: 2008-02-22 00:15:06 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Reimplement the SO_textureinfo() function using the new texture library. * Implement a CqTextureCache::textureInfo() function which returns *all* the texture file attributes, wrapped up in a header. This means that SO_textureinfo() is immediately and trivially extensable. * Modify CqTextureCache to cache the underlying texture files, not just the texture samplers. This means that the same file handle will always be used, no matter how a particular texture file is sampled. * Add an image file attribute, Attr::TextureFormat for holding the texture file type. * Implement a CqTextureCache::flush() function for flushing the cache. * Implement a callthrough function IqRenderer::textureInfo(). On second thoughts the texture access should be refactored so that CqRenderer just returns a reference to the current texture cache, but this will be done later. Modified Paths: -------------- branches/texfiltering/aqsis/interfaces/irenderer.h branches/texfiltering/aqsis/renderer/render/renderer.cpp branches/texfiltering/aqsis/renderer/render/renderer.h branches/texfiltering/aqsis/shadercompiler/shaderexecenv/shadeops_tmap.cpp branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h branches/texfiltering/aqsis/texturing/texlib/texturecache.cpp branches/texfiltering/aqsis/texturing/texlib/texturecache.h branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp Modified: branches/texfiltering/aqsis/interfaces/irenderer.h =================================================================== --- branches/texfiltering/aqsis/interfaces/irenderer.h 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/interfaces/irenderer.h 2008-02-22 08:15:06 UTC (rev 1937) @@ -20,6 +20,7 @@ class IqTextureSampler; class IqShadowSampler; class CqObjectInstance; +class CqTexFileHeader; struct IqRenderer { @@ -54,10 +55,9 @@ */ virtual void PrintString( const char* str ) = 0; - /* - * Access to the texture map handling component - */ - + //-------------------------------------------------- + /// \name Texture map access + //@{ /** \brief Get a reference to a texture sampler. * * Failure to load the texture from a file will result in a dummy texture @@ -68,11 +68,34 @@ */ virtual const IqTextureSampler& GetTextureMap(const char* fileName) = 0; virtual IqTextureMapOld* GetEnvironmentMap( const CqString& fileName ) = 0; + /** \brief Get a reference to a shadow texture sampler. + * + * Failure to load the texture from a file will result in a dummy shadow + * sampler object being returned. + * + * \param fileName - File name to search for in the texture resource path. + * \return the texture sampler (always valid). + */ virtual const IqShadowSampler& GetShadowMap(const char* fileName) = 0; virtual IqTextureMapOld* GetOcclusionMap( const CqString& fileName ) = 0; virtual IqTextureMapOld* GetLatLongMap( const CqString& fileName ) = 0; + /** \brief Obtain texture file metadata for the given file name. + * + * \return Pointer to a texture file header, or 0 if the texture file + * cannot be found in the current search path. + */ + virtual const CqTexFileHeader* textureInfo(const char* fileName) = 0; + //@} + /** \brief Return the current texture search path. + * + * This is used as a callback function by the texture library to obtain + * the texture search path when necessary. + */ + virtual const char* textureSearchPath() = 0; + + virtual bool GetBasisMatrix( CqMatrix& matBasis, const CqString& name ) = 0; virtual TqInt RegisterOutputData( const char* name ) = 0; Modified: branches/texfiltering/aqsis/renderer/render/renderer.cpp =================================================================== --- branches/texfiltering/aqsis/renderer/render/renderer.cpp 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/renderer/render/renderer.cpp 2008-02-22 08:15:06 UTC (rev 1937) @@ -1674,6 +1674,7 @@ const IqShadowSampler& CqRenderer::GetShadowMap(const char* fileName) { /// \todo Inefficient - correct this later. + /// \todo What is the correct coordinate system to use here? "shader"? CqMatrix camToWorldMatrix; QGetRenderContext() ->matSpaceToSpace("camera", "world", NULL, NULL, 0, camToWorldMatrix); m_textureCache.setCamToWorldMatrix(camToWorldMatrix); @@ -1691,6 +1692,11 @@ return ( CqTextureMapOld::GetLatLongMap( strFileName ) ); } +const CqTexFileHeader* CqRenderer::textureInfo(const char* fileName) +{ + return m_textureCache.textureInfo(fileName); +} + const char* CqRenderer::textureSearchPath() { const CqString* pathPtr = poptCurrent()->GetStringOption("searchpath", "texture"); Modified: branches/texfiltering/aqsis/renderer/render/renderer.h =================================================================== --- branches/texfiltering/aqsis/renderer/render/renderer.h 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/renderer/render/renderer.h 2008-02-22 08:15:06 UTC (rev 1937) @@ -207,13 +207,9 @@ virtual const IqShadowSampler& GetShadowMap(const char* fileName); virtual IqTextureMapOld* GetOcclusionMap(const CqString& fileName); virtual IqTextureMapOld* GetLatLongMap( const CqString& strFileName ); + virtual const CqTexFileHeader* textureInfo(const char* fileName); - /** \brief Return the current texture search path. - * - * This is used as a callback function by the texture library to obtain - * the texture search path when necessary. - */ - const char* textureSearchPath(); + virtual const char* textureSearchPath(); virtual bool GetBasisMatrix( CqMatrix& matBasis, const CqString& name ); Modified: branches/texfiltering/aqsis/shadercompiler/shaderexecenv/shadeops_tmap.cpp =================================================================== --- branches/texfiltering/aqsis/shadercompiler/shaderexecenv/shadeops_tmap.cpp 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/shadercompiler/shaderexecenv/shadeops_tmap.cpp 2008-02-22 08:15:06 UTC (rev 1937) @@ -40,6 +40,7 @@ #include "itexturemap_old.h" /// \todo remove after migration to new interface #include "itexturesampler.h" #include "ishadowsampler.h" +#include "texfileheader.h" #include "version.h" #include "logging.h" @@ -1537,269 +1538,82 @@ } //---------------------------------------------------------------------- -// textureinfo -// support resolution, type, channels, projectionmatrix(*) and viewingmatrix(*) -// User has to provide an array of TqFloat (2) for resolution -// an string for type -// an integer for channels -// an array of floats (16) for both projectionmatrix and viewingmatrix -// (*) the name must be a shadow map -// - -void CqShaderExecEnv::SO_textureinfo( IqShaderData* name, IqShaderData* dataname, IqShaderData* pV, IqShaderData* Result, IqShader* pShader ) +// textureinfo(texturename, dataname, output variable); +void CqShaderExecEnv::SO_textureinfo( IqShaderData* name, IqShaderData* dataName, IqShaderData* pV, IqShaderData* result, IqShader* pShader ) { - TqUint __iGrid; - - if ( !getRenderContext() ) - return ; - - TqFloat Ret = 0.0f; - //IqTextureMapPtr pMap; - IqTextureMapOld* pMap = NULL; - IqTextureMapOld *pSMap = NULL; - IqTextureMapOld *pEMap = NULL; - IqTextureMapOld *pTMap = NULL; - - __iGrid = 0; - CqString _aq_name; - (name)->GetString(_aq_name,__iGrid); - CqString _aq_dataname; - (dataname)->GetString(_aq_dataname,__iGrid); - - if ( !pMap && strstr( _aq_name.c_str(), ".tif" ) ) + if(!getRenderContext()) { - /// \todo Fix to work with the new type returned from GetTextureMap - //pTMap = getRenderContext() ->GetTextureMap( _aq_name ); - if ( pTMap && ( pTMap->Type() == MapType_Texture ) ) - { - pMap = pTMap; - } - else if ( pTMap ) - { - //delete pTMap; - pTMap = NULL; - } + // \todo Is this check necessary? + return; } - if ( !pMap ) - { - //pSMap = getRenderContext() ->GetShadowMap( _aq_name ); - if ( pSMap && ( pSMap->Type() == MapType_Shadow ) ) - { - pMap = pSMap; - } - else if ( pSMap ) - { - //delete pSMap; - pSMap = NULL; - } - } - if ( !pMap ) + // Name of the texture file. + CqString textureName; + name->GetString(textureName, 0); + const CqTexFileHeader* header = getRenderContext()->textureInfo(textureName.c_str()); + if(!header) { - pEMap = getRenderContext() ->GetEnvironmentMap( _aq_name ); - if ( pEMap && ( pEMap->Type() == MapType_Environment ) ) - { - pMap = pEMap; - } - else if ( pEMap ) - { - //delete pEMap; - pEMap = NULL; - } + // Texture not found - return 0. + result->SetFloat(0); + return; } - if ( !pMap ) - { - /// \todo Fix to work with the new type returned from GetTextureMap - //pTMap = getRenderContext() ->GetTextureMap( _aq_name ); - if ( pTMap && ( pTMap->Type() == MapType_Texture ) ) - { - pMap = pTMap; - } - else if ( pTMap ) - { - //delete pTMap; - pTMap = NULL; - } - } + // Name identifying the texture attribute desired. + CqString dataNameStr; + dataName->GetString(dataNameStr, 0); - - if ( pMap == 0 ) + TqFloat returnVal = 0; + if(dataNameStr == "exists" && pV->Type() == type_float) { - (Result)->SetFloat(Ret,__iGrid); - return ; + pV->SetFloat(1); + returnVal = 1; } - - if ( _aq_dataname.compare( "exists" ) == 0 ) + else if(dataNameStr == "resolution" && pV->Type() == type_float + && pV->ArrayLength() == 2) { - if ( pV->Type() == type_float ) - { - pV->SetFloat( 1.0f ); - Ret = 1.0f; - } + pV->ArrayEntry(0)->SetFloat(header->width()); + pV->ArrayEntry(1)->SetFloat(header->height()); + returnVal = 1; } - - if ( _aq_dataname.compare( "resolution" ) == 0 ) + else if(dataNameStr == "type" && pV->Type() == type_string) { - if ( pV->Type() == type_float && - pV->ArrayLength() > 0 ) + const std::string* texFormat = header->findPtr<Attr::TextureFormat>(); + if(texFormat) { - - if ( pV->ArrayLength() == 2 ) - { - pV->ArrayEntry( 0 ) ->SetFloat( static_cast<TqFloat>( pMap->XRes() ) ); - pV->ArrayEntry( 1 ) ->SetFloat( static_cast<TqFloat>( pMap->YRes() ) ); - Ret = 1.0f; - - } + pV->SetString(*texFormat); + returnVal = 1; } } - if ( _aq_dataname.compare( "type" ) == 0 ) + else if(dataNameStr == "channels" && pV->Type() == type_float) { - if ( pV->Type() == type_string ) - { - if ( pMap->Type() == MapType_Texture ) - { - pV->SetString( "texture" ); - Ret = 1.0f; - - } - if ( pMap->Type() == MapType_Bump ) - { - pV->SetString( "bump" ); - Ret = 1.0f; - - } - - if ( pMap->Type() == MapType_Shadow ) - { - pV->SetString( "shadow" ); - Ret = 1.0f; - - } - if ( pMap->Type() == MapType_Environment ) - { - pV->SetString( "environment" ); - Ret = 1.0f; - - } - if ( pMap->Type() == MapType_LatLong ) - { - // both latlong/cube respond the same way according to BMRT - // It makes sense since both use environment() shader fct. - pV->SetString( "environment" ); - Ret = 1.0f; - - } - - - } + pV->SetFloat(header->channelList().numChannels()); + returnVal = 1; } - - if ( _aq_dataname.compare( "channels" ) == 0 ) + else if(dataNameStr == "viewingmatrix" && pV->Type() == type_matrix) { - if ( pV->Type() == type_float ) + const CqMatrix* worldToLight = header->findPtr<Attr::WorldToCameraMatrix>(); + if(worldToLight) { - pV->SetFloat( static_cast<TqFloat>( pMap->SamplesPerPixel() ) ); - Ret = 1.0f; + CqMatrix currToWorld; + getRenderContext()->matSpaceToSpace("current", "world", + NULL, NULL, 0, currToWorld); + pV->SetMatrix((*worldToLight)*currToWorld); + returnVal = 1; } - } - - if ( _aq_dataname.compare( "viewingmatrix" ) == 0 ) + else if(dataNameStr == "projectionmatrix" && pV->Type() == type_matrix) { - if ( ( ( pV->Type() == type_float ) && ( pV->ArrayLength() == 16 ) ) || - ( pV->Type() == type_matrix ) ) + const CqMatrix* worldToLightNdc = header->findPtr<Attr::WorldToScreenMatrix>(); + if(worldToLightNdc) { - IqTextureMapOld* pTmp = NULL; - if (pTMap) pTmp = pTMap; - if (pSMap) pTmp = pSMap; - if ( pTmp ) // && pTmp->Type() == MapType_Shadow) - { - - - CqMatrix m = pTmp->GetMatrix( 0 ); /* WorldToCamera */ - if ( pV->ArrayLength() == 16 ) - { - - pV->ArrayEntry( 0 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 0 ] ) ); - pV->ArrayEntry( 1 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 1 ] ) ); - pV->ArrayEntry( 2 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 2 ] ) ); - pV->ArrayEntry( 3 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 3 ] ) ); - pV->ArrayEntry( 4 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 0 ] ) ); - pV->ArrayEntry( 5 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 1 ] ) ); - pV->ArrayEntry( 6 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 2 ] ) ); - pV->ArrayEntry( 7 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 3 ] ) ); - pV->ArrayEntry( 8 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 0 ] ) ); - pV->ArrayEntry( 9 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 1 ] ) ); - pV->ArrayEntry( 10 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 2 ] ) ); - pV->ArrayEntry( 11 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 3 ] ) ); - pV->ArrayEntry( 12 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 0 ] ) ); - pV->ArrayEntry( 13 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 1 ] ) ); - pV->ArrayEntry( 14 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 2 ] ) ); - pV->ArrayEntry( 15 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 3 ] ) ); - - } - else - { - pV->SetMatrix( m, 0 ); - } - Ret = 1.0f; - - } - + CqMatrix currToWorld; + getRenderContext()->matSpaceToSpace("current", "world", + NULL, NULL, 0, currToWorld); + pV->SetMatrix((*worldToLightNdc)*currToWorld); + returnVal = 1; } } - - if ( _aq_dataname.compare( "projectionmatrix" ) == 0 ) - { - if ( ( ( pV->Type() == type_float ) && ( pV->ArrayLength() == 16 ) ) || - ( pV->Type() == type_matrix ) ) - { - // init the matrix in case of wrong sl logic - IqTextureMapOld* pTmp = NULL; - if (pTMap) pTmp = pTMap; - if (pSMap) pTmp = pSMap; - if ( pTmp ) // && pTmp->Type() == MapType_Shadow) - { - - CqMatrix m = pTmp->GetMatrix( 1 ); /* WorldToScreen */ - if ( pV->ArrayLength() == 16 ) - { - pV->ArrayEntry( 0 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 0 ] ) ); - pV->ArrayEntry( 1 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 1 ] ) ); - pV->ArrayEntry( 2 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 2 ] ) ); - pV->ArrayEntry( 3 ) ->SetFloat( static_cast<TqFloat>( m[ 0 ][ 3 ] ) ); - pV->ArrayEntry( 4 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 0 ] ) ); - pV->ArrayEntry( 5 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 1 ] ) ); - pV->ArrayEntry( 6 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 2 ] ) ); - pV->ArrayEntry( 7 ) ->SetFloat( static_cast<TqFloat>( m[ 1 ][ 3 ] ) ); - pV->ArrayEntry( 8 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 0 ] ) ); - pV->ArrayEntry( 9 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 1 ] ) ); - pV->ArrayEntry( 10 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 2 ] ) ); - pV->ArrayEntry( 11 ) ->SetFloat( static_cast<TqFloat>( m[ 2 ][ 3 ] ) ); - pV->ArrayEntry( 12 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 0 ] ) ); - pV->ArrayEntry( 13 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 1 ] ) ); - pV->ArrayEntry( 14 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 2 ] ) ); - pV->ArrayEntry( 15 ) ->SetFloat( static_cast<TqFloat>( m[ 3 ][ 3 ] ) ); - - - } - else - { - pV->SetMatrix( m, 0 ); - - } - Ret = 1.0f; - } - - } - } - - //delete pMap; - - (Result)->SetFloat(Ret,__iGrid); - + result->SetFloat(returnVal); } //--------------------------------------------------------------------- Modified: branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h 2008-02-22 08:15:06 UTC (rev 1937) @@ -130,7 +130,11 @@ // date and time of creation AQSIS_IMAGE_ATTR_TAG(DateTime, std::string); // texture wrap modes + /// \todo Make this a special purpose type. AQSIS_IMAGE_ATTR_TAG(WrapModes, std::string); + // texture format (one of "texture" "shadow" or "environment" ? ) + /// \todo Decide on standard names for these. + AQSIS_IMAGE_ATTR_TAG(TextureFormat, std::string); //-------------------------------------------------- /// Transformation matrices Modified: branches/texfiltering/aqsis/texturing/texlib/texturecache.cpp =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/texturecache.cpp 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/texturing/texlib/texturecache.cpp 2008-02-22 08:15:06 UTC (rev 1937) @@ -43,6 +43,7 @@ CqTextureCache::CqTextureCache(TqSearchPathCallback searchPathCallback) : m_textureCache(), m_shadowCache(), + m_texFileCache(), m_camToWorld(), m_searchPathCallback(searchPathCallback) { } @@ -57,13 +58,27 @@ return findSampler(m_shadowCache, name); } -CqTexFileHeader* CqTextureCache::textureInfo(const char* texName) +void CqTextureCache::flush() { - /// \todo Return something sensible here. - assert(0); - return 0; + m_textureCache.clear(); + m_shadowCache.clear(); + m_texFileCache.clear(); } +const CqTexFileHeader* CqTextureCache::textureInfo(const char* name) +{ + boost::shared_ptr<IqMultiTexInputFile> file; + try + { + file = getTextureFile(name); + return &(file->header()); + } + catch(XqInvalidFile& e) + { + return 0; + } +} + void CqTextureCache::setCamToWorldMatrix(const CqMatrix& camToWorld) { m_camToWorld = camToWorld; @@ -91,8 +106,8 @@ boost::shared_ptr<SamplerT> newTex; try { - newTex = newSamplerFromFile<SamplerT>( - findFileInPath(name, m_searchPathCallback()).c_str() ); + // Find the file in the current file cache. + newTex = newSamplerFromFile<SamplerT>(getTextureFile(name)); } catch(XqInvalidFile& e) { @@ -112,20 +127,36 @@ } } +boost::shared_ptr<IqMultiTexInputFile> CqTextureCache::getTextureFile( + const char* name) +{ + TqUlong hash = CqString::hash(name); + std::map<TqUlong, boost::shared_ptr<IqMultiTexInputFile> >::const_iterator + fileIter = m_texFileCache.find(hash); + if(fileIter != m_texFileCache.end()) + // File exists in the cache; return it. + return fileIter->second; + // Else open the file and store it in the cache before returning it. + boost::shared_ptr<IqMultiTexInputFile> file = IqMultiTexInputFile::open( + findFileInPath(name, m_searchPathCallback()) ); + m_texFileCache[hash] = file; + return file; +} + template<typename SamplerT> boost::shared_ptr<SamplerT> CqTextureCache::newSamplerFromFile( - const char* name) + const boost::shared_ptr<IqMultiTexInputFile>& file) { - return SamplerT::create(IqMultiTexInputFile::open(name)); + return SamplerT::create(file); } // Special case of newSamplerFromFile() for shadow maps - they need access to // the camera->world transformation matrix. template<> boost::shared_ptr<IqShadowSampler> -CqTextureCache::newSamplerFromFile(const char* name) +CqTextureCache::newSamplerFromFile(const boost::shared_ptr<IqMultiTexInputFile>& file) { - return IqShadowSampler::create(IqTexInputFile::open(name), m_camToWorld); + return IqShadowSampler::create(file, m_camToWorld); } template<typename SamplerT> Modified: branches/texfiltering/aqsis/texturing/texlib/texturecache.h =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/texturecache.h 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/texturing/texlib/texturecache.h 2008-02-22 08:15:06 UTC (rev 1937) @@ -42,6 +42,7 @@ class CqFilePathList; class IqTextureSampler; class IqShadowSampler; +class IqMultiTexInputFile; class CqTexFileHeader; /** \brief A cache managing the various types of texture samplers. @@ -66,7 +67,7 @@ * * \param name - the texture name. */ - IqTextureSampler& findTextureSampler(const char* texName); + IqTextureSampler& findTextureSampler(const char* name); /** \brief Find a shadow sampler in the cache or load from file if not found. * * If any problems are encountered in opening the shadow texture, issue @@ -74,7 +75,10 @@ * * \param name - the texture name. */ - IqShadowSampler& findShadowSampler(const char* texName); + IqShadowSampler& findShadowSampler(const char* name); + /** \brief Delete all textures from the cache + */ + void flush(); //@} //-------------------------------------------------- @@ -82,9 +86,9 @@ * * If the file is not found or is otherwise invalid, return 0. * - * \param texName - file name + * \param name - file name */ - CqTexFileHeader* textureInfo(const char* texName); + const CqTexFileHeader* textureInfo(const char* name); /** \brief Set the camera -> world transformation * @@ -108,6 +112,15 @@ template<typename SamplerT> SamplerT& findSampler(std::map<TqUlong, boost::shared_ptr<SamplerT> >& samplerMap, const char* name); + /** \brief Retrive a texture file from the cache, or open it from file. + * + * First search for the given file name in the cache. If it's not + * there, grab the file from disk (note that this may throw an + * XqInvalidFile if it's not found). + * + * \param name - file name to open. + */ + boost::shared_ptr<IqMultiTexInputFile> getTextureFile(const char* name); /** \brief Create a sampler of the given type from a file. * * SamplerT - is a sampler type to instantiate. @@ -115,7 +128,8 @@ * \param name - absolute path to file */ template<typename SamplerT> - boost::shared_ptr<SamplerT> newSamplerFromFile(const char* name); + boost::shared_ptr<SamplerT> newSamplerFromFile( + const boost::shared_ptr<IqMultiTexInputFile>& file); /** \brief Create a dummy sampler of the given type. * * This is used when a texture sampler cannot be created from the @@ -130,6 +144,8 @@ /// Cached textures live in here std::map<TqUlong, boost::shared_ptr<IqTextureSampler> > m_textureCache; std::map<TqUlong, boost::shared_ptr<IqShadowSampler> > m_shadowCache; + /// Cached texture files live in here: + std::map<TqUlong, boost::shared_ptr<IqMultiTexInputFile> > m_texFileCache; /// Camera -> world transformation - used for creating shadow maps. CqMatrix m_camToWorld; /// Callback function to obtain the current texture search path. Modified: branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp 2008-02-22 02:45:18 UTC (rev 1936) +++ branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp 2008-02-22 08:15:06 UTC (rev 1937) @@ -320,7 +320,9 @@ addAttributeToHeader<Attr::HostName,char*>(TIFFTAG_HOSTCOMPUTER, header, *this); addAttributeToHeader<Attr::Description,char*>(TIFFTAG_IMAGEDESCRIPTION, header, *this); addAttributeToHeader<Attr::DateTime,char*>(TIFFTAG_DATETIME, header, *this); + addAttributeToHeader<Attr::TextureFormat,char*>(TIFFTAG_PIXAR_TEXTUREFORMAT, header, *this); + // Add texturemap-specific strings to the header if they exist. addAttributeToHeader<Attr::WrapModes,char*>(TIFFTAG_PIXAR_WRAPMODES, header, *this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |