[Aqsis-commits] SF.net SVN: aqsis: [1944] branches/texfiltering/aqsis/texturing/texlib
Brought to you by:
ltatkinson,
pgregory
From: <c4...@us...> - 2008-02-24 02:44:43
|
Revision: 1944 http://aqsis.svn.sourceforge.net/aqsis/?rev=1944&view=rev Author: c42f Date: 2008-02-23 18:44:50 -0800 (Sat, 23 Feb 2008) Log Message: ----------- * Define a type for the Attr::WrapModes image attribute so that parsing of the wrap modes string is delegated to the image loading code. Modified Paths: -------------- branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h branches/texfiltering/aqsis/texturing/texlib/texturesampleoptions.cpp branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp branches/texfiltering/aqsis/texturing/texlib/wrapmode.h Modified: branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h 2008-02-24 02:00:52 UTC (rev 1943) +++ branches/texfiltering/aqsis/texturing/texlib/texfileattributes.h 2008-02-24 02:44:50 UTC (rev 1944) @@ -34,6 +34,7 @@ #include "channellist.h" #include "matrix.h" +#include "wrapmode.h" namespace Aqsis { @@ -50,6 +51,13 @@ TqInt topLeftX = 0, TqInt topLeftY = 0); }; +/// A pair of wrap modes to specify wrapping in the two texture coordinate directions. +struct SqWrapModes +{ + EqWrapMode sWrap; + EqWrapMode tWrap; +}; + //------------------------------------------------------------------------------ /** \brief Standard image header attributes. * @@ -129,9 +137,11 @@ AQSIS_IMAGE_ATTR_TAG(Description, std::string); // date and time of creation AQSIS_IMAGE_ATTR_TAG(DateTime, std::string); + + //-------------------------------------------------- + /// Texture map metadata // texture wrap modes - /// \todo Make this a special purpose type. - AQSIS_IMAGE_ATTR_TAG(WrapModes, std::string); + AQSIS_IMAGE_ATTR_TAG(WrapModes, SqWrapModes); // texture format (one of "texture" "shadow" or "environment" ? ) /// \todo Decide on standard names for these. AQSIS_IMAGE_ATTR_TAG(TextureFormat, std::string); Modified: branches/texfiltering/aqsis/texturing/texlib/texturesampleoptions.cpp =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/texturesampleoptions.cpp 2008-02-24 02:00:52 UTC (rev 1943) +++ branches/texfiltering/aqsis/texturing/texlib/texturesampleoptions.cpp 2008-02-24 02:44:50 UTC (rev 1944) @@ -28,7 +28,6 @@ #include "texturesampleoptions.h" #include <string.h> -#include <sstream> #include "logging.h" #include "texfileheader.h" @@ -56,15 +55,11 @@ { /// \todo Find a way to store & retrieve the downsampling filter? /// \todo Retreive texture wrap modes - const std::string* wrapModes = header.findPtr<Attr::WrapModes>(); + const SqWrapModes* wrapModes = header.findPtr<Attr::WrapModes>(); if(wrapModes) { - std::istringstream iss(*wrapModes); - std::string wrapMode; - iss >> wrapMode; - m_sWrapMode = wrapModeFromString(wrapMode); - iss >> wrapMode; - m_tWrapMode = wrapModeFromString(wrapMode); + m_sWrapMode = wrapModes->sWrap; + m_tWrapMode = wrapModes->tWrap; } } Modified: branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp 2008-02-24 02:00:52 UTC (rev 1943) +++ branches/texfiltering/aqsis/texturing/texlib/tiffdirhandle.cpp 2008-02-24 02:44:50 UTC (rev 1944) @@ -26,6 +26,8 @@ #include "tiffdirhandle.h" +#include <sstream> + #include <tiffio.hxx> #include "aqsismath.h" @@ -303,16 +305,37 @@ } } -// Extract an attribute from dirHandle and add it to header, if present. +namespace { + +/// Extract an attribute from dirHandle and add it to header, if present. template<typename Tattr, typename Ttiff> -static void addAttributeToHeader(ttag_t tag, - CqTexFileHeader& header, const CqTiffDirHandle& dirHandle) +void addAttributeToHeader(ttag_t tag, CqTexFileHeader& header, + const CqTiffDirHandle& dirHandle) { Ttiff temp; if(TIFFGetField(dirHandle.tiffPtr(), tag, &temp)) header.set<Tattr>(typename Tattr::type(temp)); } +/// Add texture wrap modes to the header if they can be found in the TIFF. +void addWrapModesToHeader(CqTexFileHeader& header, const CqTiffDirHandle& dirHandle) +{ + char* wrapModesStr = 0; + if(TIFFGetField(dirHandle.tiffPtr(), TIFFTAG_PIXAR_WRAPMODES, &wrapModesStr)) + { + SqWrapModes modes; + std::istringstream iss(wrapModesStr); + std::string wrapMode; + iss >> wrapMode; + modes.sWrap = wrapModeFromString(wrapMode); + iss >> wrapMode; + modes.tWrap = wrapModeFromString(wrapMode); + header.set<Attr::WrapModes>(modes); + } +} + +} // unnamed namespace + void CqTiffDirHandle::fillHeaderOptionalAttrs(CqTexFileHeader& header) const { // Add various descriptive strings to the header if they exist @@ -322,12 +345,10 @@ addAttributeToHeader<Attr::DateTime,char*>(TIFFTAG_DATETIME, header, *this); addAttributeToHeader<Attr::TextureFormat,char*>(TIFFTAG_PIXAR_TEXTUREFORMAT, header, *this); + // Add texturemap-specific stuff to the header if it exists. + addWrapModesToHeader(header, *this); - // Add texturemap-specific strings to the header if they exist. - addAttributeToHeader<Attr::WrapModes,char*>(TIFFTAG_PIXAR_WRAPMODES, header, *this); - // Add some matrix attributes - /// \todo: Check that these are constructed correctly! addAttributeToHeader<Attr::WorldToScreenMatrix,float*>( TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, header, *this); addAttributeToHeader<Attr::WorldToCameraMatrix,float*>( Modified: branches/texfiltering/aqsis/texturing/texlib/wrapmode.h =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/wrapmode.h 2008-02-24 02:00:52 UTC (rev 1943) +++ branches/texfiltering/aqsis/texturing/texlib/wrapmode.h 2008-02-24 02:44:50 UTC (rev 1944) @@ -51,7 +51,6 @@ EqWrapMode wrapModeFromString(const std::string& modeString); - //============================================================================== // Implementation details //============================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |