Parcourir la source

Merge branch 'master' of https://github.com/assimp/assimp

Alexander Gessler il y a 10 ans
Parent
commit
1851bf3acc
75 fichiers modifiés avec 5304 ajouts et 5095 suppressions
  1. 1 0
      .gitignore
  2. 3 2
      CMakeLists.txt
  3. 14 13
      code/Assimp.cpp
  4. 1 1
      code/BaseImporter.cpp
  5. 1 1
      code/Bitmap.cpp
  6. 22 22
      code/ByteSwapper.h
  7. 2 2
      code/CMakeLists.txt
  8. 5 1
      code/ColladaHelper.h
  9. 20 5
      code/ColladaLoader.cpp
  10. 1 0
      code/ColladaLoader.h
  11. 11 2
      code/ColladaParser.cpp
  12. 8 12
      code/Exporter.cpp
  13. 24 24
      code/FBXBinaryTokenizer.cpp
  14. 21 22
      code/FBXParser.cpp
  15. 4 7
      code/GenericProperty.h
  16. 3 5
      code/IFF.h
  17. 20 16
      code/Importer.cpp
  18. 1 1
      code/LWOLoader.cpp
  19. 1 1
      code/LWOMaterial.cpp
  20. 1 1
      code/MD2Loader.cpp
  21. 13 13
      code/MD2Loader.h
  22. 1 2
      code/MD3Loader.cpp
  23. 16 16
      code/MD3Loader.h
  24. 13 14
      code/MDCLoader.h
  25. 97 97
      code/MDLFileData.h
  26. 6 6
      code/ObjFileImporter.cpp
  27. 246 245
      code/ObjFileMtlImporter.cpp
  28. 1 0
      code/ObjFileParser.cpp
  29. 55 37
      code/OpenGEXImporter.cpp
  30. 1 1
      code/OpenGEXImporter.h
  31. 9 5
      code/PlyExporter.cpp
  32. 1 1
      code/PlyParser.cpp
  33. 3 2
      code/Q3BSPZipArchive.cpp
  34. 1 1
      code/STEPFileEncoding.cpp
  35. 1 1
      code/STLExporter.cpp
  36. 1 1
      code/SceneCombiner.cpp
  37. 23 23
      code/StreamReader.h
  38. 17 17
      code/StreamWriter.h
  39. 2 0
      code/StringComparison.h
  40. 5 4
      code/TextureTransform.cpp
  41. 8 5
      code/UnrealLoader.cpp
  42. 1 1
      code/XFileParser.cpp
  43. 3 3
      code/fast_atof.h
  44. 1 1
      contrib/openddlparser/code/DDLNode.cpp
  45. 6 10
      contrib/openddlparser/code/OpenDDLParser.cpp
  46. 69 41
      contrib/openddlparser/include/openddlparser/OpenDDLCommon.h
  47. 14 3
      contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h
  48. 165 165
      doc/dox.h
  49. 8 13
      include/assimp/Exporter.hpp
  50. 8 13
      include/assimp/Importer.hpp
  51. 18 3
      include/assimp/config.h
  52. 4 7
      test/unit/utImporter.cpp
  53. 0 1
      tools/assimp_view/AnimEvaluator.cpp
  54. 199 190
      tools/assimp_view/AssetHelper.h
  55. 1 2
      tools/assimp_view/Background.cpp
  56. 65 65
      tools/assimp_view/Background.h
  57. 8 5
      tools/assimp_view/Display.cpp
  58. 465 457
      tools/assimp_view/Display.h
  59. 0 2
      tools/assimp_view/HelpDialog.cpp
  60. 0 2
      tools/assimp_view/Input.cpp
  61. 1 4
      tools/assimp_view/LogDisplay.cpp
  62. 45 42
      tools/assimp_view/LogDisplay.h
  63. 2 2
      tools/assimp_view/LogWindow.cpp
  64. 65 60
      tools/assimp_view/LogWindow.h
  65. 1392 1301
      tools/assimp_view/Material.cpp
  66. 165 159
      tools/assimp_view/MaterialManager.h
  67. 0 2
      tools/assimp_view/MeshRenderer.cpp
  68. 40 38
      tools/assimp_view/MeshRenderer.h
  69. 7 3
      tools/assimp_view/MessageProc.cpp
  70. 1 1
      tools/assimp_view/Normals.cpp
  71. 0 1
      tools/assimp_view/SceneAnimator.cpp
  72. 1295 1299
      tools/assimp_view/Shaders.cpp
  73. 523 522
      tools/assimp_view/assimp_view.cpp
  74. 37 36
      tools/assimp_view/assimp_view.h
  75. 12 12
      workspaces/xcode3/assimp.xcodeproj/project.pbxproj

+ 1 - 0
.gitignore

@@ -58,3 +58,4 @@ test/gtest/src/gtest-stamp/gtest-gitinfo.txt
 test/gtest/src/gtest-stamp/gtest-gitclone-lastrun.txt
 Assimp.opensdf
 contrib/zlib/CTestTestfile.cmake
+ipch/assimp_viewer-44bbbcd1/assimp_viewerd-ccc45335.ipch

+ 3 - 2
CMakeLists.txt

@@ -1,3 +1,4 @@
+set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
 cmake_minimum_required( VERSION 2.8 )
 PROJECT( Assimp )
 
@@ -61,9 +62,9 @@ if( CMAKE_COMPILER_IS_MINGW )
 endif()
 
 if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) AND NOT CMAKE_COMPILER_IS_MINGW)
-    add_definitions(-fPIC) # this is a very important switch and some libraries seem now to have it....
+    set(CMAKE_CXX_FLAGS "-fPIC") # this is a very important switch and some libraries seem now to have it....
     # hide all not-exported symbols
-    add_definitions( -fvisibility=hidden -Wall )
+    set(CMAKE_CXX_FLAGS "-fvisibility=hidden -Wall" )
 elseif(MSVC)
     # enable multi-core compilation with MSVC
     add_definitions(/MP)

+ 14 - 13
code/Assimp.cpp

@@ -42,18 +42,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  @brief Implementation of the Plain-C API
  */
 
-#include "../include/assimp/cimport.h"
-#include "../include/assimp/LogStream.hpp"
-#include "../include/assimp/DefaultLogger.hpp"
-#include "../include/assimp/importerdesc.h"
-#include "../include/assimp/scene.h"
+#include <assimp/cimport.h>
+#include <assimp/LogStream.hpp>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/Importer.hpp>
+#include <assimp/importerdesc.h>
+#include <assimp/scene.h>
 
 #include "GenericProperty.h"
 #include "CInterfaceIOWrapper.h"
-#include "Importer.h"
-#include "Exceptional.h"
-#include "ScenePrivate.h"
-#include "BaseImporter.h"
+#include "Importer.h"
+#include "Exceptional.h"
+#include "ScenePrivate.h"
+#include "BaseImporter.h"
 #include <list>
 
 // ------------------------------------------------------------------------------------------------
@@ -489,7 +490,7 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
 {
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
-	SetGenericProperty<int>(pp->ints,szName,value,NULL);
+	SetGenericProperty<int>(pp->ints,szName,value);
 	ASSIMP_END_EXCEPTION_REGION(void);
 }
 
@@ -499,7 +500,7 @@ ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName,
 {
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
-	SetGenericProperty<float>(pp->floats,szName,value,NULL);
+	SetGenericProperty<float>(pp->floats,szName,value);
 	ASSIMP_END_EXCEPTION_REGION(void);
 }
 
@@ -513,7 +514,7 @@ ASSIMP_API void aiSetImportPropertyString(aiPropertyStore* p, const char* szName
 	}
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
-	SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()),NULL);
+	SetGenericProperty<std::string>(pp->strings,szName,std::string(st->C_Str()));
 	ASSIMP_END_EXCEPTION_REGION(void);
 }
 
@@ -527,7 +528,7 @@ ASSIMP_API void aiSetImportPropertyMatrix(aiPropertyStore* p, const char* szName
 	}
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
-	SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat,NULL);
+	SetGenericProperty<aiMatrix4x4>(pp->matrices,szName,*mat);
 	ASSIMP_END_EXCEPTION_REGION(void);
 }
 

+ 1 - 1
code/BaseImporter.cpp

@@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "BaseImporter.h"
 #include "FileSystemFilter.h"
 #include "Importer.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "../include/assimp/scene.h"
 #include "../include/assimp/Importer.hpp"
 #include "../include/assimp/postprocess.h"

+ 1 - 1
code/Bitmap.cpp

@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "Bitmap.h"
 #include "../include/assimp/texture.h"
 #include "../include/assimp/IOStream.hpp"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 namespace Assimp {
 

+ 22 - 22
code/ByteSwap.h → code/ByteSwapper.h

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,38 +23,38 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
 */
 
-/** @file Helper class tp perform various byte oder swappings 
+/** @file Helper class tp perform various byte oder swappings
    (e.g. little to big endian) */
-#ifndef AI_BYTESWAP_H_INC
-#define AI_BYTESWAP_H_INC
+#ifndef AI_BYTESWAPPER_H_INC
+#define AI_BYTESWAPPER_H_INC
 
 #include "../include/assimp/ai_assert.h"
 #include "../include/assimp/types.h"
 #include <stdint.h>
 
-#if _MSC_VER >= 1400 
+#if _MSC_VER >= 1400
 #include <stdlib.h>
 #endif
 
 namespace Assimp	{
 // --------------------------------------------------------------------------------------
 /** Defines some useful byte order swap routines.
- * 
+ *
  * This is required to read big-endian model formats on little-endian machines,
  * and vice versa. Direct use of this class is DEPRECATED. Use #StreamReader instead. */
 // --------------------------------------------------------------------------------------
@@ -167,7 +167,7 @@ public:
 	// ----------------------------------------------------------------------
 	//! Templatized ByteSwap
 	//! \returns param tOut as swapped
-	template<typename Type> 
+	template<typename Type>
 	static inline Type Swapped(Type tOut)
 	{
 		return _swapper<Type,sizeof(Type)>()(tOut);
@@ -180,28 +180,28 @@ private:
 
 template <typename T> struct ByteSwap::_swapper<T,2> {
 	T operator() (T tOut) {
-		Swap2(&tOut); 
+		Swap2(&tOut);
 		return tOut;
 	}
 };
 
 template <typename T> struct ByteSwap::_swapper<T,4> {
 	T operator() (T tOut) {
-		Swap4(&tOut); 
+		Swap4(&tOut);
 		return tOut;
 	}
 };
 
 template <typename T> struct ByteSwap::_swapper<T,8> {
 	T operator() (T tOut) {
-		Swap8(&tOut); 
+		Swap8(&tOut);
 		return tOut;
 	}
 };
 
 
 // --------------------------------------------------------------------------------------
-// ByteSwap macros for BigEndian/LittleEndian support 
+// ByteSwap macros for BigEndian/LittleEndian support
 // --------------------------------------------------------------------------------------
 #if (defined AI_BUILD_BIG_ENDIAN)
 #	define AI_LE(t)	(t)
@@ -250,7 +250,7 @@ struct ByteSwapper	{
 	}
 };
 
-template <typename T> 
+template <typename T>
 struct ByteSwapper<T,false>	{
 	void operator() (T*) {
 	}
@@ -272,7 +272,7 @@ struct Getter {
 	}
 };
 
-template <bool SwapEndianess, typename T> 
+template <bool SwapEndianess, typename T>
 struct Getter<SwapEndianess,T,false> {
 
 	void operator() (T* inout, bool /*le*/) {
@@ -283,4 +283,4 @@ struct Getter<SwapEndianess,T,false> {
 } // end Intern
 } // end Assimp
 
-#endif //!! AI_BYTESWAP_H_INC
+#endif //!! AI_BYTESWAPPER_H_INC

+ 2 - 2
code/CMakeLists.txt

@@ -98,7 +98,7 @@ SET( Common_SRCS
 	ScenePrivate.h
 	PostStepRegistry.cpp
 	ImporterRegistry.cpp
-	ByteSwap.h
+	ByteSwapper.h
 	DefaultProgressHandler.h
 	DefaultIOStream.cpp
 	DefaultIOStream.h
@@ -784,7 +784,7 @@ if( MSVC )
   else()
     set(MSVC_PREFIX "vc130")
   endif()
-  set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library" FORCE)
+  set(LIBRARY_SUFFIX "${ASSIMP_LIBRARY_SUFFIX}-${MSVC_PREFIX}-mt" CACHE STRING "the suffix for the assimp windows library")
 endif()
 
 SET_TARGET_PROPERTIES( assimp PROPERTIES

+ 5 - 1
code/ColladaHelper.h

@@ -513,6 +513,8 @@ struct Effect
 	// Scalar factory
 	float mShininess, mRefractIndex, mReflectivity;
 	float mTransparency;
+	bool mHasTransparency;
+	bool mRGBTransparency;
 
 	// local params referring to each other by their SID
 	typedef std::map<std::string, Collada::EffectParam> ParamLibrary;
@@ -533,7 +535,9 @@ struct Effect
 		, mShininess    (10.0f)
 		, mRefractIndex (1.f)
 		, mReflectivity (1.f)
-		, mTransparency (0.f)
+		, mTransparency (1.f)
+		, mHasTransparency (false)
+		, mRGBTransparency(false)
 		, mDoubleSided	(false)
 		, mWireframe    (false)
 		, mFaceted      (false)

+ 20 - 5
code/ColladaLoader.cpp

@@ -117,6 +117,7 @@ void ColladaLoader::SetupProperties(const Importer* pImp)
 {
 	noSkeletonMesh = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_NO_SKELETON_MESHES,0) != 0;
 	ignoreUpDirection = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION,0) != 0;
+	invertTransparency = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY,0) != 0;
 }
 
 
@@ -1338,11 +1339,25 @@ void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pSce
 		mat.AddProperty( &effect.mRefractIndex, 1, AI_MATKEY_REFRACTI);
 
 		// transparency, a very hard one. seemingly not all files are following the
-		// specification here .. but we can trick.
-		if (effect.mTransparency >= 0.f && effect.mTransparency < 1.f) {
-			effect.mTransparency = 1.f- effect.mTransparency;
-			mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY );
-			mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
+		// specification here (1.0 transparency => completly opaque)...
+		// therefore, we let the opportunity for the user to manually invert
+		// the transparency if necessary and we add preliminary support for RGB_ZERO mode
+		if(effect.mTransparency >= 0.f && effect.mTransparency <= 1.f) {
+			// Trying some support for RGB_ZERO mode
+			if(effect.mRGBTransparency) {
+				effect.mTransparency = 1.f - effect.mTransparent.a;
+			}
+			
+			// Global option
+			if(invertTransparency) {
+				effect.mTransparency = 1.f - effect.mTransparency;
+			}
+
+			// Is the material finally transparent ?
+			if (effect.mHasTransparency || effect.mTransparency < 1.f) {
+				mat.AddProperty( &effect.mTransparency, 1, AI_MATKEY_OPACITY );
+				mat.AddProperty( &effect.mTransparent, 1, AI_MATKEY_COLOR_TRANSPARENT );
+			}
 		}
 
 		// add textures, if given

+ 1 - 0
code/ColladaLoader.h

@@ -241,6 +241,7 @@ protected:
 
 	bool noSkeletonMesh;
 	bool ignoreUpDirection;
+	bool invertTransparency;
 
 	/** Used by FindNameForNode() to generate unique node names */
 	unsigned int mNodeNameCounter;

+ 11 - 2
code/ColladaParser.cpp

@@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef ASSIMP_BUILD_NO_COLLADA_IMPORTER
 
+#include <sstream>
 #include "ColladaParser.h"
 #include "fast_atof.h"
 #include "ParsingUtils.h"
@@ -1230,6 +1231,14 @@ void ColladaParser::ReadEffectProfileCommon( Collada::Effect& pEffect)
 				ReadEffectColor( pEffect.mReflective, pEffect.mTexReflective);
 			}
 			else if( IsElement( "transparent")) {
+				pEffect.mHasTransparency = true;
+
+				// In RGB_ZERO mode, the transparency is interpreted in reverse, go figure...
+				if(::strcmp(mReader->getAttributeValueSafe("opaque"), "RGB_ZERO") == 0) {
+					// TODO: handle RGB_ZERO mode completely
+					pEffect.mRGBTransparency = true;
+				}
+
 				ReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent);
 			}
 			else if( IsElement( "shininess"))
@@ -1987,12 +1996,12 @@ void ColladaParser::ReadIndexData( Mesh* pMesh)
 			break;
 		}
 	}
-
+
 #ifdef ASSIMP_BUILD_DEBUG  
 	if (primType != Prim_TriFans && primType != Prim_TriStrips) {
 		ai_assert(actualPrimitives == numPrimitives);
 	}
-#endif
+#endif
 
 	// only when we're done reading all <p> tags (and thus know the final vertex count) can we commit the submesh
 	subgroup.mNumFaces = actualPrimitives;

+ 8 - 12
code/Exporter.cpp

@@ -513,34 +513,30 @@ ExportProperties::ExportProperties(const ExportProperties &other)
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void ExportProperties :: SetPropertyInteger(const char* szName, int iValue, 
-	bool* bWasExisting /*= NULL*/)
+bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
 {
-	SetGenericProperty<int>(mIntProperties, szName,iValue,bWasExisting);
+	return SetGenericProperty<int>(mIntProperties, szName,iValue);
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void ExportProperties :: SetPropertyFloat(const char* szName, float iValue, 
-	bool* bWasExisting /*= NULL*/)
+bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue)
 {
-	SetGenericProperty<float>(mFloatProperties, szName,iValue,bWasExisting);
+	return SetGenericProperty<float>(mFloatProperties, szName,iValue);
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void ExportProperties :: SetPropertyString(const char* szName, const std::string& value, 
-	bool* bWasExisting /*= NULL*/)
+bool ExportProperties :: SetPropertyString(const char* szName, const std::string& value)
 {
-	SetGenericProperty<std::string>(mStringProperties, szName,value,bWasExisting);
+	return SetGenericProperty<std::string>(mStringProperties, szName,value);
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, 
-	bool* bWasExisting /*= NULL*/)
+bool ExportProperties :: SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
 {
-	SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value,bWasExisting);
+	return SetGenericProperty<aiMatrix4x4>(mMatrixProperties, szName,value);
 }
 
 // ------------------------------------------------------------------------------------------------

+ 24 - 24
code/FBXBinaryTokenizer.cpp

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,16 +23,16 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
@@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "../include/assimp/defs.h"
 #include <stdint.h>
 #include "Exceptional.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 namespace Assimp {
 namespace FBX {
@@ -58,7 +58,7 @@ namespace FBX {
 
 // ------------------------------------------------------------------------------------------------
 Token::Token(const char* sbegin, const char* send, TokenType type, unsigned int offset)
-	: 
+	:
 	#ifdef DEBUG
 	contents(sbegin, static_cast<size_t>(send-sbegin)),
 	#endif
@@ -108,7 +108,7 @@ uint32_t ReadWord(const char* input, const char*& cursor, const char* end)
 {
 	if(Offset(cursor, end) < 4) {
 		TokenizeError("cannot ReadWord, out of bounds",input, cursor);
-	} 
+	}
 
 	uint32_t word = *reinterpret_cast<const uint32_t*>(cursor);
 	AI_SWAP4(word);
@@ -124,7 +124,7 @@ uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
 {
 	if(Offset(cursor, end) < 1) {
 		TokenizeError("cannot ReadByte, out of bounds",input, cursor);
-	} 
+	}
 
 	uint8_t word = *reinterpret_cast<const uint8_t*>(cursor);
 	++cursor;
@@ -134,14 +134,14 @@ uint8_t ReadByte(const char* input, const char*& cursor, const char* end)
 
 
 // ------------------------------------------------------------------------------------------------
-unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end, 
+unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end,
 	bool long_length = false,
 	bool allow_null = false)
 {
 	const uint32_t len_len = long_length ? 4 : 1;
 	if(Offset(cursor, end) < len_len) {
 		TokenizeError("cannot ReadString, out of bounds reading length",input, cursor);
-	} 
+	}
 
 	const uint32_t length = long_length ? ReadWord(input, cursor, end) : ReadByte(input, cursor, end);
 
@@ -172,7 +172,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
 {
 	if(Offset(cursor, end) < 1) {
 		TokenizeError("cannot ReadData, out of bounds reading length",input, cursor);
-	} 
+	}
 
 	const char type = *cursor;
 	sbegin_out = cursor++;
@@ -211,14 +211,14 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
 		// note: do not write cursor += ReadWord(...cursor) as this would be UB
 
 		// raw binary data
-	case 'R':	
+	case 'R':
 	{
 		const uint32_t length = ReadWord(input, cursor, end);
 		cursor += length;
 		break;
 	}
 
-	case 'b': 
+	case 'b':
 		// TODO: what is the 'b' type code? Right now we just skip over it /
 		// take the full range we could get
 		cursor = end;
@@ -229,7 +229,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
 	case 'd':
 	case 'l':
 	case 'i':	{
-	
+
 		const uint32_t length = ReadWord(input, cursor, end);
 		const uint32_t encoding = ReadWord(input, cursor, end);
 
@@ -259,7 +259,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
 			}
 		}
 		// zip/deflate algorithm (encoding==1)? take given length. anything else? die
-		else if (encoding != 1) {			
+		else if (encoding != 1) {
 			TokenizeError("cannot ReadData, unknown encoding",input, cursor);
 		}
 		cursor += comp_len;
@@ -279,7 +279,7 @@ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input,
 
 	if(cursor > end) {
 		TokenizeError("cannot ReadData, the remaining size is too small for the data type: " + std::string(&type, 1),input, cursor);
-	} 
+	}
 
 	// the type code is contained in the returned range
 	send_out = cursor;
@@ -291,10 +291,10 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
 {
 	// the first word contains the offset at which this block ends
 	const uint32_t end_offset = ReadWord(input, cursor, end);
-	
+
 	// we may get 0 if reading reached the end of the file -
-	// fbx files have a mysterious extra footer which I don't know 
-	// how to extract any information from, but at least it always 
+	// fbx files have a mysterious extra footer which I don't know
+	// how to extract any information from, but at least it always
 	// starts with a 0.
 	if(!end_offset) {
 		return false;

+ 21 - 22
code/FBXParser.cpp

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,16 +23,16 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
@@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "ParsingUtils.h"
 #include "fast_atof.h"
 #include <boost/foreach.hpp>
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 using namespace Assimp;
 using namespace Assimp::FBX;
@@ -189,7 +189,7 @@ Scope::Scope(Parser& parser,bool topLevel)
 		TokenPtr t = parser.CurrentToken();
 		if (t->Type() != TokenType_OPEN_BRACKET) {
 			ParseError("expected open bracket",t);
-		}	
+		}
 	}
 
 	TokenPtr n = parser.AdvanceToNextToken();
@@ -384,7 +384,7 @@ float ParseTokenAsFloat(const Token& t, const char*& err_out)
 	}
 
 	// need to copy the input string to a temporary buffer
-	// first - next in the fbx token stream comes ',', 
+	// first - next in the fbx token stream comes ',',
 	// which fast_atof could interpret as decimal point.
 #define MAX_FLOAT_LENGTH 31
 	char temp[MAX_FLOAT_LENGTH + 1];
@@ -515,7 +515,7 @@ namespace {
 
 // ------------------------------------------------------------------------------------------------
 // read the type code and element count of a binary data array and stop there
-void ReadBinaryDataArrayHead(const char*& data, const char* end, char& type, uint32_t& count, 
+void ReadBinaryDataArrayHead(const char*& data, const char* end, char& type, uint32_t& count,
 	const Element& el)
 {
 	if (static_cast<size_t>(end-data) < 5) {
@@ -536,8 +536,8 @@ void ReadBinaryDataArrayHead(const char*& data, const char* end, char& type, uin
 
 // ------------------------------------------------------------------------------------------------
 // read binary data array, assume cursor points to the 'compression mode' field (i.e. behind the header)
-void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const char* end, 
-	std::vector<char>& buff, 
+void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const char* end,
+	std::vector<char>& buff,
 	const Element& /*el*/)
 {
 	BE_NCONST uint32_t encmode = SafeParse<uint32_t>(data, end);
@@ -581,7 +581,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char*& data, const cha
 	else if(encmode == 1) {
 		// zlib/deflate, next comes ZIP head (0x78 0x01)
 		// see http://www.ietf.org/rfc/rfc1950.txt
-		
+
 		z_stream zstream;
 		zstream.opaque = Z_NULL;
 		zstream.zalloc = Z_NULL;
@@ -631,7 +631,7 @@ void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
 	if(tok.empty()) {
 		ParseError("unexpected empty element",&el);
 	}
-	
+
 	if(tok[0]->IsBinary()) {
 		const char* data = tok[0]->begin(), *end = tok[0]->end();
 
@@ -653,7 +653,7 @@ void ParseVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
 
 		std::vector<char> buff;
 		ReadBinaryDataArray(type, count, data, end, buff, el);
-		
+
 		ai_assert(data == end);
 		ai_assert(buff.size() == count * (type == 'd' ? 8 : 4));
 
@@ -1095,7 +1095,7 @@ void ParseVectorDataArray(std::vector<uint64_t>& out, const Element& el)
 
 	for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
 		const uint64_t ival = ParseTokenAsID(**it++);
-		
+
 		out.push_back(ival);
 	}
 }
@@ -1211,7 +1211,7 @@ std::string ParseTokenAsString(const Token& t)
 
 // ------------------------------------------------------------------------------------------------
 // extract a required element from a scope, abort if the element cannot be found
-const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= NULL*/) 
+const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= NULL*/)
 {
 	const Element* el = sc[index];
 	if(!el) {
@@ -1249,7 +1249,7 @@ const Token& GetRequiredToken(const Element& el, unsigned int index)
 
 // ------------------------------------------------------------------------------------------------
 // wrapper around ParseTokenAsID() with ParseError handling
-uint64_t ParseTokenAsID(const Token& t) 
+uint64_t ParseTokenAsID(const Token& t)
 {
 	const char* err;
 	const uint64_t i = ParseTokenAsID(t,err);
@@ -1316,4 +1316,3 @@ int64_t ParseTokenAsInt64(const Token& t)
 } // !Assimp
 
 #endif
-

+ 4 - 7
code/GenericProperty.h

@@ -49,22 +49,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 // ------------------------------------------------------------------------------------------------
 template <class T>
-inline void SetGenericProperty(std::map< unsigned int, T >& list, 
-	const char* szName, const T& value, bool* bWasExisting = NULL)
+inline bool SetGenericProperty(std::map< unsigned int, T >& list, 
+	const char* szName, const T& value)
 {
 	ai_assert(NULL != szName);
 	const uint32_t hash = SuperFastHash(szName);
 
 	typename std::map<unsigned int, T>::iterator it = list.find(hash);
 	if (it == list.end())	{
-		if (bWasExisting)
-			*bWasExisting = false;
 		list.insert(std::pair<unsigned int, T>( hash, value ));
-		return;
+		return false;
 	}
 	(*it).second = value;
-	if (bWasExisting)
-		*bWasExisting = true;
+	return true;
 }
 
 // ------------------------------------------------------------------------------------------------

+ 3 - 5
code/IFF.h

@@ -1,5 +1,3 @@
-
-
 // Definitions for the Interchange File Format (IFF)
 // Alexander Gessler, 2006
 // Adapted to Assimp August 2008
@@ -7,7 +5,7 @@
 #ifndef AI_IFF_H_INCLUDED
 #define AI_IFF_H_INCLUDED
 
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 namespace Assimp	{
 namespace IFF		{
@@ -81,12 +79,12 @@ inline SubChunkHeader LoadSubChunk(uint8_t*& outFile)
 
 /////////////////////////////////////////////////////////////////////////////////
 //! Read the file header and return the type of the file and its size
-//! @param outFile Pointer to the file data. The buffer must at 
+//! @param outFile Pointer to the file data. The buffer must at
 //!   least be 12 bytes large.
 //! @param fileType Receives the type of the file
 //! @return 0 if everything was OK, otherwise an error message
 /////////////////////////////////////////////////////////////////////////////////
-inline const char* ReadHeader(uint8_t* outFile, uint32_t& fileType) 
+inline const char* ReadHeader(uint8_t* outFile, uint32_t& fileType)
 {
 	ChunkHeader head = LoadChunk(outFile);
 	if(AI_IFF_FOURCC_FORM != head.type)

+ 20 - 16
code/Importer.cpp

@@ -925,42 +925,46 @@ void Importer::GetExtensionList(aiString& szOut) const
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void Importer::SetPropertyInteger(const char* szName, int iValue, 
-	bool* bWasExisting /*= NULL*/)
+bool Importer::SetPropertyInteger(const char* szName, int iValue)
 {
+	bool existing;
 	ASSIMP_BEGIN_EXCEPTION_REGION();
-		SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue,bWasExisting);	
-	ASSIMP_END_EXCEPTION_REGION(void);
+		existing = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);	
+	ASSIMP_END_EXCEPTION_REGION(bool);
+	return existing;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void Importer::SetPropertyFloat(const char* szName, float iValue, 
-	bool* bWasExisting /*= NULL*/)
+bool Importer::SetPropertyFloat(const char* szName, float iValue)
 {
+	bool exising;
 	ASSIMP_BEGIN_EXCEPTION_REGION();
-		SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue,bWasExisting);	
-	ASSIMP_END_EXCEPTION_REGION(void);
+		exising = SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue);	
+	ASSIMP_END_EXCEPTION_REGION(bool);
+	return exising;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void Importer::SetPropertyString(const char* szName, const std::string& value, 
-	bool* bWasExisting /*= NULL*/)
+bool Importer::SetPropertyString(const char* szName, const std::string& value)
 {
+	bool exising;
 	ASSIMP_BEGIN_EXCEPTION_REGION();
-		SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value,bWasExisting);	
-	ASSIMP_END_EXCEPTION_REGION(void);
+		exising = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);	
+	ASSIMP_END_EXCEPTION_REGION(bool);
+	return exising;
 }
 
 // ------------------------------------------------------------------------------------------------
 // Set a configuration property
-void Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value, 
-	bool* bWasExisting /*= NULL*/)
+bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
 {
+	bool exising;
 	ASSIMP_BEGIN_EXCEPTION_REGION();
-	SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value,bWasExisting);	
-	ASSIMP_END_EXCEPTION_REGION(void);
+		exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);	
+	ASSIMP_END_EXCEPTION_REGION(bool);
+	return exising;
 }
 
 // ------------------------------------------------------------------------------------------------

+ 1 - 1
code/LWOLoader.cpp

@@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "LWOLoader.h"
 #include "StringComparison.h"
 #include "SGSpatialSort.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "ProcessHelper.h"
 #include "ConvertToLHProcess.h"
 #include <boost/scoped_ptr.hpp>

+ 1 - 1
code/LWOMaterial.cpp

@@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 // internal headers
 #include "LWOLoader.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include <boost/static_assert.hpp>
 
 

+ 1 - 1
code/MD2Loader.cpp

@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /** @file Implementation of the MD2 importer class */
 #include "MD2Loader.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "MD2NormalTable.h" // shouldn't be included by other units
 #include "../include/assimp/DefaultLogger.hpp"
 #include "../include/assimp/Importer.hpp"

+ 13 - 13
code/MD2Loader.h

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,16 +23,16 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
@@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "BaseImporter.h"
 #include "../include/assimp/types.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 #include "MD2FileData.h"
 struct aiNode;
@@ -69,7 +69,7 @@ public:
 public:
 
 	// -------------------------------------------------------------------
-	/** Returns whether the class can handle the format of the given file. 
+	/** Returns whether the class can handle the format of the given file.
 	* See BaseImporter::CanRead() for details.	*/
 	bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
 		bool checkSig) const;
@@ -91,10 +91,10 @@ protected:
 	const aiImporterDesc* GetInfo () const;
 
 	// -------------------------------------------------------------------
-	/** Imports the given file into the given scene structure. 
+	/** Imports the given file into the given scene structure.
 	* See BaseImporter::InternReadFile() for details
 	*/
-	void InternReadFile( const std::string& pFile, aiScene* pScene, 
+	void InternReadFile( const std::string& pFile, aiScene* pScene,
 		IOSystem* pIOHandler);
 
 

+ 1 - 2
code/MD3Loader.cpp

@@ -52,7 +52,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef ASSIMP_BUILD_NO_MD3_IMPORTER
 
 #include "MD3Loader.h"
-#include "ByteSwap.h"
 #include "SceneCombiner.h"
 #include "GenericProperty.h"
 #include "RemoveComments.h"
@@ -564,7 +563,7 @@ bool MD3Importer::ReadMultipartFile()
 
 		// ensure we won't try to load ourselves recursively
 		BatchLoader::PropertyMap props;
-		SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0, NULL);
+		SetGenericProperty( props.ints, AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART, 0);
 
 		// now read these three files
 		BatchLoader batch(mIOHandler);

+ 16 - 16
code/MD3Loader.h

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,16 +23,16 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
@@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define AI_MD3LOADER_H_INCLUDED
 
 #include "BaseImporter.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "MD3FileData.h"
 #include "StringComparison.h"
 #include "../include/assimp/types.h"
@@ -99,7 +99,7 @@ enum ShaderCullMode
 enum BlendFunc
 {
 	BLEND_NONE,
-	BLEND_GL_ONE, 
+	BLEND_GL_ONE,
 	BLEND_GL_ZERO,
 	BLEND_GL_DST_COLOR,
 	BLEND_GL_ONE_MINUS_DST_COLOR,
@@ -114,7 +114,7 @@ enum AlphaTestFunc
 {
 	AT_NONE,
 	AT_GT0,
-	AT_LT128, 
+	AT_LT128,
 	AT_GE128
 };
 
@@ -223,7 +223,7 @@ public:
 public:
 
 	// -------------------------------------------------------------------
-	/** Returns whether the class can handle the format of the given file. 
+	/** Returns whether the class can handle the format of the given file.
 	* See BaseImporter::CanRead() for details.	*/
 	bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
 		bool checkSig) const;
@@ -245,10 +245,10 @@ protected:
 	const aiImporterDesc* GetInfo () const;
 
 	// -------------------------------------------------------------------
-	/** Imports the given file into the given scene structure. 
+	/** Imports the given file into the given scene structure.
 	 * See BaseImporter::InternReadFile() for details
 	 */
-	void InternReadFile( const std::string& pFile, aiScene* pScene, 
+	void InternReadFile( const std::string& pFile, aiScene* pScene,
 		IOSystem* pIOHandler);
 
 	// -------------------------------------------------------------------
@@ -281,7 +281,7 @@ protected:
 	 *  @param[in] header_path Base path specified in MD3 header
 	 *  @param[out] out Receives the converted output string
 	 */
-	void ConvertPath(const char* texture_name, const char* header_path, 
+	void ConvertPath(const char* texture_name, const char* header_path,
 		std::string& out) const;
 
 protected:

+ 13 - 14
code/MDCLoader.h

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,23 +23,23 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
 */
 
 /** @file  MDCLoader.h
- *  @brief Definition of the MDC importer class. 
+ *  @brief Definition of the MDC importer class.
  */
 #ifndef AI_MDCLOADER_H_INCLUDED
 #define AI_MDCLOADER_H_INCLUDED
@@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "BaseImporter.h"
 #include "MDCFileData.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 namespace Assimp	{
 using namespace MDC;
@@ -66,7 +66,7 @@ public:
 public:
 
 	// -------------------------------------------------------------------
-	/** Returns whether the class can handle the format of the given file. 
+	/** Returns whether the class can handle the format of the given file.
 	* See BaseImporter::CanRead() for details.	*/
 	bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
 		bool checkSig) const;
@@ -87,7 +87,7 @@ protected:
 	const aiImporterDesc* GetInfo () const;
 
 	// -------------------------------------------------------------------
-	/** Imports the given file into the given scene structure. 
+	/** Imports the given file into the given scene structure.
 	* See BaseImporter::InternReadFile() for details
 	*/
 	void InternReadFile( const std::string& pFile, aiScene* pScene,
@@ -125,4 +125,3 @@ protected:
 } // end of namespace Assimp
 
 #endif // AI_3DSIMPORTER_H_INC
-

+ 97 - 97
code/MDLFileData.h

@@ -5,8 +5,8 @@ Open Asset Import Library (assimp)
 Copyright (c) 2006-2012, assimp team
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the
 following conditions are met:
 
 * Redistributions of source code must retain the above
@@ -23,16 +23,16 @@ following conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 ----------------------------------------------------------------------
@@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /**
  * @file  MDLFileData.h
- * @brief Definition of in-memory structures for the MDL file format. 
+ * @brief Definition of in-memory structures for the MDL file format.
  *
  * The specification has been taken from various sources on the internet.
  * - http://tfc.duke.free.fr/coding/mdl-specs-en.html
@@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef AI_MDLFILEHELPER_H_INC
 #define AI_MDLFILEHELPER_H_INC
 
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "./../include/assimp/anim.h"
 #include "./../include/assimp/mesh.h"
 #include "./../include/assimp/Compiler/pushpack1.h"
@@ -99,13 +99,13 @@ namespace MDL	{
 #	define AI_MDL_MAX_FRAMES			256
 #endif
 #if (!defined AI_MDL_MAX_UVS)
-#	define AI_MDL_MAX_UVS				1024	
+#	define AI_MDL_MAX_UVS				1024
 #endif
 #if (!defined AI_MDL_MAX_VERTS)
 #	define AI_MDL_MAX_VERTS				1024
 #endif
 #if (!defined AI_MDL_MAX_TRIANGLES)
-#	define AI_MDL_MAX_TRIANGLES			2048	
+#	define AI_MDL_MAX_TRIANGLES			2048
 #endif
 
 // material key that is set for dummy materials that are
@@ -121,47 +121,47 @@ namespace MDL	{
 struct Header
 {
 	//! magic number: "IDPO"
-	uint32_t ident;          
+	uint32_t ident;
 
 	//! version number: 6
-	int32_t version;          
+	int32_t version;
 
 	//! scale factors for each axis
-	aiVector3D scale;				
+	aiVector3D scale;
 
 	//! translation factors for each axis
-	aiVector3D translate;	
+	aiVector3D translate;
 
 	//! bounding radius of the mesh
 	float boundingradius;
-	 
+
 	//! Position of the viewer's exe. Ignored
 	aiVector3D vEyePos;
 
 	//! Number of textures
-	int32_t num_skins;       
+	int32_t num_skins;
 
 	//! Texture width in pixels
 	int32_t skinwidth;
 
 	//! Texture height in pixels
-	int32_t skinheight;       
+	int32_t skinheight;
 
 	//! Number of vertices contained in the file
-	int32_t num_verts;       
+	int32_t num_verts;
 
 	//! Number of triangles contained in the file
-	int32_t num_tris;         
+	int32_t num_tris;
 
 	//! Number of frames contained in the file
-	int32_t num_frames;      
+	int32_t num_frames;
 
 	//! 0 = synchron, 1 = random . Ignored
 	//! (MDLn formats: number of texture coordinates)
-	int32_t synctype;         
+	int32_t synctype;
 
 	//! State flag
-	int32_t flags;     
+	int32_t flags;
 
 	//! Could be the total size of the file (and not a float)
 	float size;
@@ -175,10 +175,10 @@ struct Header
 struct Header_MDL7
 {
 	//! magic number: "MDL7"
-	char	ident[4];		
+	char	ident[4];
 
 	//! Version number. Ignored
-	int32_t	version;		
+	int32_t	version;
 
 	//! Number of bones in file
 	uint32_t	bones_num;
@@ -187,13 +187,13 @@ struct Header_MDL7
 	uint32_t	groups_num;
 
 	//! Size of data in the file
-	uint32_t	data_size;	
+	uint32_t	data_size;
 
 	//! Ignored. Used to store entity specific information
-	int32_t	entlump_size;	
+	int32_t	entlump_size;
 
 	//! Ignored. Used to store MED related data
-	int32_t	medlump_size;	
+	int32_t	medlump_size;
 
 	//! Size of the Bone_MDL7 data structure used in the file
 	uint16_t bone_stc_size;
@@ -237,7 +237,7 @@ struct Bone_MDL7
 	//! Index of the parent bone of *this* bone. 0xffff means:
 	//! "hey, I have no parent, I'm an orphan"
 	uint16_t parent_index;
-	uint8_t _unused_[2]; 
+	uint8_t _unused_[2];
 
 	//! Relative position of the bone (relative to the
 	//! parent bone)
@@ -270,21 +270,21 @@ struct Bone_MDL7
 struct Group_MDL7
 {
 	//! = '1' -> triangle based Mesh
-	unsigned char	typ;		
+	unsigned char	typ;
 
 	int8_t	deformers;
 	int8_t	max_weights;
 	int8_t	_unused_;
 
 	//! size of data for this group in bytes ( MD7_GROUP stc. included).
-	int32_t	groupdata_size; 
+	int32_t	groupdata_size;
 	char	name[AI_MDL7_MAX_GROUPNAMESIZE];
 
 	//! Number of skins
 	int32_t	numskins;
 
 	//! Number of texture coordinates
-	int32_t	num_stpts;	
+	int32_t	num_stpts;
 
 	//! Number of triangles
 	int32_t	numtris;
@@ -327,7 +327,7 @@ struct Deformer_MDL7
 struct DeformerElement_MDL7
 {
 	//! bei deformer_typ==0 (==bones) element_index == bone index
-	int32_t	element_index;		
+	int32_t	element_index;
 	char	element_name[AI_MDL7_MAX_BONENAMESIZE];
 	int32_t	weights;
 } PACK_STRUCT;
@@ -340,7 +340,7 @@ struct DeformerElement_MDL7
 struct DeformerWeight_MDL7
 {
 	//! for deformer_typ==0 (==bones) index == vertex index
-	int32_t	index;				
+	int32_t	index;
 	float	weight;
 } PACK_STRUCT;
 
@@ -364,19 +364,19 @@ struct ColorValue_MDL7
 struct Material_MDL7
 {
 	//! Diffuse base color of the material
-	ColorValue_MDL7	Diffuse;        
+	ColorValue_MDL7	Diffuse;
 
 	//! Ambient base color of the material
-    ColorValue_MDL7	Ambient;  
+    ColorValue_MDL7	Ambient;
 
 	//! Specular base color of the material
-    ColorValue_MDL7	Specular;  
+    ColorValue_MDL7	Specular;
 
 	//! Emissive base color of the material
-    ColorValue_MDL7	Emissive; 
+    ColorValue_MDL7	Emissive;
 
 	//! Phong power
-    float			Power;         
+    float			Power;
 } PACK_STRUCT;
 
 
@@ -391,16 +391,16 @@ struct Skin
 	//! fore the size of the data to skip:
 	//-------------------------------------------------------
 	//! 2 for 565 RGB,
-	//! 3 for 4444 ARGB, 
-	//! 10 for 565 mipmapped, 
+	//! 3 for 4444 ARGB,
+	//! 10 for 565 mipmapped,
 	//! 11 for 4444 mipmapped (bpp = 2),
-	//! 12 for 888 RGB mipmapped (bpp = 3), 
+	//! 12 for 888 RGB mipmapped (bpp = 3),
 	//! 13 for 8888 ARGB mipmapped (bpp = 4)
 	//-------------------------------------------------------
-	int32_t group;      
+	int32_t group;
 
 	//! Texture data
-	uint8_t *data;  
+	uint8_t *data;
 } PACK_STRUCT;
 
 
@@ -411,8 +411,8 @@ struct Skin
  */
 struct Skin_MDL5
 {
-	int32_t size, width, height;      
-	uint8_t *data;  
+	int32_t size, width, height;
+	uint8_t *data;
 } PACK_STRUCT;
 
 // maximum length of texture file name
@@ -430,7 +430,7 @@ struct Skin_MDL7
 	int8_t			_unused_[3];
 	int32_t			width;
 	int32_t			height;
-	char			texture_name[AI_MDL7_MAX_TEXNAMESIZE];	
+	char			texture_name[AI_MDL7_MAX_TEXNAMESIZE];
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -463,16 +463,16 @@ struct ARGB4
 struct GroupSkin
 {
 	//! 0 = single (Skin), 1 = group (GroupSkin)
-    int32_t group;     
+    int32_t group;
 
 	//! Number of images
-	int32_t nb;       
+	int32_t nb;
 
 	//! Time for each image
-    float *time;   
+    float *time;
 
 	//! Data of each image
-	uint8_t **data;  
+	uint8_t **data;
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -498,10 +498,10 @@ struct TexCoord
 struct TexCoord_MDL3
 {
 	//! position, horizontally in range 0..skinwidth-1
-	int16_t u; 
+	int16_t u;
 
 	//! position, vertically in range 0..skinheight-1
-	int16_t v; 
+	int16_t v;
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -511,10 +511,10 @@ struct TexCoord_MDL3
 struct TexCoord_MDL7
 {
 	//! position, horizontally in range 0..1
-	float u; 
+	float u;
 
 	//! position, vertically in range 0..1
-	float v; 
+	float v;
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -527,10 +527,10 @@ struct TexCoord_MDL7
 struct SkinSet_MDL7
 {
 	//! Index into the UV coordinate list
-	uint16_t	st_index[3]; // size 6	
+	uint16_t	st_index[3]; // size 6
 
 	//! Material index
-	int32_t		material;	 // size 4				
+	int32_t		material;	 // size 4
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -540,10 +540,10 @@ struct SkinSet_MDL7
 struct Triangle
 {
 	//! 0 = backface, 1 = frontface
-	int32_t facesfront;  
+	int32_t facesfront;
 
 	//! Vertex indices
-	int32_t vertex[3];   
+	int32_t vertex[3];
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -556,7 +556,7 @@ struct Triangle_MDL3
 	uint16_t index_xyz[3];
 
 	//! Index of 3 skin vertices in range 0..numskinverts
-	uint16_t index_uv[3]; 
+	uint16_t index_uv[3];
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -570,17 +570,17 @@ struct Triangle_MDL7
 
 	//! Two skinsets. The second will be used for multi-texturing
 	SkinSet_MDL7  skinsets[2];
-} PACK_STRUCT; 
+} PACK_STRUCT;
 
 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV)
 #	define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t))
-#endif 
+#endif
 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX)
 #	define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX (6+sizeof(SkinSet_MDL7))
-#endif 
+#endif
 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV)
 #	define AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV (6+2*sizeof(SkinSet_MDL7))
-#endif 
+#endif
 
 // Helper constants for Triangle::facesfront
 #if (!defined AI_MDL_BACKFACE)
@@ -634,10 +634,10 @@ struct Vertex_MDL7
 struct BoneTransform_MDL7
 {
 	//! 4*3
-	float	m [4*4];				
+	float	m [4*4];
 
 	//! the index of this vertex, 0.. header::bones_num - 1
-	uint16_t bone_index;		
+	uint16_t bone_index;
 
 	//! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED
 	//! THIS STUPID FILE FORMAT!
@@ -655,8 +655,8 @@ struct BoneTransform_MDL7
 struct Frame_MDL7
 {
 	char	frame_name[AI_MDL7_MAX_FRAMENAMESIZE];
-	uint32_t	vertices_count;			
-	uint32_t	transmatrix_count;		
+	uint32_t	vertices_count;
+	uint32_t	transmatrix_count;
 };
 
 
@@ -667,16 +667,16 @@ struct Frame_MDL7
 struct SimpleFrame
 {
 	//! Minimum vertex of the bounding box
-	Vertex bboxmin; 
+	Vertex bboxmin;
 
 	//! Maximum vertex of the bounding box
-	Vertex bboxmax; 
+	Vertex bboxmax;
 
 	//! Name of the frame
 	char name[16];
 
 	//! Vertex list of the frame
-	Vertex *verts; 
+	Vertex *verts;
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -686,10 +686,10 @@ struct SimpleFrame
 struct Frame
 {
 	//! 0 = simple frame, !0 = group frame
-	int32_t type;       
+	int32_t type;
 
 	//! Frame data
-	SimpleFrame frame;  	      
+	SimpleFrame frame;
 } PACK_STRUCT;
 
 
@@ -697,16 +697,16 @@ struct Frame
 struct SimpleFrame_MDLn_SP
 {
 	//! Minimum vertex of the bounding box
-	Vertex_MDL4 bboxmin; 
+	Vertex_MDL4 bboxmin;
 
 	//! Maximum vertex of the bounding box
-	Vertex_MDL4 bboxmax; 
+	Vertex_MDL4 bboxmax;
 
 	//! Name of the frame
 	char name[16];
 
 	//! Vertex list of the frame
-	Vertex_MDL4 *verts; 
+	Vertex_MDL4 *verts;
 } PACK_STRUCT;
 
 // -------------------------------------------------------------------------------------
@@ -716,19 +716,19 @@ struct SimpleFrame_MDLn_SP
 struct GroupFrame
 {
 	//! 0 = simple frame, !0 = group frame
-	int32_t type;                         
+	int32_t type;
 
 	//! Minimum vertex for all single frames
-	Vertex min;         
+	Vertex min;
 
 	//! Maximum vertex for all single frames
-	Vertex max;         
+	Vertex max;
 
 	//! Time for all single frames
-	float *time;                  
+	float *time;
 
 	//! List of single frames
-	SimpleFrame *frames; 
+	SimpleFrame *frames;
 } PACK_STRUCT;
 
 #include "./../include/assimp/Compiler/poppack1.h"
@@ -752,7 +752,7 @@ struct IntFace_MDL7
 
 	//! Material index (maximally two channels, which are joined later)
 	unsigned int iMatIndex[2];
-}; 
+};
 
 // -------------------------------------------------------------------------------------
 /** \struct IntMaterial_MDL7
@@ -812,7 +812,7 @@ struct IntBone_MDL7 : aiBone
 struct IntFrameInfo_MDL7
 {
 	//! Construction from an existing frame header
-	IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex) 
+	IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex)
 		: iIndex(_iIndex)
 		, pcFrame(_pcFrame)
 	{}
@@ -821,7 +821,7 @@ struct IntFrameInfo_MDL7
 	unsigned int iIndex;
 
 	//! Points to the header of the frame
-	BE_NCONST MDL::Frame_MDL7*	pcFrame; 
+	BE_NCONST MDL::Frame_MDL7*	pcFrame;
 };
 
 // -------------------------------------------------------------------------------------
@@ -829,7 +829,7 @@ struct IntFrameInfo_MDL7
 struct IntGroupInfo_MDL7
 {
 	//! Default constructor
-	IntGroupInfo_MDL7()		
+	IntGroupInfo_MDL7()
 		:	iIndex(0)
 		,	pcGroup(NULL)
 		,	pcGroupUVs(NULL)
@@ -847,13 +847,13 @@ struct IntGroupInfo_MDL7
 	unsigned int iIndex;
 
 	//! Points to the header of the group
-	BE_NCONST MDL::Group_MDL7*		pcGroup; 
+	BE_NCONST MDL::Group_MDL7*		pcGroup;
 
 	//! Points to the beginning of the uv coordinate section
-	BE_NCONST MDL::TexCoord_MDL7*	pcGroupUVs;		
+	BE_NCONST MDL::TexCoord_MDL7*	pcGroupUVs;
 
 	//! Points to the beginning of the triangle section
-	MDL::Triangle_MDL7*	pcGroupTris;		
+	MDL::Triangle_MDL7*	pcGroupTris;
 
 	//! Points to the beginning of the vertex section
 	BE_NCONST MDL::Vertex_MDL7*		pcGroupVerts;
@@ -868,16 +868,16 @@ struct IntGroupData_MDL7
 	{}
 
 	//! Array of faces that belong to the group
-	MDL::IntFace_MDL7* pcFaces;		
+	MDL::IntFace_MDL7* pcFaces;
 
 	//! Array of vertex positions
-	std::vector<aiVector3D>		vPositions;			
+	std::vector<aiVector3D>		vPositions;
 
 	//! Array of vertex normals
-	std::vector<aiVector3D>		vNormals;	
+	std::vector<aiVector3D>		vNormals;
 
 	//! Array of bones indices
-	std::vector<unsigned int>	aiBones;	
+	std::vector<unsigned int>	aiBones;
 
 	//! First UV coordinate set
 	std::vector<aiVector3D>		vTextureCoords1;
@@ -895,7 +895,7 @@ struct IntGroupData_MDL7
 struct IntSharedData_MDL7
 {
 	//! Default constructor
-	IntSharedData_MDL7() 
+	IntSharedData_MDL7()
 	{
 		abNeedMaterials.reserve(10);
 	}
@@ -929,7 +929,7 @@ struct IntSharedData_MDL7
 //! Contains input data for GenerateOutputMeshes_3DGS_MDL7
 struct IntSplitGroupData_MDL7
 {
-	//! Construction from a given shared data set 
+	//! Construction from a given shared data set
 	IntSplitGroupData_MDL7(IntSharedData_MDL7& _shared,
 		std::vector<aiMesh*>& _avOutList)
 
@@ -955,7 +955,7 @@ struct IntSplitGroupData_MDL7
 	//! Shared data for all groups of the model
 	IntSharedData_MDL7& shared;
 
-	//! List of meshes 
+	//! List of meshes
 	std::vector<aiMesh*>& avOutList;
 };
 

+ 6 - 6
code/ObjFileImporter.cpp

@@ -45,12 +45,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "DefaultIOSystem.h"
 #include "ObjFileImporter.h"
 #include "ObjFileParser.h"
-#include "ObjFileData.h"
-#include <boost/scoped_ptr.hpp>
-#include "../include/assimp/Importer.hpp"
-#include "../include/assimp/scene.h"
-#include "../include/assimp/ai_assert.h"
-#include "../include/assimp/DefaultLogger.hpp"
+#include "ObjFileData.h"
+#include <boost/scoped_ptr.hpp>
+#include "../include/assimp/Importer.hpp"
+#include "../include/assimp/scene.h"
+#include "../include/assimp/ai_assert.h"
+#include "../include/assimp/DefaultLogger.hpp"
 
 
 static const aiImporterDesc desc = {

+ 246 - 245
code/ObjFileMtlImporter.cpp

@@ -42,13 +42,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
 
+#include <stdlib.h>
 #include "ObjFileMtlImporter.h"
 #include "ObjTools.h"
 #include "ObjFileData.h"
 #include "fast_atof.h"
-#include "ParsingUtils.h"
-#include "../include/assimp/material.h"
-#include "../include/assimp/DefaultLogger.hpp"
+#include "ParsingUtils.h"
+#include "../include/assimp/material.h"
+#include "../include/assimp/DefaultLogger.hpp"
 
 
 namespace Assimp	{
@@ -85,147 +86,147 @@ static const std::string TypeOption			= "-type";
 // -------------------------------------------------------------------
 //	Constructor
 ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer, 
-									   const std::string & /*strAbsPath*/,
-									   ObjFile::Model *pModel ) :
-	m_DataIt( buffer.begin() ),
-	m_DataItEnd( buffer.end() ),
-	m_pModel( pModel ),
-	m_uiLine( 0 )
+                                       const std::string & /*strAbsPath*/,
+                                       ObjFile::Model *pModel ) :
+    m_DataIt( buffer.begin() ),
+    m_DataItEnd( buffer.end() ),
+    m_pModel( pModel ),
+    m_uiLine( 0 )
 {
-	ai_assert( NULL != m_pModel );
-	if ( NULL == m_pModel->m_pDefaultMaterial )
-	{
-		m_pModel->m_pDefaultMaterial = new ObjFile::Material;
-		m_pModel->m_pDefaultMaterial->MaterialName.Set( "default" );
-	}
-	load();
+    ai_assert( NULL != m_pModel );
+    if ( NULL == m_pModel->m_pDefaultMaterial )
+    {
+        m_pModel->m_pDefaultMaterial = new ObjFile::Material;
+        m_pModel->m_pDefaultMaterial->MaterialName.Set( "default" );
+    }
+    load();
 }
 
 // -------------------------------------------------------------------
 //	Destructor
 ObjFileMtlImporter::~ObjFileMtlImporter()
 {
-	// empty
+    // empty
 }
 
 // -------------------------------------------------------------------
 //	Private copy constructor
 ObjFileMtlImporter::ObjFileMtlImporter(const ObjFileMtlImporter & /* rOther */ )
 {
-	// empty
+    // empty
 }
-	
+    
 // -------------------------------------------------------------------
 //	Private copy constructor
 ObjFileMtlImporter &ObjFileMtlImporter::operator = ( const ObjFileMtlImporter & /*rOther */ )
 {
-	return *this;
+    return *this;
 }
 
 // -------------------------------------------------------------------
 //	Loads the material description
 void ObjFileMtlImporter::load()
 {
-	if ( m_DataIt == m_DataItEnd )
-		return;
-
-	while ( m_DataIt != m_DataItEnd )
-	{
-		switch (*m_DataIt)
-		{
-		case 'k':
-		case 'K':
-			{
-				++m_DataIt;
-				if (*m_DataIt == 'a') // Ambient color
-				{
-					++m_DataIt;
-					getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
-				}
-				else if (*m_DataIt == 'd')	// Diffuse color
-				{
-					++m_DataIt;
-					getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
-				}
-				else if (*m_DataIt == 's')
-				{
-					++m_DataIt;
-					getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
-				}
-				else if (*m_DataIt == 'e')
-				{
-					++m_DataIt;
-					getColorRGBA( &m_pModel->m_pCurrentMaterial->emissive );
-				}
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-
-		case 'd':	// Alpha value
-			{
-				++m_DataIt;
-				getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-
-		case 'N':
-		case 'n':
-			{
-				++m_DataIt;
-				switch(*m_DataIt)
-				{
-				case 's':	// Specular exponent
-					++m_DataIt;
-					getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
-					break;
-				case 'i':	// Index Of refraction
-					++m_DataIt;
-					getFloatValue(m_pModel->m_pCurrentMaterial->ior);
-					break;
-				case 'e':	// New material
-					createMaterial();
-					break;
-				}
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-
-		case 'm':	// Texture
-		case 'b':   // quick'n'dirty - for 'bump' sections
-			{
-				getTexture();
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-
-		case 'i':	// Illumination model
-			{
-				m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
-				getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-
-		default:
-			{
-				m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
-			}
-			break;
-		}
-	}
+    if ( m_DataIt == m_DataItEnd )
+        return;
+
+    while ( m_DataIt != m_DataItEnd )
+    {
+        switch (*m_DataIt)
+        {
+        case 'k':
+        case 'K':
+            {
+                ++m_DataIt;
+                if (*m_DataIt == 'a') // Ambient color
+                {
+                    ++m_DataIt;
+                    getColorRGBA( &m_pModel->m_pCurrentMaterial->ambient );
+                }
+                else if (*m_DataIt == 'd')	// Diffuse color
+                {
+                    ++m_DataIt;
+                    getColorRGBA( &m_pModel->m_pCurrentMaterial->diffuse );
+                }
+                else if (*m_DataIt == 's')
+                {
+                    ++m_DataIt;
+                    getColorRGBA( &m_pModel->m_pCurrentMaterial->specular );
+                }
+                else if (*m_DataIt == 'e')
+                {
+                    ++m_DataIt;
+                    getColorRGBA( &m_pModel->m_pCurrentMaterial->emissive );
+                }
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+
+        case 'd':	// Alpha value
+            {
+                ++m_DataIt;
+                getFloatValue( m_pModel->m_pCurrentMaterial->alpha );
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+
+        case 'N':
+        case 'n':
+            {
+                ++m_DataIt;
+                switch(*m_DataIt)
+                {
+                case 's':	// Specular exponent
+                    ++m_DataIt;
+                    getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
+                    break;
+                case 'i':	// Index Of refraction
+                    ++m_DataIt;
+                    getFloatValue(m_pModel->m_pCurrentMaterial->ior);
+                    break;
+                case 'e':	// New material
+                    createMaterial();
+                    break;
+                }
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+
+        case 'm':	// Texture
+        case 'b':   // quick'n'dirty - for 'bump' sections
+            {
+                getTexture();
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+
+        case 'i':	// Illumination model
+            {
+                m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
+                getIlluminationModel( m_pModel->m_pCurrentMaterial->illumination_model );
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+
+        default:
+            {
+                m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
+            }
+            break;
+        }
+    }
 }
 
 // -------------------------------------------------------------------
 //	Loads a color definition
 void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
 {
-	ai_assert( NULL != pColor );
-	
-	float r( 0.0f ), g( 0.0f ), b( 0.0f );
-	m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
-	pColor->r = r;
-	
+    ai_assert( NULL != pColor );
+    
+    float r( 0.0f ), g( 0.0f ), b( 0.0f );
+    m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, r );
+    pColor->r = r;
+    
     // we have to check if color is default 0 with only one token
     if( !IsLineEnd( *m_DataIt ) ) {
         m_DataIt = getFloat<DataArrayIt>( m_DataIt, m_DataItEnd, g );
@@ -239,107 +240,107 @@ void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor )
 //	Loads the kind of illumination model.
 void ObjFileMtlImporter::getIlluminationModel( int &illum_model )
 {
-	m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
-	illum_model = atoi(m_buffer);
+    m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
+    illum_model = atoi(m_buffer);
 }
 
 // -------------------------------------------------------------------
 //	Loads a single float value. 
 void ObjFileMtlImporter::getFloatValue( float &value )
 {
-	m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
-	value = (float) fast_atof(m_buffer);
+    m_DataIt = CopyNextWord<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
+    value = (float) fast_atof(m_buffer);
 }
 
 // -------------------------------------------------------------------
 //	Creates a material from loaded data.
 void ObjFileMtlImporter::createMaterial()
 {	
-	std::string line( "" );
+    std::string line( "" );
     while( !IsLineEnd( *m_DataIt ) ) {
-		line += *m_DataIt;
-		++m_DataIt;
-	}
-	
-	std::vector<std::string> token;
-	const unsigned int numToken = tokenize<std::string>( line, token, " " );
-	std::string name( "" );
-	if ( numToken == 1 ) {
-		name = AI_DEFAULT_MATERIAL_NAME;
-	} else {
-		name = token[ 1 ];
-	}
-
-	std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
-	if ( m_pModel->m_MaterialMap.end() == it) {
-		// New Material created
-		m_pModel->m_pCurrentMaterial = new ObjFile::Material();	
-		m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
-		m_pModel->m_MaterialLib.push_back( name );
-		m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
-	} else {
-		// Use older material
-		m_pModel->m_pCurrentMaterial = (*it).second;
-	}
+        line += *m_DataIt;
+        ++m_DataIt;
+    }
+    
+    std::vector<std::string> token;
+    const unsigned int numToken = tokenize<std::string>( line, token, " " );
+    std::string name( "" );
+    if ( numToken == 1 ) {
+        name = AI_DEFAULT_MATERIAL_NAME;
+    } else {
+        name = token[ 1 ];
+    }
+
+    std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( name );
+    if ( m_pModel->m_MaterialMap.end() == it) {
+        // New Material created
+        m_pModel->m_pCurrentMaterial = new ObjFile::Material();	
+        m_pModel->m_pCurrentMaterial->MaterialName.Set( name );
+        m_pModel->m_MaterialLib.push_back( name );
+        m_pModel->m_MaterialMap[ name ] = m_pModel->m_pCurrentMaterial;
+    } else {
+        // Use older material
+        m_pModel->m_pCurrentMaterial = (*it).second;
+    }
 }
 
 // -------------------------------------------------------------------
 //	Gets a texture name from data.
 void ObjFileMtlImporter::getTexture() {
-	aiString *out( NULL );
-	int clampIndex = -1;
-
-	const char *pPtr( &(*m_DataIt) );
-	if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
-		// Diffuse texture
-		out = & m_pModel->m_pCurrentMaterial->texture;
-		clampIndex = ObjFile::Material::TextureDiffuseType;
-	} else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
-		// Ambient texture
-		out = & m_pModel->m_pCurrentMaterial->textureAmbient;
-		clampIndex = ObjFile::Material::TextureAmbientType;
-	} else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
-		// Specular texture
-		out = & m_pModel->m_pCurrentMaterial->textureSpecular;
-		clampIndex = ObjFile::Material::TextureSpecularType;
-	} else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
-		// Opacity texture
-		out = & m_pModel->m_pCurrentMaterial->textureOpacity;
-		clampIndex = ObjFile::Material::TextureOpacityType;
-	} else if (!ASSIMP_strincmp( pPtr, EmmissiveTexture.c_str(), EmmissiveTexture.size())) {
-		// Emissive texture
-		out = & m_pModel->m_pCurrentMaterial->textureEmissive;
-		clampIndex = ObjFile::Material::TextureEmissiveType;
-	} else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
-		        !ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) || 
-		        !ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
-		// Bump texture 
-		out = & m_pModel->m_pCurrentMaterial->textureBump;
-		clampIndex = ObjFile::Material::TextureBumpType;
-	} else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) { 
-		// Normal map
-		out = & m_pModel->m_pCurrentMaterial->textureNormal;
-		clampIndex = ObjFile::Material::TextureNormalType;
-	} else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
-		// Displacement texture
-		out = &m_pModel->m_pCurrentMaterial->textureDisp;
-		clampIndex = ObjFile::Material::TextureDispType;
-	} else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
-		// Specularity scaling (glossiness)
-		out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
-		clampIndex = ObjFile::Material::TextureSpecularityType;
-	} else {
-		DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
-		return;
-	}
-
-	bool clamp = false;
-	getTextureOption(clamp);
-	m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
-
-	std::string strTexture;
-	m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
-	out->Set( strTexture );
+    aiString *out( NULL );
+    int clampIndex = -1;
+
+    const char *pPtr( &(*m_DataIt) );
+    if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
+        // Diffuse texture
+        out = & m_pModel->m_pCurrentMaterial->texture;
+        clampIndex = ObjFile::Material::TextureDiffuseType;
+    } else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
+        // Ambient texture
+        out = & m_pModel->m_pCurrentMaterial->textureAmbient;
+        clampIndex = ObjFile::Material::TextureAmbientType;
+    } else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
+        // Specular texture
+        out = & m_pModel->m_pCurrentMaterial->textureSpecular;
+        clampIndex = ObjFile::Material::TextureSpecularType;
+    } else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
+        // Opacity texture
+        out = & m_pModel->m_pCurrentMaterial->textureOpacity;
+        clampIndex = ObjFile::Material::TextureOpacityType;
+    } else if (!ASSIMP_strincmp( pPtr, EmmissiveTexture.c_str(), EmmissiveTexture.size())) {
+        // Emissive texture
+        out = & m_pModel->m_pCurrentMaterial->textureEmissive;
+        clampIndex = ObjFile::Material::TextureEmissiveType;
+    } else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
+                !ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) || 
+                !ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
+        // Bump texture 
+        out = & m_pModel->m_pCurrentMaterial->textureBump;
+        clampIndex = ObjFile::Material::TextureBumpType;
+    } else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) { 
+        // Normal map
+        out = & m_pModel->m_pCurrentMaterial->textureNormal;
+        clampIndex = ObjFile::Material::TextureNormalType;
+    } else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
+        // Displacement texture
+        out = &m_pModel->m_pCurrentMaterial->textureDisp;
+        clampIndex = ObjFile::Material::TextureDispType;
+    } else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
+        // Specularity scaling (glossiness)
+        out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
+        clampIndex = ObjFile::Material::TextureSpecularityType;
+    } else {
+        DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
+        return;
+    }
+
+    bool clamp = false;
+    getTextureOption(clamp);
+    m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
+
+    std::string strTexture;
+    m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
+    out->Set( strTexture );
 }
 
 /* /////////////////////////////////////////////////////////////////////////////
@@ -359,54 +360,54 @@ void ObjFileMtlImporter::getTexture() {
  */
 void ObjFileMtlImporter::getTextureOption(bool &clamp)
 {
-	m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
-
-	//If there is any more texture option
-	while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-')
-	{
-		const char *pPtr( &(*m_DataIt) );
-		//skip option key and value
-		int skipToken = 1;
-
-		if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), ClampOption.size()))
-		{
-			DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
-			char value[3];
-			CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
-			if (!ASSIMP_strincmp(value, "on", 2))
-			{
-				clamp = true;
-			}
-
-			skipToken = 2;
-		}
-		else if (  !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
-				|| !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), BlendVOption.size())
-				|| !ASSIMP_strincmp(pPtr, BoostOption.c_str(), BoostOption.size())
-				|| !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), ResolutionOption.size())
-				|| !ASSIMP_strincmp(pPtr, BumpOption.c_str(), BumpOption.size())
-				|| !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size())
-				|| !ASSIMP_strincmp(pPtr, TypeOption.c_str(), TypeOption.size()) )
-		{
-			skipToken = 2;
-		}
-		else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), ModifyMapOption.size()))
-		{
-			skipToken = 3;
-		}
-		else if (  !ASSIMP_strincmp(pPtr, OffsetOption.c_str(), OffsetOption.size())
-				|| !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), ScaleOption.size())
-				|| !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), TurbulenceOption.size())
-				)
-		{
-			skipToken = 4;
-		}
-
-		for (int i = 0; i < skipToken; ++i)
-		{
-			m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
-		}
-	}
+    m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
+
+    //If there is any more texture option
+    while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-')
+    {
+        const char *pPtr( &(*m_DataIt) );
+        //skip option key and value
+        int skipToken = 1;
+
+        if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), ClampOption.size()))
+        {
+            DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
+            char value[3];
+            CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
+            if (!ASSIMP_strincmp(value, "on", 2))
+            {
+                clamp = true;
+            }
+
+            skipToken = 2;
+        }
+        else if (  !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
+                || !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), BlendVOption.size())
+                || !ASSIMP_strincmp(pPtr, BoostOption.c_str(), BoostOption.size())
+                || !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), ResolutionOption.size())
+                || !ASSIMP_strincmp(pPtr, BumpOption.c_str(), BumpOption.size())
+                || !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size())
+                || !ASSIMP_strincmp(pPtr, TypeOption.c_str(), TypeOption.size()) )
+        {
+            skipToken = 2;
+        }
+        else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), ModifyMapOption.size()))
+        {
+            skipToken = 3;
+        }
+        else if (  !ASSIMP_strincmp(pPtr, OffsetOption.c_str(), OffsetOption.size())
+                || !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), ScaleOption.size())
+                || !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), TurbulenceOption.size())
+                )
+        {
+            skipToken = 4;
+        }
+
+        for (int i = 0; i < skipToken; ++i)
+        {
+            m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
+        }
+    }
 }
 
 // -------------------------------------------------------------------

+ 1 - 0
code/ObjFileParser.cpp

@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "../include/assimp/DefaultLogger.hpp"
 #include "../include/assimp/material.h"
 #include "../include/assimp/Importer.hpp"
+#include <cstdlib>
 
 
 namespace Assimp {

+ 55 - 37
code/OpenGEXImporter.cpp

@@ -44,8 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "MakeVerboseFormat.h"
 
 #include <openddlparser/OpenDDLParser.h>
-#include "../include/assimp/scene.h"
-
+#include <assimp/scene.h>
+#include <assimp/ai_assert.h>
 
 #include <vector>
 
@@ -80,6 +80,10 @@ namespace Grammar {
     static const char *IndexArrayType      = "IndexArray";
     static const char *MaterialType        = "Material";
     static const char *ColorType           = "Color";
+    static const std::string DiffuseColorToken = "diffuse";
+    static const std::string SpecularColorToken = "specular";
+    static const std::string EmissionColorToken = "emission";
+
     static const char *TextureType         = "Texture";
 
     enum TokenType {
@@ -363,9 +367,9 @@ void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene *pScene ) {
 
     Property *prop( node->getProperties() );
     while( NULL != prop ) {
-        if( NULL != prop->m_id ) {
-            if( Value::ddl_string == prop->m_primData->m_type ) {
-                std::string valName( (char*) prop->m_primData->m_data );
+        if( NULL != prop->m_key ) {
+            if( Value::ddl_string == prop->m_value->m_type ) {
+                std::string valName( ( char* ) prop->m_value->m_data );
                 int type( Grammar::isValidMetricType( valName.c_str() ) );
                 if( Grammar::NoneType != type ) {
                     Value *val( node->getValue() );
@@ -415,7 +419,7 @@ static void getRefNames( DDLNode *node, std::vector<std::string> &names ) {
         for( size_t i = 0; i < ref->m_numRefs; i++ )  {
             Name *currentName( ref->m_referencedName[ i ] );
             if( NULL != currentName && NULL != currentName->m_id ) {
-                const std::string name( currentName->m_id->m_buffer );
+                const std::string name( currentName->m_id->m_text.m_buffer );
                 if( !name.empty() ) {
                     names.push_back( name );
                 }
@@ -530,10 +534,10 @@ static void propId2StdString( Property *prop, std::string &name, std::string &ke
         return;
     }
 
-    if( NULL != prop->m_id ) {
-        name = prop->m_id->m_buffer;
-        if( Value::ddl_string == prop->m_primData->m_type ) {
-            key = prop->m_primData->getString();
+    if( NULL != prop->m_key ) {
+        name = prop->m_key->m_text.m_buffer;
+        if( Value::ddl_string == prop->m_value->m_type ) {
+            key = prop->m_value->getString();
         }
     }
 }
@@ -705,7 +709,7 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
         Value *next( vaList->m_dataList );
         for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
             const int idx = next->getInt32();
-            ai_assert( idx <= m_currentVertices.m_numVerts );
+            ai_assert( static_cast<size_t>( idx ) <= m_currentVertices.m_numVerts );
 
             aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
             aiVector3D &normal = ( m_currentVertices.m_normals[ idx ] );
@@ -725,30 +729,36 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
 }
 
 //------------------------------------------------------------------------------------------------
-static void getColorRGBA( aiColor3D *pColor, Value *data ) {
-    if( NULL == pColor || NULL == data ) {
+static void getColorRGB( aiColor3D *pColor, DataArrayList *colList ) {
+    if( NULL == pColor || NULL == colList ) {
         return;
     }
-
-    pColor->r = data->getFloat();
-    data = data->getNext();
-    pColor->g = data->getFloat();
-    data = data->getNext();
-    pColor->b = data->getFloat();
-    data = data->getNext();
+    
+    ai_assert( 3 == colList->m_numItems );
+    Value *val( colList->m_dataList );
+    pColor->r = val->getFloat();
+    val = val->getNext();
+    pColor->g = val->getFloat();
+    val = val->getNext();
+    pColor->b = val->getFloat();
 }
 
 //------------------------------------------------------------------------------------------------
 enum ColorType {
     NoneColor = 0,
-    DiffuseColor
+    DiffuseColor,
+    SpecularColor,
+    EmissionColor
 };
 
 //------------------------------------------------------------------------------------------------
 static ColorType getColorType( Identifier *id ) {
-    const int res(strncmp("diffuse", id->m_buffer, id->m_len ) );
-    if( 0 == res ) {
+    if( id->m_text == Grammar::DiffuseColorToken ) {
         return DiffuseColor;
+    } else if( id->m_text == Grammar::SpecularColorToken ) {
+        return SpecularColor;
+    } else if( id->m_text == Grammar::EmissionColorToken ) {
+        return EmissionColor;
     }
 
     return NoneColor;
@@ -769,9 +779,23 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen
         return;
     }
 
-    Property *colorProp = node->getProperties();
-    if( NULL != colorProp ) {
-        if( NULL != colorProp->m_id ) {
+    Property *prop = node->findPropertyByName( "attrib" );
+    if( NULL != prop ) {
+        if( NULL != prop->m_value ) {
+            DataArrayList *colList( node->getDataArrayList() );
+            if( NULL == colList ) {
+                return;
+            }
+            aiColor3D col;
+            getColorRGB( &col, colList );
+            const ColorType colType( getColorType( prop->m_key ) );
+            if( DiffuseColor == colType ) {
+                m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_DIFFUSE );
+            } else if( SpecularColor == colType ) {
+                m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_SPECULAR );
+            } else if( EmissionColor == colType ) {
+                m_currentMaterial->AddProperty( &col, 1, AI_MATKEY_COLOR_EMISSIVE );
+            }
         }
     }
 }
@@ -786,13 +810,10 @@ void OpenGEXImporter::copyMeshes( aiScene *pScene ) {
     if( m_meshCache.empty() ) {
         return;
     }
+    
     pScene->mNumMeshes = m_meshCache.size();
     pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
-    size_t i( 0 );
-    for( std::vector<aiMesh*>::iterator it = m_meshCache.begin(); it != m_meshCache.end(); it++ ) {
-        pScene->mMeshes[ i ] = *it;
-        i++;
-    }
+    std::copy( m_meshCache.begin(), m_meshCache.end(), pScene->mMeshes );
 }
 
 //------------------------------------------------------------------------------------------------
@@ -833,13 +854,10 @@ void OpenGEXImporter::createNodeTree( aiScene *pScene ) {
     if( m_root->m_children.empty() ) {
         return;
     }
-    size_t i( 0 );
+
     pScene->mRootNode->mNumChildren = m_root->m_children.size();
-    pScene->mRootNode->mChildren = new C_STRUCT aiNode*[ pScene->mRootNode->mNumChildren ];
-    for( ChildInfo::NodeList::iterator it = m_root->m_children.begin(); it != m_root->m_children.end(); it++ ) {
-        pScene->mRootNode->mChildren[ i ] = *it;
-        i++;
-    }
+    pScene->mRootNode->mChildren = new aiNode*[ pScene->mRootNode->mNumChildren ];
+    std::copy( m_root->m_children.begin(), m_root->m_children.end(), pScene->mRootNode->mChildren );
 }
 
 //------------------------------------------------------------------------------------------------

+ 1 - 1
code/OpenGEXImporter.h

@@ -43,7 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef ASSIMP_BUILD_NO_OPENGEX_IMPORTER
 
 #include "BaseImporter.h"
-#include "../include/assimp/mesh.h"
+#include <assimp/mesh.h>
 
 #include <vector>
 #include <list>

+ 9 - 5
code/PlyExporter.cpp

@@ -44,11 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "PlyExporter.h"
 #include <boost/scoped_ptr.hpp>
+#include <cmath>
 #include "Exceptional.h"
 #include "../include/assimp/scene.h"
 #include "../include/assimp/version.h"
 #include "../include/assimp/IOSystem.hpp"
-#include "../include/assimp/Exporter.hpp"
+#include "../include/assimp/Exporter.hpp"
+#include "qnan.h"
 
 
 using namespace Assimp;
@@ -213,6 +215,8 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
 // ------------------------------------------------------------------------------------------------
 void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
 {
+	static const float inf = std::numeric_limits<float>::infinity();
+	
 	// If a component (for instance normal vectors) is present in at least one mesh in the scene,
 	// then default values are written for meshes that do not contain this component.
 	for (unsigned int i = 0; i < m->mNumVertices; ++i) {
@@ -222,11 +226,11 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
 			m->mVertices[i].z
 		;
 		if(components & PLY_EXPORT_HAS_NORMALS) {
-			if (m->HasNormals()) {
+			if (m->HasNormals() && is_not_qnan(m->mNormals[i].x) && std::fabs(m->mNormals[i].x) != inf) {
 				mOutput << 
-				" " << m->mNormals[i].x << 
-				" " << m->mNormals[i].y << 
-				" " << m->mNormals[i].z;
+					" " << m->mNormals[i].x << 
+					" " << m->mNormals[i].y << 
+					" " << m->mNormals[i].z;
 			}
 			else {
 				mOutput << " 0.0 0.0 0.0"; 

+ 1 - 1
code/PlyParser.cpp

@@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "PlyLoader.h"
 #include "fast_atof.h"
 #include "../include/assimp/DefaultLogger.hpp"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 
 using namespace Assimp;

+ 3 - 2
code/Q3BSPZipArchive.cpp

@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "Q3BSPZipArchive.h"
 #include <algorithm>
 #include <cassert>
+#include <cstdlib>
 #include "../include/assimp/ai_assert.h"
 
 
@@ -140,11 +141,11 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem* pIOHandler) {
 ZipFile::ZipFile(size_t size) : m_Size(size) {
 	ai_assert(m_Size != 0);
 
-	m_Buffer = std::malloc(m_Size);
+	m_Buffer = malloc(m_Size);
 }
 	
 ZipFile::~ZipFile() {
-	std::free(m_Buffer);
+	free(m_Buffer);
 	m_Buffer = NULL;
 }
 

+ 1 - 1
code/STEPFileEncoding.cpp

@@ -332,7 +332,7 @@ bool STEP::StringToUTF8(std::string& s)
 				case '4':
 					if (s[i+3] == '\\') {
 						const size_t basei = i+4;
-						size_t j = basei, jend = s.size()-4;						
+						size_t j = basei, jend = s.size()-3;				
 
 						for (; j < jend; ++j) {
 							if (s[j] == '\\' && s[j] == 'X' && s[j] == '0' && s[j] == '\\') {

+ 1 - 1
code/STLExporter.cpp

@@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "../include/assimp/Exporter.hpp"
 #include <boost/scoped_ptr.hpp>
 #include "Exceptional.h"
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 
 using namespace Assimp;
 namespace Assimp	{

+ 1 - 1
code/SceneCombiner.cpp

@@ -920,7 +920,7 @@ void SceneCombiner::MergeMaterials(aiMaterial** dest,
 
 			// Test if we already have a matching property 
 			const aiMaterialProperty* prop_exist;
-			if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mType, sprop->mIndex, &prop_exist) != AI_SUCCESS) {
+			if(aiGetMaterialProperty(out, sprop->mKey.C_Str(), sprop->mSemantic, sprop->mIndex, &prop_exist) != AI_SUCCESS) {
 				// If not, we add it to the new material
 				aiMaterialProperty* prop = out->mProperties[out->mNumProperties] = new aiMaterialProperty();
 

+ 23 - 23
code/StreamReader.h

@@ -7,8 +7,8 @@ Copyright (c) 2006-2012, assimp team
 
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the following 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
 conditions are met:
 
 * Redistributions of source code must retain the above
@@ -25,16 +25,16 @@ conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
@@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef AI_STREAMREADER_H_INCLUDED
 #define AI_STREAMREADER_H_INCLUDED
 
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "Exceptional.h"
 #include <boost/shared_ptr.hpp>
 #include "../include/assimp/IOStream.hpp"
@@ -54,12 +54,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 namespace Assimp {
 
 // --------------------------------------------------------------------------------------------
-/** Wrapper class around IOStream to allow for consistent reading of binary data in both 
- *  little and big endian format. Don't attempt to instance the template directly. Use 
- *  StreamReaderLE to read from a little-endian stream and StreamReaderBE to read from a 
- *  BE stream. The class expects that the endianess of any input data is known at 
+/** Wrapper class around IOStream to allow for consistent reading of binary data in both
+ *  little and big endian format. Don't attempt to instance the template directly. Use
+ *  StreamReaderLE to read from a little-endian stream and StreamReaderBE to read from a
+ *  BE stream. The class expects that the endianess of any input data is known at
  *  compile-time, which should usually be true (#BaseImporter::ConvertToUTF8 implements
- *  runtime endianess conversions for text files). 
+ *  runtime endianess conversions for text files).
  *
  *  XXX switch from unsigned int for size types to size_t? or ptrdiff_t?*/
 // --------------------------------------------------------------------------------------------
@@ -71,7 +71,7 @@ public:
 
 	// FIXME: use these data types throughout the whole library,
 	// then change them to 64 bit values :-)
-	
+
 	typedef int diff;
 	typedef unsigned int pos;
 
@@ -80,7 +80,7 @@ public:
 
 	// ---------------------------------------------------------------------
 	/** Construction from a given stream with a well-defined endianess.
-	 * 
+	 *
 	 *  The StreamReader holds a permanent strong reference to the
 	 *  stream, which is released upon destruction.
 	 *  @param stream Input stream. The stream is not restarted if
@@ -94,7 +94,7 @@ public:
 		: stream(stream)
 		, le(le)
 	{
-		ai_assert(stream); 
+		ai_assert(stream);
 		InternBegin();
 	}
 
@@ -213,8 +213,8 @@ public:
 
 	// ---------------------------------------------------------------------
 	/** Set current file pointer (Get it from #GetPtr). This is if you
-	 *  prefer to do pointer arithmetics on your own or want to copy 
-	 *  large chunks of data at once. 
+	 *  prefer to do pointer arithmetics on your own or want to copy
+	 *  large chunks of data at once.
 	 *  @param p The new pointer, which is validated against the size
 	 *    limit and buffer boundaries. */
 	void SetPtr(int8_t* p)	{
@@ -250,7 +250,7 @@ public:
 
 	// ---------------------------------------------------------------------
 	/** Setup a temporary read limit
-	 * 
+	 *
 	 *  @param limit Maximum number of bytes to be read from
 	 *    the beginning of the file. Specifying UINT_MAX
 	 *    resets the limit to the original end of the stream. */
@@ -285,7 +285,7 @@ public:
 	/** overload operator>> and allow chaining of >> ops. */
 	template <typename T>
 	StreamReader& operator >> (T& f) {
-		f = Get<T>(); 
+		f = Get<T>();
 		return *this;
 	}
 
@@ -304,7 +304,7 @@ private:
 		memcpy (&f, current, sizeof(T));
 #else
 		T f = *((const T*)current);
-#endif	
+#endif
 		Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f,le);
 
 		current += sizeof(T);

+ 17 - 17
code/StreamWriter.h

@@ -7,8 +7,8 @@ Copyright (c) 2006-2012, assimp team
 
 All rights reserved.
 
-Redistribution and use of this software in source and binary forms, 
-with or without modification, are permitted provided that the following 
+Redistribution and use of this software in source and binary forms,
+with or without modification, are permitted provided that the following
 conditions are met:
 
 * Redistributions of source code must retain the above
@@ -25,16 +25,16 @@ conditions are met:
   derived from this software without specific prior
   written permission of the assimp team.
 
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
@@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef AI_STREAMWRITER_H_INCLUDED
 #define AI_STREAMWRITER_H_INCLUDED
 
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "../include/assimp/IOStream.hpp"
 
 #include <boost/shared_ptr.hpp>
@@ -54,9 +54,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 namespace Assimp {
 
 // --------------------------------------------------------------------------------------------
-/** Wrapper class around IOStream to allow for consistent writing of binary data in both 
- *  little and big endian format. Don't attempt to instance the template directly. Use 
- *  StreamWriterLE to read from a little-endian stream and StreamWriterBE to read from a 
+/** Wrapper class around IOStream to allow for consistent writing of binary data in both
+ *  little and big endian format. Don't attempt to instance the template directly. Use
+ *  StreamWriterLE to read from a little-endian stream and StreamWriterBE to read from a
  *  BE stream. Alternatively, there is StreamWriterAny if the endianess of the output
  *  stream is to be determined at runtime.
  */
@@ -72,7 +72,7 @@ public:
 
 	// ---------------------------------------------------------------------
 	/** Construction from a given stream with a well-defined endianess.
-	 * 
+	 *
 	 *  The StreamReader holds a permanent strong reference to the
 	 *  stream, which is released upon destruction.
 	 *  @param stream Input stream. The stream is not re-seeked and writing
@@ -86,7 +86,7 @@ public:
 		, le(le)
 		, cursor()
 	{
-		ai_assert(stream); 
+		ai_assert(stream);
 		buffer.reserve(INITIAL_CAPACITY);
 	}
 
@@ -175,7 +175,7 @@ public:
 	/** overload operator<< and allow chaining of MM ops. */
 	template <typename T>
 	StreamWriter& operator << (T f) {
-		Put(f); 
+		Put(f);
 		return *this;
 	}
 
@@ -196,7 +196,7 @@ private:
 	template <typename T>
 	void Put(T f)	{
 		Intern :: Getter<SwapEndianess,T,RuntimeSwitch>() (&f, le);
-		
+
 		if (cursor + sizeof(T) >= buffer.size()) {
 			buffer.resize(cursor + sizeof(T));
 		}

+ 2 - 0
code/StringComparison.h

@@ -51,6 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define INCLUDED_AI_STRING_WORKERS_H
 
 #include "../include/assimp/ai_assert.h"
+#include "StringComparison.h"
+
 #include <string.h>
 #include <stdint.h>
 #include <string>

+ 5 - 4
code/TextureTransform.cpp

@@ -42,11 +42,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 
-#include "TextureTransform.h"
-#include "../include/assimp/postprocess.h"
-#include "../include/assimp/DefaultLogger.hpp"
-#include "../include/assimp/scene.h"
+#include <assimp/Importer.hpp>
+#include <assimp/postprocess.h>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/scene.h>
 
+#include "TextureTransform.h"
 
 using namespace Assimp;
 

+ 8 - 5
code/UnrealLoader.cpp

@@ -54,11 +54,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "StreamReader.h"
 #include "ParsingUtils.h"
 #include "fast_atof.h"
-#include "ConvertToLHProcess.h"
-#include "../include/assimp/DefaultLogger.hpp"
-#include "../include/assimp/IOSystem.hpp"
-#include "../include/assimp/scene.h"
-#include <boost/scoped_ptr.hpp>
+#include "ConvertToLHProcess.h"
+
+#include <assimp/Importer.hpp>
+#include <assimp/DefaultLogger.hpp>
+#include <assimp/IOSystem.hpp>
+#include <assimp/scene.h>
+
+#include <boost/scoped_ptr.hpp>
 
 using namespace Assimp;
 

+ 1 - 1
code/XFileParser.cpp

@@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "Exceptional.h"
 #include <boost/format.hpp>
 #include <boost/lexical_cast.hpp>
-#include "ByteSwap.h"
+#include "ByteSwapper.h"
 #include "../include/assimp/DefaultLogger.hpp"
 
 

+ 3 - 3
code/fast_atof.h

@@ -255,7 +255,7 @@ inline int64_t strtol10_64(const char* in, const char** out = 0, unsigned int* m
 // If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
 // ------------------------------------------------------------------------------------
 template <typename Real>
-inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma = true)
+inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true)
 {
 	Real f = 0;
 
@@ -286,14 +286,14 @@ inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma
 	}
 
 	if (!(c[0] >= '0' && c[0] <= '9') &&
-	    !(c[0] == '.' && c[1] >= '0' && c[1] <= '9'))
+	    !((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9'))
 	{
 		throw std::invalid_argument("Cannot parse string "
 		                            "as real number: does not start with digit "
 		                            "or decimal point followed by digit.");
 	}
 
-	if (*c != '.')
+	if (*c != '.' && (! check_comma || c[0] != ','))
 	{
 		f = static_cast<Real>( strtoul10_64 ( c, &c) );
 	}

+ 1 - 1
contrib/openddlparser/code/DDLNode.cpp

@@ -153,7 +153,7 @@ Property *DDLNode::findPropertyByName( const std::string &name ) {
     }
     Property *current( m_properties );
     while( ddl_nullptr != current ) {
-        int res = strncmp( current->m_id->m_buffer, name.c_str(), name.size() );
+        int res = strncmp( current->m_key->m_text.m_buffer, name.c_str(), name.size() );
         if( 0 == res ) {
             return current;
         }

+ 6 - 10
contrib/openddlparser/code/OpenDDLParser.cpp

@@ -87,7 +87,7 @@ static DDLNode *createDDLNode( Identifier *id, OpenDDLParser *parser ) {
         return ddl_nullptr;
     }
 
-    const std::string type( id->m_buffer );
+    const std::string type( id->m_text.m_buffer );
     DDLNode *parent( parser->top() );
     DDLNode *node = DDLNode::create( type, "", parent );
 
@@ -191,8 +191,6 @@ bool OpenDDLParser::parse() {
     
     normalizeBuffer( m_buffer );
 
-    std::cout << &m_buffer[0] << std::endl;
-
     m_context = new Context;
     m_context->m_root = DDLNode::create( "root", "", ddl_nullptr );
     pushNode( m_context->m_root );
@@ -217,7 +215,7 @@ char *OpenDDLParser::parseNextNode( char *in, char *end ) {
 
 static void dumpId( Identifier *id ) {
     if( ddl_nullptr != id ) {
-        std::cout << id->m_buffer << std::endl;
+        std::cout << id->m_text.m_buffer << std::endl;
     }
 }
 
@@ -277,7 +275,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
         Name *name( ddl_nullptr );
         in = OpenDDLParser::parseName( in, end, &name );
         if( ddl_nullptr != name ) {
-            const std::string nodeName( name->m_id->m_buffer );
+            const std::string nodeName( name->m_id->m_text.m_buffer );
             node->setName( nodeName );
         }
     }
@@ -500,10 +498,8 @@ char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
         idLen++;
     }
     
-    const size_t len( idLen + 1 );
-    Identifier *newId = new Identifier( len, new char[ len ] );
-    ::strncpy( newId->m_buffer, start, newId->m_len-1 );
-    newId->m_buffer[ newId->m_len - 1 ] = '\0';
+    const size_t len( idLen );
+    Identifier *newId = new Identifier( start, len );
     *id = newId;
 
     return in;
@@ -714,7 +710,7 @@ char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData
 static void createPropertyWithData( Identifier *id, Value *primData, Property **prop ) {
     if( ddl_nullptr != primData ) {
         ( *prop ) = new Property( id );
-        ( *prop )->m_primData = primData;
+        ( *prop )->m_value = primData;
     }
 }
 

+ 69 - 41
contrib/openddlparser/include/openddlparser/OpenDDLCommon.h

@@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <cstddef>
 #include <vector>
+#include <string>
 
 #include <string.h>
 
@@ -77,41 +78,83 @@ enum NameType {
     LocalName
 };
 
-struct Token {
-public:
-    Token( const char *token )
-    : m_token( token )
-    , m_size( 0 ){
-        if( ddl_nullptr != token ) {
-            m_size = strlen( m_token );
-        }
+struct Text {
+    size_t m_capacity;
+    size_t m_len;
+    char *m_buffer;
+
+    Text( const char *buffer, size_t numChars )
+    : m_capacity( 0 )
+    , m_len( 0 )
+    , m_buffer( ddl_nullptr ) {
+        set( buffer, numChars );
     }
-    
-    ~Token() {
-        // empty
+
+    ~Text() {
+        clear();
+    }
+
+    void clear() {
+        delete[] m_buffer;
+        m_buffer = ddl_nullptr;
+        m_capacity = 0;
+        m_len = 0;
+    }
+
+    void set( const char *buffer, size_t numChars ) {
+        clear();
+        if( numChars > 0 ) {
+            m_len = numChars;
+            m_capacity = m_len + 1;
+            m_buffer = new char[ m_capacity ];
+            strncpy( m_buffer, buffer, numChars );
+            m_buffer[ numChars ] = '\0';
+        }
     }
 
-    size_t length() const {
-        return m_size;
+    bool operator == ( const std::string &name ) const {
+        if( m_len != name.size() ) {
+            return false;
+        }
+        const int res( strncmp( m_buffer, name.c_str(), name.size() ) );
+        return ( 0 == res );
+
     }
 
-    bool operator == ( const Token &rhs ) const {
-        if( m_size != rhs.m_size ) {
+    bool operator == ( const Text &rhs ) const {
+        if( m_len != rhs.m_len ) {
             return false;
         }
 
-        const int res( strncmp( m_token, rhs.m_token, m_size ) );
-        return ( res == 0 );
+        const int res ( strncmp( m_buffer, rhs.m_buffer, m_len ) );
+        return ( 0 == res );
     }
 
 private:
-    Token();
-    Token( const Token  & );
-    Token &operator = ( const Token & );
+    Text( const Text & );
+    Text &operator = ( const Text & );
+};
+
+struct Identifier {
+    Text m_text;
+
+    Identifier( char buffer[], size_t len )
+        : m_text( buffer, len ) {
+        // empty
+    }
+
+    Identifier( char buffer[] )
+    : m_text( buffer, strlen( buffer ) ) {
+        // empty
+    }
+
+    bool operator == ( const Identifier &rhs ) const {
+        return m_text == rhs.m_text;
+    }
 
 private:
-    const char *m_token;
-    size_t m_size;
+    Identifier( const Identifier & );
+    Identifier &operator = ( const Identifier & );
 };
 
 struct Name {
@@ -154,30 +197,15 @@ private:
     Reference &operator = ( const Reference & );
 };
 
-struct Identifier {
-    size_t m_len;
-    char *m_buffer;
-
-    Identifier( size_t len, char buffer[] )
-        : m_len( len )
-        , m_buffer( buffer ) {
-        // empty
-    }
-
-private:
-    Identifier( const Identifier & );
-    Identifier &operator = ( const Identifier & );
-};
-
 struct Property {
-    Identifier *m_id;
-    Value *m_primData;
+    Identifier *m_key;
+    Value *m_value;
     Reference *m_ref;
     Property *m_next;
 
     Property( Identifier *id )
-        : m_id( id )
-        , m_primData( ddl_nullptr )
+        : m_key( id )
+        , m_value( ddl_nullptr )
         , m_ref( ddl_nullptr )
         , m_next( ddl_nullptr ) {
         // empty

+ 14 - 3
contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h

@@ -107,6 +107,12 @@ bool isNumeric( const T in ) {
     return false;*/
 }
 
+template<class T>
+inline
+bool isNotEndOfToken( T *in, T *end ) {
+    return ( '}' != *in && ',' != *in && !isSpace( *in ) && in != end );
+}
+
 template<class T>
 inline
 bool isInteger( T *in, T *end ) {
@@ -117,7 +123,8 @@ bool isInteger( T *in, T *end ) {
     }
 
     bool result( false );
-    while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
+    while( isNotEndOfToken( in, end ) ) {
+        //while( '}' != *in && ',' != *in && !isSpace( *in ) && in != end ) {
         result = isNumeric( *in );
         if( !result ) {
             break;
@@ -139,7 +146,9 @@ bool isFloat( T *in, T *end ) {
 
     // check for <1>.0f
     bool result( false );
-    while( !isSpace( *in ) && in != end ) {
+    while( isNotEndOfToken( in, end ) ) {
+
+//    while( !isSpace( *in ) && in != end ) {
         if( *in == '.' ) {
             result = true;
             break;
@@ -159,7 +168,9 @@ bool isFloat( T *in, T *end ) {
     }
 
     // check for 1.<0>f
-    while( !isSpace( *in ) && in != end && *in != ',' ) {
+    while( isNotEndOfToken( in, end ) ) {
+
+//    while( !isSpace( *in ) && in != end && *in != ',' && *in != '}' ) {
         result = isNumeric( *in );
         if( !result ) {
             return false;

+ 165 - 165
doc/dox.h

@@ -9,14 +9,14 @@
 
 @section intro Introduction
 
-assimp is a library to load and process geometric scenes from various data formats. It is tailored at typical game 
+assimp is a library to load and process geometric scenes from various data formats. It is tailored at typical game
 scenarios by supporting a node hierarchy, static or skinned meshes, materials, bone animations and potential texture data.
-The library is *not* designed for speed, it is primarily useful for importing assets from various sources once and 
+The library is *not* designed for speed, it is primarily useful for importing assets from various sources once and
 storing it in a engine-specific format for easy and fast every-day-loading. assimp is also able to apply various post
 processing steps to the imported data such as conversion to indexed meshes, calculation of normals or tangents/bitangents
 or conversion from right-handed to left-handed coordinate systems.
 
-assimp currently supports the following file formats (note that some loaders lack some features of their formats because 
+assimp currently supports the following file formats (note that some loaders lack some features of their formats because
 some file formats contain data not supported by assimp, some stuff would require so much conversion work
 that it has not been implemented yet and some (most ...) formats lack proper specifications):
 <hr>
@@ -39,15 +39,15 @@ that it has not been implemented yet and some (most ...) formats lack proper spe
 <b>Quake 3 BSP</b> ( <i>*.pk3</i> )  <sup>1</sup> <br>
 <b>RtCW</b> ( <i>*.mdc</i> )<br>
 <b>Doom 3</b> ( <i>*.md5mesh;*.md5anim;*.md5camera</i> ) <br>
-<b>DirectX X </b> ( <i>*.x</i> ). <br>		
-<b>Quick3D </b> ( <i>*.q3o;*q3s</i> ). <br>	
-<b>Raw Triangles </b> ( <i>*.raw</i> ). <br>	
+<b>DirectX X </b> ( <i>*.x</i> ). <br>
+<b>Quick3D </b> ( <i>*.q3o;*q3s</i> ). <br>
+<b>Raw Triangles </b> ( <i>*.raw</i> ). <br>
 <b>AC3D </b> ( <i>*.ac</i> ). <br>
 <b>Stereolithography </b> ( <i>*.stl</i> ). <br>
 <b>Autodesk DXF </b> ( <i>*.dxf</i> ). <br>
 <b>Irrlicht Mesh </b> ( <i>*.irrmesh;*.xml</i> ). <br>
 <b>Irrlicht Scene </b> ( <i>*.irr;*.xml</i> ). <br>
-<b>Object File Format </b> ( <i>*.off</i> ). <br>	
+<b>Object File Format </b> ( <i>*.off</i> ). <br>
 <b>Terragen Terrain </b> ( <i>*.ter</i> ) <br>
 <b>3D GameStudio Model </b> ( <i>*.mdl</i> ) <br>
 <b>3D GameStudio Terrain</b> ( <i>*.hmp</i> )<br>
@@ -60,9 +60,9 @@ that it has not been implemented yet and some (most ...) formats lack proper spe
 <b>Stanford Ply</b> ( <i>*.ply</i> )<br>
 <b>TrueSpace</b> ( <i>*.cob, *.scn</i> )<sup>2</sup><br><br>
 </tt>
-See the @link importer_notes Importer Notes Page @endlink for informations, what a specific importer can do and what not. 
-Note that although this paper claims to be the official documentation, 
-http://assimp.sourceforge.net/main_features_formats.html 
+See the @link importer_notes Importer Notes Page @endlink for informations, what a specific importer can do and what not.
+Note that although this paper claims to be the official documentation,
+http://assimp.sourceforge.net/main_features_formats.html
 <br>is usually the most up-to-date list of file formats supported by the library. <br>
 
 <sup>1</sup>: Experimental loaders<br>
@@ -71,12 +71,12 @@ http://assimp.sourceforge.net/main_features_formats.html
 <br>
 <hr>
 
-assimp is independent of the Operating System by nature, providing a C++ interface for easy integration 
-with game engines and a C interface to allow bindings to other programming languages. At the moment the library runs 
-on any little-endian platform including X86/Windows/Linux/Mac and X64/Windows/Linux/Mac. Special attention 
-was paid to keep the library as free as possible from dependencies. 
+assimp is independent of the Operating System by nature, providing a C++ interface for easy integration
+with game engines and a C interface to allow bindings to other programming languages. At the moment the library runs
+on any little-endian platform including X86/Windows/Linux/Mac and X64/Windows/Linux/Mac. Special attention
+was paid to keep the library as free as possible from dependencies.
 
-Big endian systems such as PPC-Macs or PPC-Linux systems are not officially supported at the moment. However, most 
+Big endian systems such as PPC-Macs or PPC-Linux systems are not officially supported at the moment. However, most
 formats handle the required endian conversion correctly, so large parts of the library should work.
 
 The assimp linker library and viewer application are provided under the BSD 3-clause license. This basically means
@@ -89,14 +89,14 @@ but not all of them are *open-source*. If there's an accompagning '<file>\source
 
 @section main_install Installation
 
-assimp can be used in two ways: linking against the pre-built libraries or building the library on your own. The former 
+assimp can be used in two ways: linking against the pre-built libraries or building the library on your own. The former
 option is the easiest, but the assimp distribution contains pre-built libraries only for Visual C++ 2005 and 2008. For other
-compilers you'll have to build assimp for yourself. Which is hopefully as hassle-free as the other way, but needs a bit 
+compilers you'll have to build assimp for yourself. Which is hopefully as hassle-free as the other way, but needs a bit
 more work. Both ways are described at the @link install Installation page. @endlink
 
 @section main_usage Usage
 
-When you're done integrating the library into your IDE / project, you can now start using it. There are two separate 
+When you're done integrating the library into your IDE / project, you can now start using it. There are two separate
 interfaces by which you can access the library: a C++ interface and a C interface using flat functions. While the former
 is easier to handle, the latter also forms a point where other programming languages can connect to. Upto the moment, though,
 there are no bindings for any other language provided. Have a look at the @link usage Usage page @endlink for a detailed explanation and code examples.
@@ -104,7 +104,7 @@ there are no bindings for any other language provided. Have a look at the @link
 @section main_data Data Structures
 
 When the importer successfully completed its job, the imported data is returned in an aiScene structure. This is the root
-point from where you can access all the various data types that a scene/model file can possibly contain. The 
+point from where you can access all the various data types that a scene/model file can possibly contain. The
 @link data Data Structures page @endlink describes how to interpret this data.
 
 @section ext Extending the library
@@ -118,7 +118,7 @@ See the @link extend Extending the library @endlink page for more information.
 
 @section main_support Support & Feedback
 
-If you have any questions/comments/suggestions/bug reports you're welcome to post them in our 
+If you have any questions/comments/suggestions/bug reports you're welcome to post them in our
 <a href="https://sourceforge.net/forum/forum.php?forum_id=817653">forums</a>. Alternatively there's
 a mailing list, <a href="https://sourceforge.net/mailarchive/forum.php?forum_name=assimp-discussions">
 assimp-discussions</a>.
@@ -146,18 +146,18 @@ project configs. For static linking, use release/debug. See the sections below o
 other build configs.
 If done correctly you should now be able to compile, link,
 run and use the application. If the linker complains about some integral functions being defined twice you propably have
-mixed the runtimes. Recheck the project configuration (project properties -&gt; C++ -&gt; Code generation -&gt; Runtime) if you use 
+mixed the runtimes. Recheck the project configuration (project properties -&gt; C++ -&gt; Code generation -&gt; Runtime) if you use
 static runtimes (Multithreaded / Multithreaded Debug) or dynamic runtimes (Multithreaded DLL / Multithreaded Debug DLL).
-Choose the assimp linker lib accordingly. 
+Choose the assimp linker lib accordingly.
 <br><br>
 Please don't forget to also read the @ref assimp_stl section on MSVC and the STL.
 
-@section assimp_stl Microsoft Compilers and the C++ Standard Library 
+@section assimp_stl Microsoft Compilers and the C++ Standard Library
 
 In VC8 and VC9 Microsoft introduced some Standard Library debugging features. A good example are improved iterator checks and
 various useful debug checks. The problem is the performance penalty that incurs with those extra checks.
 
-Most of these security enhancements are active in release builds by default, rendering assimp several times 
+Most of these security enhancements are active in release builds by default, rendering assimp several times
 slower. However, it is possible to disable them by setting
 
 @code
@@ -168,39 +168,39 @@ _SECURE_SCL=0
 in the preprocessor options (or alternatively in the source code, just before the STL is included for the first time).
 <b>assimp's vc8 and vc9 configs enable these flags by default</b>.
 
-<i>If you're linking statically against assimp:</i> Make sure your applications uses the same STl settings! 
-If you do not, there are two binary incompatible STL versions mangled together and you'll crash. 
+<i>If you're linking statically against assimp:</i> Make sure your applications uses the same STl settings!
+If you do not, there are two binary incompatible STL versions mangled together and you'll crash.
 Alternatively you can disable the fast STL settings for assimp by removing the 'FastSTL' property sheet from
 the vc project file.
 
 <i>If you're using assimp in a DLL/SO:</i> It's ok. There's no STL used in the binary DLL/SO interface, so it doesn't care whether
 your application uses the same STL settings or not.
 <br><br>
-Another option is to build against a different STL implementation, for example STlport. There's a special 
+Another option is to build against a different STL implementation, for example STlport. There's a special
 @ref assimp_stlport section that has a description how to achieve this.
 
 
 @section install_own Building the library from scratch
 
-To build the library on your own you first have to get hold of the dependencies. Fortunately, special attention was paid to 
-keep the list of dependencies short. Unfortunately, the only dependency is <a href="http://www.boost.org">boost</a> which 
-can be a bit painful to set up for certain development environments. Boost is a widely used collection of classes and 
-functions for various purposes. Chances are that it was already installed along with your compiler. If not, you have to install 
-it for yourself. Read the "Getting Started" section of the Boost documentation for how to setup boost. VisualStudio users 
+To build the library on your own you first have to get hold of the dependencies. Fortunately, special attention was paid to
+keep the list of dependencies short. Unfortunately, the only dependency is <a href="http://www.boost.org">boost</a> which
+can be a bit painful to set up for certain development environments. Boost is a widely used collection of classes and
+functions for various purposes. Chances are that it was already installed along with your compiler. If not, you have to install
+it for yourself. Read the "Getting Started" section of the Boost documentation for how to setup boost. VisualStudio users
 can use a comfortable installer from <a href="http://www.boost-consulting.com/products/free">
 http://www.boost-consulting.com/products/free</a>. Choose the appropriate version of boost for your runtime of choice.
 
-<b>If you don't want to use boost</b>, you can build against our <i>"Boost-Workaround"</i>. It consists of very small 
-implementations of the various boost utility classes used. However, you'll lose functionality (e.g. threading) by doing this. 
-So, if you can use boost, you should use boost. Otherwise, See the @link use_noboost NoBoost-Section @endlink 
+<b>If you don't want to use boost</b>, you can build against our <i>"Boost-Workaround"</i>. It consists of very small
+implementations of the various boost utility classes used. However, you'll lose functionality (e.g. threading) by doing this.
+So, if you can use boost, you should use boost. Otherwise, See the @link use_noboost NoBoost-Section @endlink
 later on this page for the details of the workaround.
 
 Once boost is working, you have to set up a project for the assimp library in your favorite IDE. If you use VC2005 or
-VC2008, you can simply load the solution or project files in the workspaces/ folder, otherwise you have to create a new 
+VC2008, you can simply load the solution or project files in the workspaces/ folder, otherwise you have to create a new
 package and add all the headers and source files from the include/ and code/ directories. Set the temporary output folder
 to obj/, for example, and redirect the output folder to bin/. Then build the library - it should compile and link fine.
 
-The last step is to integrate the library into your project. This is basically the same task as described in the 
+The last step is to integrate the library into your project. This is basically the same task as described in the
 "Using the pre-built libraries" section above: add the include/ and bin/ directories to your IDE's paths so that the compiler can find
 the library files. Alternatively you can simply add the assimp project to your project's overall solution and build it inside
 your solution.
@@ -221,7 +221,7 @@ The Boost-Workaround consists of dummy replacements for some boost utility templ
 
 These implementations are very limited and are not intended for use outside assimp. A compiler
 with full support for partial template specializations is required. To enable the workaround, put the following in
-your compiler's list of predefined macros: 
+your compiler's list of predefined macros:
 @code
 #define ASSIMP_BUILD_BOOST_WORKAROUND
 @endcode
@@ -240,7 +240,7 @@ for more details.
 assimp can be built as DLL. You just need to select a -dll config from the list of project
 configs and you're fine.
 
-<b>NOTE:</b> Theoretically, assimp-dll can be used with multithreaded (non-dll) runtime libraries, 
+<b>NOTE:</b> Theoretically, assimp-dll can be used with multithreaded (non-dll) runtime libraries,
 as long as you don't utilize any non-public stuff from the code folder. However, if you happen
 to encounter *very* strange problems, try changing the runtime to <i>Multithreaded (Debug) DLL</i>.
 
@@ -260,19 +260,19 @@ C++ Standard Library.
 */
 
 
-/** 
+/**
 @page usage Usage
 
 @section access_cpp Access by C++ class interface
 
 The assimp library can be accessed by both a class or flat function interface. The C++ class
-interface is the preferred way of interaction: you create an instance of class Assimp::Importer, 
+interface is the preferred way of interaction: you create an instance of class Assimp::Importer,
 maybe adjust some settings of it and then call Assimp::Importer::ReadFile(). The class will
-read the files and process its data, handing back the imported data as a pointer to an aiScene 
+read the files and process its data, handing back the imported data as a pointer to an aiScene
 to you. You can now extract the data you need from the file. The importer manages all the resources
-for itsself. If the importer is destroyed, all the data that was created/read by it will be 
+for itsself. If the importer is destroyed, all the data that was created/read by it will be
 destroyed, too. So the easiest way to use the Importer is to create an instance locally, use its
-results and then simply let it go out of scope. 
+results and then simply let it go out of scope.
 
 C++ example:
 @code
@@ -286,14 +286,14 @@ bool DoTheImportThing( const std::string& pFile)
   Assimp::Importer importer;
 
   // And have it read the given file with some example postprocessing
-  // Usually - if speed is not the most important aspect for you - you'll 
+  // Usually - if speed is not the most important aspect for you - you'll
   // propably to request more postprocessing than we do in this example.
-  const aiScene* scene = importer.ReadFile( pFile, 
-	aiProcess_CalcTangentSpace       | 
+  const aiScene* scene = importer.ReadFile( pFile,
+	aiProcess_CalcTangentSpace       |
 	aiProcess_Triangulate            |
 	aiProcess_JoinIdenticalVertices  |
 	aiProcess_SortByPType);
-  
+
   // If the import failed, report it
   if( !scene)
   {
@@ -301,7 +301,7 @@ bool DoTheImportThing( const std::string& pFile)
     return false;
   }
 
-  // Now we can access the file's contents. 
+  // Now we can access the file's contents.
   DoTheSceneProcessing( scene);
 
   // We're done. Everything will be cleaned up by the importer destructor
@@ -312,9 +312,9 @@ bool DoTheImportThing( const std::string& pFile)
 What exactly is read from the files and how you interpret it is described at the @ref data page. @endlink The post processing steps that the assimp library can apply to the
 imported data are listed at #aiPostProcessSteps. See the @ref pp Post proccessing page for more details.
 
-Note that the aiScene data structure returned is declared 'const'. Yes, you can get rid of 
-these 5 letters with a simple cast. Yes, you may do that. No, it's not recommended (and it's 
-suicide in DLL builds if you try to use new or delete on any of the arrays in the scene). 
+Note that the aiScene data structure returned is declared 'const'. Yes, you can get rid of
+these 5 letters with a simple cast. Yes, you may do that. No, it's not recommended (and it's
+suicide in DLL builds if you try to use new or delete on any of the arrays in the scene).
 
 @section access_c Access by plain-c function interface
 
@@ -336,8 +336,8 @@ bool DoTheImportThing( const char* pFile)
   // Start the import on the given file with some example postprocessing
   // Usually - if speed is not the most important aspect for you - you'll t
   // probably to request more postprocessing than we do in this example.
-  const aiScene* scene = aiImportFile( pFile, 
-    aiProcess_CalcTangentSpace       | 
+  const aiScene* scene = aiImportFile( pFile,
+    aiProcess_CalcTangentSpace       |
 	aiProcess_Triangulate            |
 	aiProcess_JoinIdenticalVertices  |
 	aiProcess_SortByPType);
@@ -363,7 +363,7 @@ bool DoTheImportThing( const char* pFile)
 The assimp library needs to access files internally. This of course applies to the file you want
 to read, but also to additional files in the same folder for certain file formats. By default,
 standard C/C++ IO logic is used to access these files. If your application works in a special
-environment where custom logic is needed to access the specified files, you have to supply 
+environment where custom logic is needed to access the specified files, you have to supply
 custom implementations of IOStream and IOSystem. A shortened example might look like this:
 
 @code
@@ -397,25 +397,25 @@ class MyIOSystem : public Assimp::IOSystem
 
   // Check whether a specific file exists
   bool Exists( const std::string& pFile) const {
-    .. 
+    ..
   }
 
   // Get the path delimiter character we'd like to see
-  char GetOsSeparator() const { 
-    return '/'; 
+  char GetOsSeparator() const {
+    return '/';
   }
 
   // ... and finally a method to open a custom stream
   IOStream* Open( const std::string& pFile, const std::string& pMode) {
-	return new MyIOStream( ... ); 
+	return new MyIOStream( ... );
   }
 
   void Close( IOStream* pFile) { delete pFile; }
 };
 @endcode
 
-Now that your IO system is implemented, supply an instance of it to the Importer object by calling 
-Assimp::Importer::SetIOHandler(). 
+Now that your IO system is implemented, supply an instance of it to the Importer object by calling
+Assimp::Importer::SetIOHandler().
 
 @code
 void DoTheImportThing( const std::string& pFile)
@@ -441,18 +441,18 @@ surely enough for almost any purpose. The process is simple:
 <li> .. and pass it as parameter to #aiImportFileEx
 </ul>
 
-@section  logging Logging 
+@section  logging Logging
 
-The assimp library provides an easy mechanism to log messages. For instance if you want to check the state of your 
-import and you just want to see, after which preprocessing step the import-process was aborted you can take a look 
-into the log. 
+The assimp library provides an easy mechanism to log messages. For instance if you want to check the state of your
+import and you just want to see, after which preprocessing step the import-process was aborted you can take a look
+into the log.
 Per default the assimp-library provides a default log implementation, where you can log your user specific message
 by calling it as a singleton with the requested logging-type. To see how this works take a look to this:
 
 @code
 using namespace Assimp;
 
-// Create a logger instance 
+// Create a logger instance
 DefaultLogger::create("",Logger::VERBOSE);
 
 // Now I am ready for logging my stuff
@@ -462,12 +462,12 @@ DefaultLogger::get()->info("this is my info-call");
 DefaultLogger::kill();
 @endcode
 
-At first you have to create the default-logger-instance (create). Now you are ready to rock and can log a 
+At first you have to create the default-logger-instance (create). Now you are ready to rock and can log a
 little bit around. After that you should kill it to release the singleton instance.
 
 If you want to integrate the assimp-log into your own GUI it my be helpful to have a mechanism writing
 the logs into your own log windows. The logger interface provides this by implementing an interface called LogStream.
-You can attach and detach this log stream to the default-logger instance or any implementation derived from Logger. 
+You can attach and detach this log stream to the default-logger instance or any implementation derived from Logger.
 Just derivate your own logger from the abstract base class LogStream and overwrite the write-method:
 
 @code
@@ -481,7 +481,7 @@ public:
 	{
 		// empty
 	}
-	
+
 	// Destructor
 	~myStream()
 	{
@@ -504,9 +504,9 @@ Assimp::DefaultLogger::get()->attachStream( new myStream(), severity );
 @endcode
 
 The severity level controls the kind of message which will be written into
-the attached stream. If you just want to log errors and warnings set the warn 
-and error severity flag for those severities. It is also possible to remove 
-a self defined logstream from an error severity by detaching it with the severity 
+the attached stream. If you just want to log errors and warnings set the warn
+and error severity flag for those severities. It is also possible to remove
+a self defined logstream from an error severity by detaching it with the severity
 flag set:
 
 @code
@@ -519,10 +519,10 @@ Assimp::DefaultLogger::get()->attachStream( new myStream(), severity );
 
 @endcode
 
-If you want to implement your own logger just derive from the abstract base class 
-#Logger and overwrite the methods debug, info, warn and error. 
+If you want to implement your own logger just derive from the abstract base class
+#Logger and overwrite the methods debug, info, warn and error.
 
-If you want to see the debug-messages in a debug-configured build, the Logger-interface 
+If you want to see the debug-messages in a debug-configured build, the Logger-interface
 provides a logging-severity. You can set it calling the following method:
 
 @code
@@ -531,17 +531,17 @@ Assimp::DefaultLogger::get()->setLogSeverity( LogSeverity log_severity );
 
 @endcode
 
-The normal logging severity supports just the basic stuff like, info, warnings and errors. 
+The normal logging severity supports just the basic stuff like, info, warnings and errors.
 In the verbose level very fine-grained debug messages will be logged, too. Note that this
 kind kind of logging might decrease import performance.
 */
 
-/** 
+/**
 @page data Data Structures
 
 The assimp library returns the imported data in a collection of structures. aiScene forms the root
 of the data, from here you gain access to all the nodes, meshes, materials, animations or textures
-that were read from the imported file. The aiScene is returned from a successful call to 
+that were read from the imported file. The aiScene is returned from a successful call to
 assimp::Importer::ReadFile(), aiImportFile() or aiImportFileEx() - see the @link usage Usage page @endlink
 for further information on how to use the library.
 
@@ -555,17 +555,17 @@ DirectX. If you need the imported data to be in a left-handed coordinate system,
 The output face winding is counter clockwise. Use #aiProcess_FlipWindingOrder to get CW data.
 @code
 x2
-  
+
             x1
 	x0
 @endcode
 
 Outputted polygons can be literally everything: they're probably concave, self-intersecting or non-planar,
-although our built-in triangulation (#aiProcess_Triangulate postprocessing step) doesn't handle the two latter. 
+although our built-in triangulation (#aiProcess_Triangulate postprocessing step) doesn't handle the two latter.
 
 The output UV coordinate system has its origin in the lower-left corner:
 @code
-0y|1y ---------- 1x|1y 
+0y|1y ---------- 1x|1y
  |                |
  |                |
  |                |
@@ -582,31 +582,31 @@ X3  Y3  Z3  T3
 0   0   0   1
 @endcode
 
-... with (X1, X2, X3) being the X base vector, (Y1, Y2, Y3) being the Y base vector, (Z1, Z2, Z3) 
+... with (X1, X2, X3) being the X base vector, (Y1, Y2, Y3) being the Y base vector, (Z1, Z2, Z3)
 being the Z base vector and (T1, T2, T3) being the translation part. If you want to use these matrices
 in DirectX functions, you have to transpose them.
 
 <hr>
 
-<b>11.24.09:</b> We changed the orientation of our quaternions to the most common convention to avoid confusion. 
-However, if you're a previous user of Assimp and you update the library to revisions beyond SVNREV 502, 
-you have to adapt your animation loading code to match the new quaternion orientation. 
+<b>11.24.09:</b> We changed the orientation of our quaternions to the most common convention to avoid confusion.
+However, if you're a previous user of Assimp and you update the library to revisions beyond SVNREV 502,
+you have to adapt your animation loading code to match the new quaternion orientation.
 
 <hr>
 
 @section hierarchy The Node Hierarchy
 
 Nodes are little named entities in the scene that have a place and orientation relative to their parents.
-Starting from the scene's root node all nodes can have 0 to x child nodes, thus forming a hierarchy. 
+Starting from the scene's root node all nodes can have 0 to x child nodes, thus forming a hierarchy.
 They form the base on which the scene is built on: a node can refer to 0..x meshes, can be referred to
 by a bone of a mesh or can be animated by a key sequence of an animation. DirectX calls them "frames",
-others call them "objects", we call them aiNode. 
+others call them "objects", we call them aiNode.
 
 A node can potentially refer to single or multiple meshes. The meshes are not stored inside the node, but
 instead in an array of aiMesh inside the aiScene. A node only refers to them by their array index. This also means
 that multiple nodes can refer to the same mesh, which provides a simple form of instancing. A mesh referred to
 by this way lives in the node's local coordinate system. If you want the mesh's orientation in global
-space, you'd have to concatenate the transformations from the referring node and all of its parents. 
+space, you'd have to concatenate the transformations from the referring node and all of its parents.
 
 Most of the file formats don't really support complex scenes, though, but a single model only. But there are
 more complex formats such as .3ds, .x or .collada scenes which may contain an arbitrary complex
@@ -646,7 +646,7 @@ void CopyNodesWithMeshes( aiNode node, SceneObject targetParent, Matrix4x4 accTr
 This function copies a node into the scene graph if it has children. If yes, a new scene object
 is created for the import node and the node's meshes are copied over. If not, no object is created.
 Potential child objects will be added to the old targetParent, but there transformation will be correct
-in respect to the global space. This function also works great in filtering the bone nodes - nodes 
+in respect to the global space. This function also works great in filtering the bone nodes - nodes
 that form the bone hierarchy for another mesh/node, but don't have any mesh themselves.
 
 @section meshes Meshes
@@ -662,7 +662,7 @@ An aiMesh is defined by a series of data channels. The presence of these data ch
 by the contents of the imported file: by default there are only those data channels present in the mesh
 that were also found in the file. The only channels guarenteed to be always present are aiMesh::mVertices
 and aiMesh::mFaces. You can test for the presence of other data by testing the pointers against NULL
-or use the helper functions provided by aiMesh. You may also specify several post processing flags 
+or use the helper functions provided by aiMesh. You may also specify several post processing flags
 at Importer::ReadFile() to let assimp calculate or recalculate additional data channels for you.
 
 At the moment, a single aiMesh may contain a set of triangles and polygons. A single vertex does always
@@ -677,9 +677,9 @@ See the @link materials Material System Page. @endlink
 
 @section bones Bones
 
-A mesh may have a set of bones in the form of aiBone structures.. Bones are a means to deform a mesh 
-according to the movement of a skeleton. Each bone has a name and a set of vertices on which it has influence. 
-Its offset matrix declares the transformation needed to transform from mesh space to the local space of this bone. 
+A mesh may have a set of bones in the form of aiBone structures.. Bones are a means to deform a mesh
+according to the movement of a skeleton. Each bone has a name and a set of vertices on which it has influence.
+Its offset matrix declares the transformation needed to transform from mesh space to the local space of this bone.
 
 Using the bones name you can find the corresponding node in the node hierarchy. This node in relation
 to the other bones' nodes defines the skeleton of the mesh. Unfortunately there might also be
@@ -687,7 +687,7 @@ nodes which are not used by a bone in the mesh, but still affect the pose of the
 they have child nodes which are bones. So when creating the skeleton hierarchy for a mesh I
 suggest the following method:
 
-a) Create a map or a similar container to store which nodes are necessary for the skeleton. 
+a) Create a map or a similar container to store which nodes are necessary for the skeleton.
 Pre-initialise it for all nodes with a "no". <br>
 b) For each bone in the mesh: <br>
 b1) Find the corresponding node in the scene's hierarchy by comparing their names. <br>
@@ -697,11 +697,11 @@ c) Recursively iterate over the node hierarchy <br>
 c1) If the node is marked as necessary, copy it into the skeleton and check its children <br>
 c2) If the node is marked as not necessary, skip it and do not iterate over its children. <br>
 
-Reasons: you need all the parent nodes to keep the transformation chain intact. For most  
+Reasons: you need all the parent nodes to keep the transformation chain intact. For most
 file formats and modelling packages the node hierarchy of the skeleton is either a child
-of the mesh node or a sibling of the mesh node but this is by no means a requirement so you shouldn't rely on it. 
+of the mesh node or a sibling of the mesh node but this is by no means a requirement so you shouldn't rely on it.
 The node closest to the root node is your skeleton root, from there you
-start copying the hierarchy. You can skip every branch without a node being a bone in the mesh - 
+start copying the hierarchy. You can skip every branch without a node being a bone in the mesh -
 that's why the algorithm skips the whole branch if the node is marked as "not necessary".
 
 You should now have a mesh in your engine with a skeleton that is a subset of the imported hierarchy.
@@ -719,12 +719,12 @@ though, that certain combinations of file format and exporter don't always store
 in the exported file. In this case, mTicksPerSecond is set to 0 to indicate the lack of knowledge.
 
 The aiAnimation consists of a series of aiNodeAnim's. Each bone animation affects a single node in
-the node hierarchy only, the name specifying which node is affected. For this node the structure 
+the node hierarchy only, the name specifying which node is affected. For this node the structure
 stores three separate key sequences: a vector key sequence for the position, a quaternion key sequence
 for the rotation and another vector key sequence for the scaling. All 3d data is local to the
 coordinate space of the node's parent, that means in the same space as the node's transformation matrix.
 There might be cases where animation tracks refer to a non-existent node by their name, but this
-should not be the case in your every-day data. 
+should not be the case in your every-day data.
 
 To apply such an animation you need to identify the animation tracks that refer to actual bones
 in your mesh. Then for every track: <br>
@@ -733,7 +733,7 @@ b) Optional: interpolate between these and the following keys. <br>
 c) Combine the calculated position, rotation and scaling to a tranformation matrix <br>
 d) Set the affected node's transformation to the calculated matrix. <br>
 
-If you need hints on how to convert to or from quaternions, have a look at the 
+If you need hints on how to convert to or from quaternions, have a look at the
 <a href="http://www.j3d.org/matrix_faq/matrfaq_latest.html">Matrix&Quaternion FAQ</a>. I suggest
 using logarithmic interpolation for the scaling keys if you happen to need them - usually you don't
 need them at all.
@@ -742,7 +742,7 @@ need them at all.
 
 Normally textures used by assets are stored in separate files, however,
 there are file formats embedding their textures directly into the model file.
-Such textures are loaded into an aiTexture structure. 
+Such textures are loaded into an aiTexture structure.
 <br>
 There are two cases:
 <br>
@@ -769,12 +769,12 @@ set if assimp is able to determine the file format.
 @page materials Material System
 
 @section General Overview
-All materials are stored in an array of aiMaterial inside the aiScene. 
+All materials are stored in an array of aiMaterial inside the aiScene.
 
-Each aiMesh refers to one 
+Each aiMesh refers to one
 material by its index in the array. Due to the vastly diverging definitions and usages of material
 parameters there is no hard definition of a material structure. Instead a material is defined by
-a set of properties accessible by their names. Have a look at assimp/material.h to see what types of 
+a set of properties accessible by their names. Have a look at assimp/material.h to see what types of
 properties are defined. In this file there are also various functions defined to test for the
 presence of certain properties in a material and retrieve their values.
 
@@ -788,13 +788,13 @@ Textures are organized in stacks, each stack being evaluated independently. The
 
 ------------------------
 | Constant base color  |             color
------------------------- 
+------------------------
 | Blend operation 0    |             +
 ------------------------
 | Strength factor 0    |             0.25*
 ------------------------
 | Texture 0            |             texture_0
------------------------- 
+------------------------
 | Blend operation 1    |             *
 ------------------------
 | Strength factor 1    |             1.0*
@@ -807,7 +807,7 @@ Textures are organized in stacks, each stack being evaluated independently. The
 
 @section keys Constants
 
-All material key constants start with 'AI_MATKEY' (it's an ugly macro for historical reasons, don't ask). 
+All material key constants start with 'AI_MATKEY' (it's an ugly macro for historical reasons, don't ask).
 
 <table border="1">
   <tr>
@@ -857,7 +857,7 @@ All material key constants start with 'AI_MATKEY' (it's an ugly macro for histor
     <td><tt>COLOR_TRANSPARENT</tt></td>
     <td>aiColor3D</td>
     <td>black (0,0,0)</td>
-	<td>Defines the transparent color of the material, this is the color to be multiplied with the color of 
+	<td>Defines the transparent color of the material, this is the color to be multiplied with the color of
 	translucent light to construct the final 'destination color' for a particular position in the screen buffer. T </td>
 	<td>---</tt></td>
   </tr>
@@ -1034,7 +1034,7 @@ mat->Get(AI_MATKEY_COLOR_DIFFUSE,color);
 @endcode
 
 <b>Note:</b> Get() is actually a template with explicit specializations for aiColor3D, aiColor4D, aiString, float, int and some others.
-Make sure that the type of the second parameter matches the expected data type of the material property (no compile-time check yet!). 
+Make sure that the type of the second parameter matches the expected data type of the material property (no compile-time check yet!).
 Don't follow this advice if you wish to encounter very strange results.
 
 @section C C-API
@@ -1085,15 +1085,15 @@ for all textures
    have uvwsrc for this texture?
       assign channel specified in uvwsrc
    else
-      assign channels in ascending order for all texture stacks, 
+      assign channels in ascending order for all texture stacks,
 	    i.e. diffuse1 gets channel 1, opacity0 gets channel 0.
 
 @endverbatim
 
 @section pseudo Pseudo Code Listing
 
-For completeness, the following is a very rough pseudo-code sample showing how to evaluate Assimp materials in your 
-shading pipeline. You'll probably want to limit your handling of all those material keys to a reasonable subset suitable for your purposes 
+For completeness, the following is a very rough pseudo-code sample showing how to evaluate Assimp materials in your
+shading pipeline. You'll probably want to limit your handling of all those material keys to a reasonable subset suitable for your purposes
 (for example most 3d engines won't support highly complex multi-layer materials, but many 3d modellers do).
 
 Also note that this sample is targeted at a (shader-based) rendering pipeline for real time graphics.
@@ -1111,7 +1111,7 @@ float3 EvaluateStack(stack)
   for (every texture in stack)
   {
     // assuming we have explicit & pretransformed UVs for this texture
-    float3 color = SampleTexture(texture,uv); 
+    float3 color = SampleTexture(texture,uv);
 
     // scale by texture blend factor
     color *= texture.blend;
@@ -1207,7 +1207,7 @@ float4 PimpMyPixel (float4 prev)
 
   // Get all single light contribution terms
   float3 diff = ComputeDiffuseContribution();
-  float3 spec = ComputeSpecularContribution(); 
+  float3 spec = ComputeSpecularContribution();
   float3 ambi = ComputeAmbientContribution();
 
   // .. and compute the final color value for this pixel
@@ -1231,7 +1231,7 @@ float4 PimpMyPixel (float4 prev)
 
 
 
-/** 
+/**
 @page perf Performance
 
 @section perf_overview Overview
@@ -1243,9 +1243,9 @@ This page discusses general performance issues related to assimp.
 assimp has built-in support for <i>very</i> basic profiling and time measurement. To turn it on, set the <tt>GLOB_MEASURE_TIME</tt>
 configuration switch to <tt>true</tt> (nonzero). Results are dumped to the log file, so you need to setup
 an appropriate logger implementation with at least one output stream first (see the @link logging Logging Page @endlink
-for the details.). 
+for the details.).
 
-Note that these measurements are based on a single run of the importer and each of the post processing steps, so 
+Note that these measurements are based on a single run of the importer and each of the post processing steps, so
 a single result set is far away from being significant in a statistic sense. While precision can be improved
 by running the test multiple times, the low accuracy of the timings may render the results useless
 for smaller files.
@@ -1269,7 +1269,7 @@ Info,  T5488: Entering post processing pipeline
 
 Debug, T5488: START `postprocess`
 Debug, T5488: RemoveRedundantMatsProcess begin
-Debug, T5488: RemoveRedundantMatsProcess finished 
+Debug, T5488: RemoveRedundantMatsProcess finished
 Debug, T5488: END   `postprocess`, dt= 0.001 s
 
 
@@ -1306,7 +1306,7 @@ Debug, T5488: START `postprocess`
 Debug, T5488: ImproveCacheLocalityProcess begin
 Debug, T5488: Mesh 0 | ACMR in: 0.851622 out: 0.718139 | ~15.7
 Info,  T5488: Cache relevant are 1 meshes (251904 faces). Average output ACMR is 0.718139
-Debug, T5488: ImproveCacheLocalityProcess finished. 
+Debug, T5488: ImproveCacheLocalityProcess finished.
 Debug, T5488: END   `postprocess`, dt= 1.903 s
 
 
@@ -1315,13 +1315,13 @@ Debug, T5488: END   `total`, dt= 11.269 s
 @endverbatim
 
 In this particular example only one fourth of the total import time was spent on the actual importing, while the rest of the
-time got consumed by the #aiProcess_Triangulate, #aiProcess_JoinIdenticalVertices and #aiProcess_ImproveCacheLocality 
-postprocessing steps. A wise selection of postprocessing steps is therefore essential to getting good performance. 
-Of course this depends on the individual requirements of your application, in many of the typical use cases of assimp performance won't 
+time got consumed by the #aiProcess_Triangulate, #aiProcess_JoinIdenticalVertices and #aiProcess_ImproveCacheLocality
+postprocessing steps. A wise selection of postprocessing steps is therefore essential to getting good performance.
+Of course this depends on the individual requirements of your application, in many of the typical use cases of assimp performance won't
 matter (i.e. in an offline content pipeline).
 */
 
-/** 
+/**
 @page threading Threading
 
 @section overview Overview
@@ -1332,7 +1332,7 @@ use it from multiple threads concurrently.
 @section threadsafety Thread-safety / using Assimp concurrently from several threads
 
 The library can be accessed by multiple threads simultaneously, as long as the
-following prerequisites are fulfilled: 
+following prerequisites are fulfilled:
 
  - Users of the C++-API should ensure that they use a dedicated #Assimp::Importer instance for each thread. Constructing instances of #Assimp::Importer is expensive, so it might be a good idea to
    let every thread maintain its own thread-local instance (which can be used to
@@ -1344,9 +1344,9 @@ following prerequisites are fulfilled:
 
 
 
-Multiple concurrent imports may or may not be beneficial, however. For certain file formats in conjunction with 
-little or no post processing IO times tend to be the performance bottleneck. Intense post processing together 
-with 'slow' file formats like X or Collada might scale well with multiple concurrent imports.  
+Multiple concurrent imports may or may not be beneficial, however. For certain file formats in conjunction with
+little or no post processing IO times tend to be the performance bottleneck. Intense post processing together
+with 'slow' file formats like X or Collada might scale well with multiple concurrent imports.
 
 
 @section automt Internal threading
@@ -1357,8 +1357,8 @@ Internal multi-threading is not currently implemented.
 /**
 @page res Resources
 
-This page lists some useful resources for assimp. Note that, even though the core team has an eye on them, 
-we cannot guarantee the accuracy of third-party information. If in doubt, it's best to ask either on the 
+This page lists some useful resources for assimp. Note that, even though the core team has an eye on them,
+we cannot guarantee the accuracy of third-party information. If in doubt, it's best to ask either on the
 mailing list or on our forums on SF.net.
 
  - assimp comes with some sample applications, these can be found in the <i>./samples</i> folder. Don't forget to read the <i>README</i> file.
@@ -1376,14 +1376,14 @@ mailing list or on our forums on SF.net.
 <hr>
 @section blender Blender
 
-This section contains implementation notes for the Blender3D importer. 
+This section contains implementation notes for the Blender3D importer.
 @subsection bl_overview Overview
 
-assimp provides a self-contained reimplementation of Blender's so called SDNA system (http://www.blender.org/development/architecture/notes-on-sdna/). 
+assimp provides a self-contained reimplementation of Blender's so called SDNA system (http://www.blender.org/development/architecture/notes-on-sdna/).
 SDNA allows Blender to be fully backward and forward compatible and to exchange
-files across all platforms. The BLEND format is thus a non-trivial binary monster and the loader tries to read the most of it, 
+files across all platforms. The BLEND format is thus a non-trivial binary monster and the loader tries to read the most of it,
 naturally limited by the scope of the #aiScene output data structure.
-Consequently, if Blender is the only modeling tool in your asset work flow, consider writing a 
+Consequently, if Blender is the only modeling tool in your asset work flow, consider writing a
 custom exporter from Blender if assimps format coverage does not meet the requirements.
 
 @subsection bl_status Current status
@@ -1397,12 +1397,12 @@ When filing bugs on the Blender loader, always give the Blender version (or, eve
 <hr>
 @section ifc IFC
 
-This section contains implementation notes on the IFC-STEP importer. 
+This section contains implementation notes on the IFC-STEP importer.
 @subsection ifc_overview Overview
 
-The library provides a partial implementation of the IFC2x3 industry standard for automatized exchange of CAE/architectural 
-data sets. See http://en.wikipedia.org/wiki/Industry_Foundation_Classes for more information on the format. We aim 
-at getting as much 3D data out of the files as possible. 
+The library provides a partial implementation of the IFC2x3 industry standard for automatized exchange of CAE/architectural
+data sets. See http://en.wikipedia.org/wiki/Industry_Foundation_Classes for more information on the format. We aim
+at getting as much 3D data out of the files as possible.
 
 @subsection ifc_status Current status
 
@@ -1413,23 +1413,23 @@ IFC support is new and considered experimental. Please report any bugs you may e
 - Only the STEP-based encoding is supported. IFCZIP and IFCXML are not (but IFCZIP can simply be unzipped to get a STEP file).
 - The importer leaves vertex coordinates untouched, but applies a global scaling to the root transform to
   convert from whichever unit the IFC file uses to <i>metres</i>.
-- If multiple geometric representations are provided, the choice which one to load is based on how expensive a representation seems 
+- If multiple geometric representations are provided, the choice which one to load is based on how expensive a representation seems
  to be in terms of import time. The loader also avoids representation types for which it has known deficits.
-- Not supported are arbitrary binary operations (binary clipping is implemented, though). 
+- Not supported are arbitrary binary operations (binary clipping is implemented, though).
 - Of the various relationship types that IFC knows, only aggregation, containment and material assignment are resolved and mapped to
   the output graph.
-- The implementation knows only about IFC2X3 and applies this rule set to all models it encounters, 
+- The implementation knows only about IFC2X3 and applies this rule set to all models it encounters,
   regardless of their actual version. Loading of older or newer files may fail with parsing errors.
 
 @subsection ifc_metadata Metadata
 
-IFC file properties (IfcPropertySet) are kept as per-node metadata, see aiNode::mMetaData. 
+IFC file properties (IfcPropertySet) are kept as per-node metadata, see aiNode::mMetaData.
 
 <hr>
 @section ogre Ogre
 *ATTENTION*: The Ogre-Loader is currently under development, many things have changed after this documentation was written, but they are not final enough to rewrite the documentation. So things may have changed by now!
 
-This section contains implementations notes for the OgreXML importer. 
+This section contains implementations notes for the OgreXML importer.
 @subsection overview Overview
 Ogre importer is currently optimized for the Blender Ogre exporter, because thats the only one that I use. You can find the Blender Ogre exporter at: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=45922
 
@@ -1481,12 +1481,12 @@ Just look in OgreImporterMaterial.cpp
 -	IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME: Normally, a texture is loaded as a colormap, if no
 	target is specified in the
 	materialfile. Is this switch is enabled, texture names ending with _n, _l, _s
-	are used as normalmaps, lightmaps or specularmaps. 
+	are used as normalmaps, lightmaps or specularmaps.
 	<br>
 	Property type: Bool. Default value: false.
 -	IMPORT_OGRE_MATERIAL_FILE: Ogre Meshes contain only the MaterialName, not the MaterialFile.
-	If there 
-	is no material file with the same name as the material, Ogre Importer will 
+	If there
+	is no material file with the same name as the material, Ogre Importer will
 	try to load this file and search the material in it.
 	<br>
 	Property type: String. Default value: guessed.
@@ -1515,8 +1515,8 @@ OK, that sounds too easy :-). The whole procedure for a new loader merely looks
 <li>Add them to the following workspaces: vc8 and vc9 (the files are in the workspaces directory), CMAKE (code/CMakeLists.txt, create a new
 source group for your importer and put them also to ADD_LIBRARY( assimp SHARED))</li>
 <li>Include <i>AssimpPCH.h</i> - this is the PCH file, and it includes already most Assimp-internal stuff. </li>
-<li>Open Importer.cpp and include your header just below the <i>(include_new_importers_here)</i> line, 
-guarded by a #define 
+<li>Open Importer.cpp and include your header just below the <i>(include_new_importers_here)</i> line,
+guarded by a #define
 @code
 #if (!defined assimp_BUILD_NO_FormatName_IMPORTER)
 	...
@@ -1525,14 +1525,14 @@ guarded by a #define
 Wrap the same guard around your .cpp!</li>
 
 <li>Now advance to the <i>(register_new_importers_here)</i> line in the Importer.cpp and register your importer there - just like all the others do.</li>
-<li>Setup a suitable test environment (i.e. use AssimpView or your own application), make sure to enable 
+<li>Setup a suitable test environment (i.e. use AssimpView or your own application), make sure to enable
 the #aiProcess_ValidateDataStructure flag and enable verbose logging. That is, simply call before you import anything:
 @code
 DefaultLogger::create("AssimpLog.txt",Logger::VERBOSE)
 @endcode
 </li>
 <li>
-Implement the Assimp::BaseImporter::CanRead(), Assimp::BaseImporter::InternReadFile() and Assimp::BaseImporter::GetExtensionList(). 
+Implement the Assimp::BaseImporter::CanRead(), Assimp::BaseImporter::InternReadFile() and Assimp::BaseImporter::GetExtensionList().
 Just copy'n'paste the template from Appendix A and adapt it for your needs.
 </li>
 <li>For error handling, throw a dynamic allocated ImportErrorException (see Appendix A) for critical errors, and log errors, warnings, infos and debuginfos
@@ -1566,7 +1566,7 @@ store the properties as a member variable of your importer, they are thread safe
 <li>Try to make your parser as flexible as possible. Don't rely on particular layout, whitespace/tab style,
 except if the file format has a strict definition, in which case you should always warn about spec violations.
 But the general rule of thumb is <i>be strict in what you write and tolerant in what you accept</i>.</li>
-<li>Call Assimp::BaseImporter::ConvertToUTF8() before you parse anything to convert foreign encodings to UTF-8. 
+<li>Call Assimp::BaseImporter::ConvertToUTF8() before you parse anything to convert foreign encodings to UTF-8.
  That's not necessary for XML importers, which must use the provided IrrXML for reading. </li>
 </ul>
 
@@ -1586,11 +1586,11 @@ Don't trust the input data! Check all offsets!
 
 Mixed stuff for internal use by loaders, mostly documented (most of them are already included by <i>AssimpPCH.h</i>):
 <ul>
-<li><b>ByteSwap</b> (<i>ByteSwap.h</i>) - manual byte swapping stuff for binary loaders.</li>
+<li><b>ByteSwapper</b> (<i>ByteSwapper.h</i>) - manual byte swapping stuff for binary loaders.</li>
 <li><b>StreamReader</b> (<i>StreamReader.h</i>) - safe, endianess-correct, binary reading.</li>
 <li><b>IrrXML</b> (<i>irrXMLWrapper.h</i>)  - for XML-parsing (SAX.</li>
 <li><b>CommentRemover</b> (<i>RemoveComments.h</i>) - remove single-line and multi-line comments from a text file.</li>
-<li>fast_atof, strtoul10, strtoul16, SkipSpaceAndLineEnd, SkipToNextToken .. large family of low-level 
+<li>fast_atof, strtoul10, strtoul16, SkipSpaceAndLineEnd, SkipToNextToken .. large family of low-level
 parsing functions, mostly declared in <i>fast_atof.h</i>, <i>StringComparison.h</i> and <i>ParsingUtils.h</i> (a collection that grew
 historically, so don't expect perfect organization). </li>
 <li><b>ComputeNormalsWithSmoothingsGroups()</b> (<i>SmoothingGroups.h</i>) - Computes normal vectors from plain old smoothing groups. </li>
@@ -1640,8 +1640,8 @@ The boost whitelist:
 
 @code
 // -------------------------------------------------------------------------------
-// Returns whether the class can handle the format of the given file. 
-bool xxxxImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, 
+// Returns whether the class can handle the format of the given file.
+bool xxxxImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
 	bool checkSig) const
 {
 	const std::string extension = GetExtension(pFile);
@@ -1649,8 +1649,8 @@ bool xxxxImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
 		return true;
 	}
 	if (!extension.length() || checkSig) {
-		// no extension given, or we're called a second time because no 
-		// suitable loader was found yet. This means, we're trying to open 
+		// no extension given, or we're called a second time because no
+		// suitable loader was found yet. This means, we're trying to open
 		// the file and look for and hints to identify the file format.
 		// #Assimp::BaseImporter provides some utilities:
 		//
@@ -1659,11 +1659,11 @@ bool xxxxImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler,
 		// against a given list of 'magic' strings.
 		//
 		// #Assimp::BaseImporter::CheckMagicToken - for binary files. It goes
-		// to a particular offset in the file and and compares the next words 
+		// to a particular offset in the file and and compares the next words
 		// against a given list of 'magic' tokens.
 
-		// These checks MUST be done (even if !checkSig) if the file extension 
-		// is not exclusive to your format. For example, .xml is very common 
+		// These checks MUST be done (even if !checkSig) if the file extension
+		// is not exclusive to your format. For example, .xml is very common
 		// and (co)used by many formats.
 	}
 	return false;
@@ -1677,7 +1677,7 @@ void xxxxImporter::GetExtensionList(std::set<std::string>& extensions)
 }
 
 // -------------------------------------------------------------------------------
-void xxxxImporter::InternReadFile( const std::string& pFile, 
+void xxxxImporter::InternReadFile( const std::string& pFile,
 	aiScene* pScene, IOSystem* pIOHandler)
 {
 	boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
@@ -1686,20 +1686,20 @@ void xxxxImporter::InternReadFile( const std::string& pFile,
 	if( file.get() == NULL) {
 		throw DeadlyImportError( "Failed to open xxxx file " + pFile + ".");
 	}
-	
+
 	// Your task: fill pScene
-	// Throw a ImportErrorException with a meaningful (!) error message if 
+	// Throw a ImportErrorException with a meaningful (!) error message if
 	// something goes wrong.
 }
 
 @endcode
  */
 
- 
+
  /**
  @page AnimationOverview Animation Overview
  \section Transformations
  This diagram shows how you can calculate your transformationmatrices for an animated character:
  <img src="AnimationOverview.png" />
- 
- **/
+
+ **/

+ 8 - 13
include/assimp/Exporter.hpp

@@ -348,16 +348,14 @@ public:
 	 *   are defined in the aiConfig.g header (all constants share the
 	 *   prefix AI_CONFIG_XXX and are simple strings).
 	 * @param iValue New value of the property
-	 * @param bWasExisting Optional pointer to receive true if the
-	 *   property was set before. The new value replaces the previous value
-	 *   in this case.
+	 * @return true if the property was set before. The new value replaces
+	 *   the previous value in this case.
 	 * @note Property of different types (float, int, string ..) are kept
 	 *   on different stacks, so calling SetPropertyInteger() for a 
 	 *   floating-point property has no effect - the loader will call
 	 *   GetPropertyFloat() to read the property, but it won't be there.
 	 */
-	void SetPropertyInteger(const char* szName, int iValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyInteger(const char* szName, int iValue);
 
 	// -------------------------------------------------------------------
 	/** Set a boolean configuration property. Boolean properties
@@ -366,30 +364,27 @@ public:
 	 *  #GetPropertyBool and vice versa.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL)	{
-		SetPropertyInteger(szName,value,bWasExisting);
+	bool SetPropertyBool(const char* szName, bool value)	{
+		return SetPropertyInteger(szName,value);
 	}
 
 	// -------------------------------------------------------------------
 	/** Set a floating-point configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyFloat(const char* szName, float fValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyFloat(const char* szName, float fValue);
 
 	// -------------------------------------------------------------------
 	/** Set a string configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyString(const char* szName, const std::string& sValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyString(const char* szName, const std::string& sValue);
 
 	// -------------------------------------------------------------------
 	/** Set a matrix configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
 
 	// -------------------------------------------------------------------
 	/** Get a configuration property.

+ 8 - 13
include/assimp/Importer.hpp

@@ -194,16 +194,14 @@ public:
 	 *   are defined in the aiConfig.g header (all constants share the
 	 *   prefix AI_CONFIG_XXX and are simple strings).
 	 * @param iValue New value of the property
-	 * @param bWasExisting Optional pointer to receive true if the
-	 *   property was set before. The new value replaces the previous value
-	 *   in this case.
+	 * @return true if the property was set before. The new value replaces
+	 *   the previous value in this case.
 	 * @note Property of different types (float, int, string ..) are kept
 	 *   on different stacks, so calling SetPropertyInteger() for a 
 	 *   floating-point property has no effect - the loader will call
 	 *   GetPropertyFloat() to read the property, but it won't be there.
 	 */
-	void SetPropertyInteger(const char* szName, int iValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyInteger(const char* szName, int iValue);
 
 	// -------------------------------------------------------------------
 	/** Set a boolean configuration property. Boolean properties
@@ -212,30 +210,27 @@ public:
 	 *  #GetPropertyBool and vice versa.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyBool(const char* szName, bool value, bool* bWasExisting = NULL)	{
-		SetPropertyInteger(szName,value,bWasExisting);
+	bool SetPropertyBool(const char* szName, bool value)	{
+		return SetPropertyInteger(szName,value);
 	}
 
 	// -------------------------------------------------------------------
 	/** Set a floating-point configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyFloat(const char* szName, float fValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyFloat(const char* szName, float fValue);
 
 	// -------------------------------------------------------------------
 	/** Set a string configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyString(const char* szName, const std::string& sValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyString(const char* szName, const std::string& sValue);
 
 	// -------------------------------------------------------------------
 	/** Set a matrix configuration property.
 	 * @see SetPropertyInteger()
 	 */
-	void SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue, 
-		bool* bWasExisting = NULL);
+	bool SetPropertyMatrix(const char* szName, const aiMatrix4x4& sValue);
 
 	// -------------------------------------------------------------------
 	/** Get a configuration property.

+ 18 - 3
include/assimp/config.h

@@ -877,8 +877,24 @@ enum aiComponent
  */
 #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION"
 
+// ---------------------------------------------------------------------------
+/** @brief Specifies whether the Collada loader will ignore the provided up direction.
+ *
+ * If this property is set to true, the up direction provided in the file header will
+ * be ignored and the file will be loaded as is.
+ * Property type: Bool. Default value: false.
+ */
 #define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION"
-
+
+// ---------------------------------------------------------------------------
+/** @brief Specifies whether the Collada loader will invert the transparency value.
+ *
+ * If this property is set to true, the transparency value will be interpreted as the
+ * inverse of the usual transparency. This is useful because lots of exporters does
+ * not respect the standard and do the opposite of what is normally expected.
+ * Property type: Bool. Default value: false.
+ */
+#define AI_CONFIG_IMPORT_COLLADA_INVERT_TRANSPARENCY "IMPORT_COLLADA_INVERT_TRANSPARENCY"
 
 // ---------- All the Export defines ------------
 
@@ -887,7 +903,6 @@ enum aiComponent
  * Property type: Bool. Default value: false.
  */
 
-#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
-
+#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
 
 #endif // !! AI_CONFIG_H_INC

+ 4 - 7
test/unit/utImporter.cpp

@@ -131,21 +131,19 @@ TEST_F(ImporterTest, testMemoryRead)
 // ------------------------------------------------------------------------------------------------
 TEST_F(ImporterTest, testIntProperty)
 {
-	bool b;
-	pImp->SetPropertyInteger("quakquak",1503,&b);
+	bool b = pImp->SetPropertyInteger("quakquak",1503);
 	EXPECT_FALSE(b);
 	EXPECT_EQ(1503, pImp->GetPropertyInteger("quakquak",0));
 	EXPECT_EQ(314159, pImp->GetPropertyInteger("not_there",314159));
 
-	pImp->SetPropertyInteger("quakquak",1504,&b);
+	b = pImp->SetPropertyInteger("quakquak",1504);
 	EXPECT_TRUE(b);
 }
 
 // ------------------------------------------------------------------------------------------------
 TEST_F(ImporterTest, testFloatProperty)
 {
-	bool b;
-	pImp->SetPropertyFloat("quakquak",1503.f,&b);
+	bool b = pImp->SetPropertyFloat("quakquak",1503.f);
 	EXPECT_TRUE(!b);
 	EXPECT_EQ(1503.f, pImp->GetPropertyFloat("quakquak",0.f));
 	EXPECT_EQ(314159.f, pImp->GetPropertyFloat("not_there",314159.f));
@@ -154,8 +152,7 @@ TEST_F(ImporterTest, testFloatProperty)
 // ------------------------------------------------------------------------------------------------
 TEST_F(ImporterTest, testStringProperty)
 {
-	bool b;
-	pImp->SetPropertyString("quakquak","test",&b);
+	bool b = pImp->SetPropertyString("quakquak","test");
 	EXPECT_TRUE(!b);
 	EXPECT_EQ("test", pImp->GetPropertyString("quakquak","weghwekg"));
 	EXPECT_EQ("ILoveYou", pImp->GetPropertyString("not_there","ILoveYou"));

+ 0 - 1
tools/assimp_view/AnimEvaluator.cpp

@@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
 using namespace AssimpView;

+ 199 - 190
tools/assimp_view/AssetHelper.h

@@ -43,195 +43,204 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #if (!defined AV_ASSET_HELPER_H_INCLUDED)
 #define AV_ASSET_HELPER_H_INCLUDED
 
-class SceneAnimator;
-
-//-------------------------------------------------------------------------------
-/**	\brief Class to wrap ASSIMP's asset output structures
-*/
-//-------------------------------------------------------------------------------
-class AssetHelper
-	{
-	public:
-		enum 
-		{
-			// the original normal set will be used
-			ORIGINAL = 0x0u,
-
-			// a smoothed normal set will be used
-			SMOOTH = 0x1u,
-
-			// a hard normal set will be used
-			HARD = 0x2u,
-		};
-
-		// default constructor
-		AssetHelper()
-			: iNormalSet(ORIGINAL)
-		{
-			mAnimator = NULL;
-			apcMeshes = NULL;
-			pcScene = NULL;
-		}
-
-		//---------------------------------------------------------------
-		// default vertex data structure
-		// (even if tangents, bitangents or normals aren't
-		// required by the shader they will be committed to the GPU)
-		//---------------------------------------------------------------
-		struct Vertex
-		{
-			aiVector3D vPosition;
-			aiVector3D vNormal;
-
-			D3DCOLOR dColorDiffuse;
-			aiVector3D vTangent;
-			aiVector3D vBitangent;
-			aiVector2D vTextureUV;
-			aiVector2D vTextureUV2;
-			unsigned char mBoneIndices[4];
-			unsigned char mBoneWeights[4]; // last Weight not used, calculated inside the vertex shader
-
-			/** Returns the vertex declaration elements to create a declaration from. */
-			static D3DVERTEXELEMENT9* GetDeclarationElements() 
-			{
-				static D3DVERTEXELEMENT9 decl[] =
-				{
-					{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
-					{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
-					{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
-					{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
-					{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
-					{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
-					{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
-					{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
-					{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
-					D3DDECL_END()
-				};
-
-				return decl;
-			}
-		};
-
-		//---------------------------------------------------------------
-		// FVF vertex structure used for normals
-		//---------------------------------------------------------------
-		struct LineVertex
-		{
-			aiVector3D vPosition;
-			DWORD dColorDiffuse;
-
-			// retrieves the FVF code of the vertex type
-			static DWORD GetFVF()
-			{
-				return D3DFVF_DIFFUSE | D3DFVF_XYZ;
-			}
-		};
-
-		//---------------------------------------------------------------
-		// Helper class to store GPU related resources created for
-		// a given aiMesh
-		//---------------------------------------------------------------
-		class MeshHelper
-			{
-			public:
-
-				MeshHelper ()
-					: 
-					piVB				(NULL),
-					piIB				(NULL),
-					piVBNormals			(NULL),
-					piEffect			(NULL),
-					bSharedFX           (false),
-					piDiffuseTexture	(NULL),
-					piSpecularTexture	(NULL),
-					piAmbientTexture	(NULL),
-					piEmissiveTexture	(NULL),
-					piNormalTexture		(NULL),
-					piOpacityTexture	(NULL),
-					piShininessTexture	(NULL),
-					piLightmapTexture	(NULL),
-					twosided            (false),
-					pvOriginalNormals	(NULL)
-                {}
-
-				~MeshHelper ()
-					{
-					// NOTE: This is done in DeleteAssetData()
-					// TODO: Make this a proper d'tor
-					}
-
-				// shading mode to use. Either Lambert or otherwise phong
-				// will be used in every case
-				aiShadingMode eShadingMode;
-
-				// vertex buffer
-				IDirect3DVertexBuffer9* piVB;
-
-				// index buffer. For partially transparent meshes
-				// created with dynamic usage to be able to update
-				// the buffer contents quickly
-				IDirect3DIndexBuffer9* piIB;
-
-				// vertex buffer to be used to draw vertex normals
-				// (vertex normals are generated in every case)
-				IDirect3DVertexBuffer9* piVBNormals;
-
-				// shader to be used
-				ID3DXEffect* piEffect;
-				bool bSharedFX;
-
-				// material textures
-				IDirect3DTexture9* piDiffuseTexture;
-				IDirect3DTexture9* piSpecularTexture;
-				IDirect3DTexture9* piAmbientTexture;
-				IDirect3DTexture9* piEmissiveTexture;
-				IDirect3DTexture9* piNormalTexture;
-				IDirect3DTexture9* piOpacityTexture;
-				IDirect3DTexture9* piShininessTexture;
-				IDirect3DTexture9* piLightmapTexture;
-
-				// material colors
-				D3DXVECTOR4 vDiffuseColor;
-				D3DXVECTOR4 vSpecularColor;
-				D3DXVECTOR4 vAmbientColor;
-				D3DXVECTOR4 vEmissiveColor;
-
-				// opacity for the material
-				float fOpacity;
-
-				// shininess for the material
-				float fShininess;
-
-				// strength of the specular highlight
-				float fSpecularStrength;
-
-				// two-sided?
-				bool twosided;
-
-				// Stores a pointer to the original normal set of the asset
-				aiVector3D* pvOriginalNormals;
-			};
-
-		// One instance per aiMesh in the globally loaded asset
-		MeshHelper** apcMeshes;
-
-		// Scene wrapper instance
-		aiScene* pcScene;
-
-		// Animation player to animate the scene if necessary
-		SceneAnimator* mAnimator;
-
-		// Specifies the normal set to be used
-		unsigned int iNormalSet;
-
-		// ------------------------------------------------------------------
-		// set the normal set to be used
-		void SetNormalSet(unsigned int iSet);
-
-		// ------------------------------------------------------------------
-		// flip all normal vectors
-		void FlipNormals();
-		void FlipNormalsInt();
-	};
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <d3dx9mesh.h>
+
+#include <assimp/scene.h>
+
+namespace AssimpView {
+
+    class SceneAnimator;
+
+    //-------------------------------------------------------------------------------
+    /**	\brief Class to wrap ASSIMP's asset output structures
+    */
+    //-------------------------------------------------------------------------------
+    class AssetHelper
+    {
+    public:
+        enum
+        {
+            // the original normal set will be used
+            ORIGINAL = 0x0u,
+
+            // a smoothed normal set will be used
+            SMOOTH = 0x1u,
+
+            // a hard normal set will be used
+            HARD = 0x2u,
+        };
+
+        // default constructor
+        AssetHelper()
+            : iNormalSet( ORIGINAL )
+        {
+            mAnimator = NULL;
+            apcMeshes = NULL;
+            pcScene = NULL;
+        }
+
+        //---------------------------------------------------------------
+        // default vertex data structure
+        // (even if tangents, bitangents or normals aren't
+        // required by the shader they will be committed to the GPU)
+        //---------------------------------------------------------------
+        struct Vertex
+        {
+            aiVector3D vPosition;
+            aiVector3D vNormal;
+
+            D3DCOLOR dColorDiffuse;
+            aiVector3D vTangent;
+            aiVector3D vBitangent;
+            aiVector2D vTextureUV;
+            aiVector2D vTextureUV2;
+            unsigned char mBoneIndices[ 4 ];
+            unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
+
+            /** Returns the vertex declaration elements to create a declaration from. */
+            static D3DVERTEXELEMENT9* GetDeclarationElements()
+            {
+                static D3DVERTEXELEMENT9 decl[] =
+                {
+                    { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
+                    { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
+                    { 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
+                    { 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
+                    { 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
+                    { 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
+                    { 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
+                    { 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
+                    { 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
+                    D3DDECL_END()
+                };
+
+                return decl;
+            }
+        };
+
+        //---------------------------------------------------------------
+        // FVF vertex structure used for normals
+        //---------------------------------------------------------------
+        struct LineVertex
+        {
+            aiVector3D vPosition;
+            DWORD dColorDiffuse;
+
+            // retrieves the FVF code of the vertex type
+            static DWORD GetFVF()
+            {
+                return D3DFVF_DIFFUSE | D3DFVF_XYZ;
+            }
+        };
+
+        //---------------------------------------------------------------
+        // Helper class to store GPU related resources created for
+        // a given aiMesh
+        //---------------------------------------------------------------
+        class MeshHelper
+        {
+        public:
+
+            MeshHelper()
+                :
+                piVB( NULL ),
+                piIB( NULL ),
+                piVBNormals( NULL ),
+                piEffect( NULL ),
+                bSharedFX( false ),
+                piDiffuseTexture( NULL ),
+                piSpecularTexture( NULL ),
+                piAmbientTexture( NULL ),
+                piEmissiveTexture( NULL ),
+                piNormalTexture( NULL ),
+                piOpacityTexture( NULL ),
+                piShininessTexture( NULL ),
+                piLightmapTexture( NULL ),
+                twosided( false ),
+                pvOriginalNormals( NULL )
+            {}
+
+            ~MeshHelper()
+            {
+                // NOTE: This is done in DeleteAssetData()
+                // TODO: Make this a proper d'tor
+            }
+
+            // shading mode to use. Either Lambert or otherwise phong
+            // will be used in every case
+            aiShadingMode eShadingMode;
+
+            // vertex buffer
+            IDirect3DVertexBuffer9* piVB;
+
+            // index buffer. For partially transparent meshes
+            // created with dynamic usage to be able to update
+            // the buffer contents quickly
+            IDirect3DIndexBuffer9* piIB;
+
+            // vertex buffer to be used to draw vertex normals
+            // (vertex normals are generated in every case)
+            IDirect3DVertexBuffer9* piVBNormals;
+
+            // shader to be used
+            ID3DXEffect* piEffect;
+            bool bSharedFX;
+
+            // material textures
+            IDirect3DTexture9* piDiffuseTexture;
+            IDirect3DTexture9* piSpecularTexture;
+            IDirect3DTexture9* piAmbientTexture;
+            IDirect3DTexture9* piEmissiveTexture;
+            IDirect3DTexture9* piNormalTexture;
+            IDirect3DTexture9* piOpacityTexture;
+            IDirect3DTexture9* piShininessTexture;
+            IDirect3DTexture9* piLightmapTexture;
+
+            // material colors
+            D3DXVECTOR4 vDiffuseColor;
+            D3DXVECTOR4 vSpecularColor;
+            D3DXVECTOR4 vAmbientColor;
+            D3DXVECTOR4 vEmissiveColor;
+
+            // opacity for the material
+            float fOpacity;
+
+            // shininess for the material
+            float fShininess;
+
+            // strength of the specular highlight
+            float fSpecularStrength;
+
+            // two-sided?
+            bool twosided;
+
+            // Stores a pointer to the original normal set of the asset
+            aiVector3D* pvOriginalNormals;
+        };
+
+        // One instance per aiMesh in the globally loaded asset
+        MeshHelper** apcMeshes;
+
+        // Scene wrapper instance
+        aiScene* pcScene;
+
+        // Animation player to animate the scene if necessary
+        SceneAnimator* mAnimator;
+
+        // Specifies the normal set to be used
+        unsigned int iNormalSet;
+
+        // ------------------------------------------------------------------
+        // set the normal set to be used
+        void SetNormalSet( unsigned int iSet );
+
+        // ------------------------------------------------------------------
+        // flip all normal vectors
+        void FlipNormals();
+        void FlipNormalsInt();
+    };
+}
 
 #endif // !! IG

+ 1 - 2
tools/assimp_view/Background.cpp

@@ -39,12 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
-
 namespace AssimpView {
 
+extern std::string g_szSkyboxShader;
 
 // From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
 // ------------------------------------------------------------------------------

+ 65 - 65
tools/assimp_view/Background.h

@@ -38,91 +38,91 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
+#pragma once
 
-#if (!defined AV_BACKGROUND_H_INCLUDED)
-#define AV_BACKGROUND_H_INCLUDED
+namespace AssimpView
+{
 
+    class CBackgroundPainter
+    {
+        CBackgroundPainter()
+            :
+            clrColor( D3DCOLOR_ARGB( 0xFF, 100, 100, 100 ) ),
+            pcTexture( NULL ),
+            piSkyBoxEffect( NULL ),
+            eMode( SIMPLE_COLOR )
+        {}
 
-class CBackgroundPainter
-	{
-	CBackgroundPainter()
-		: 
-		clrColor(D3DCOLOR_ARGB(0xFF,100,100,100)),
-		pcTexture(NULL),
-		piSkyBoxEffect(NULL),
-		eMode(SIMPLE_COLOR)
-		{}
+    public:
 
-public:
+        // Supported background draw modi
+        enum MODE { SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE };
 
-	// Supported background draw modi
-	enum MODE {SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE};
+        // Singleton accessors
+        static CBackgroundPainter s_cInstance;
+        inline static CBackgroundPainter& Instance()
+        {
+            return s_cInstance;
+        }
 
-	// Singleton accessors
-	static CBackgroundPainter s_cInstance;
-	inline static CBackgroundPainter& Instance ()
-		{
-		return s_cInstance;
-		}
+        // set the current background color
+        // (this removes any textures loaded)
+        void SetColor( D3DCOLOR p_clrNew );
 
-	// set the current background color
-	// (this removes any textures loaded)
-	void SetColor (D3DCOLOR p_clrNew);
+        // Setup a cubemap/a 2d texture as background
+        void SetCubeMapBG( const char* p_szPath );
+        void SetTextureBG( const char* p_szPath );
 
-	// Setup a cubemap/a 2d texture as background
-	void SetCubeMapBG (const char* p_szPath);
-	void SetTextureBG (const char* p_szPath);
+        // Called by the render loop
+        void OnPreRender();
+        void OnPostRender();
 
-	// Called by the render loop
-	void OnPreRender();
-	void OnPostRender();
+        // Release any native resources associated with the instance
+        void ReleaseNativeResource();
 
-	// Release any native resources associated with the instance
-	void ReleaseNativeResource();
+        // Recreate any native resources associated with the instance
+        void RecreateNativeResource();
 
-	// Recreate any native resources associated with the instance
-	void RecreateNativeResource();
+        // Rotate the skybox
+        void RotateSB( const aiMatrix4x4* pm );
 
-	// Rotate the skybox
-	void RotateSB(const aiMatrix4x4* pm);
+        // Reset the state of the skybox
+        void ResetSB();
 
-	// Reset the state of the skybox
-	void ResetSB();
+        inline MODE GetMode() const
+        {
+            return this->eMode;
+        }
 
-	inline MODE GetMode() const
-		{
-		return this->eMode;
-		}
+        inline IDirect3DBaseTexture9* GetTexture()
+        {
+            return this->pcTexture;
+        }
 
-	inline IDirect3DBaseTexture9* GetTexture()
-		{
-		return this->pcTexture;
-		}
+        inline ID3DXBaseEffect* GetEffect()
+        {
+            return this->piSkyBoxEffect;
+        }
 
-	inline ID3DXBaseEffect* GetEffect()
-		{
-		return this->piSkyBoxEffect;
-		}
+    private:
 
-private:
+        void RemoveSBDeps();
 
-	void RemoveSBDeps();
+        // current background color
+        D3DCOLOR clrColor;
 
-	// current background color
-	D3DCOLOR clrColor;
+        // current background texture
+        IDirect3DBaseTexture9* pcTexture;
+        ID3DXEffect* piSkyBoxEffect;
 
-	// current background texture
-	IDirect3DBaseTexture9* pcTexture;
-	ID3DXEffect* piSkyBoxEffect;
+        // current background mode
+        MODE eMode;
 
-	// current background mode
-	MODE eMode;
+        // path to the texture
+        std::string szPath;
 
-	// path to the texture
-	std::string szPath;
+        // transformation matrix for the skybox
+        aiMatrix4x4 mMatrix;
+    };
 
-	// transformation matrix for the skybox
-	aiMatrix4x4 mMatrix;
-	};
-
-#endif // !! AV_BACKGROUND_H_INCLUDED
+}

+ 8 - 5
tools/assimp_view/Display.cpp

@@ -38,13 +38,16 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
-
-#include "stdafx.h"
 #include "assimp_view.h"
-
+#include "AnimEvaluator.h"
+#include "SceneAnimator.h"
 
 namespace AssimpView {
 
+using namespace Assimp;
+
+extern std::string g_szCheckerBackgroundShader;
+
 struct SVertex
 {
 	float x,y,z,w,u,v;
@@ -690,7 +693,7 @@ int CDisplay::FillDisplayList(void)
 	// fill in the first entry
 	TVITEMEX tvi; 
 	TVINSERTSTRUCT sNew;
-	tvi.pszText = "Model";
+	tvi.pszText = (char*) "Model";
 	tvi.cchTextMax = (int)strlen(tvi.pszText);
 	tvi.mask = TVIF_TEXT | TVIF_SELECTEDIMAGE | TVIF_IMAGE | TVIF_HANDLE | TVIF_STATE;
 	tvi.state = TVIS_EXPANDED;
@@ -2240,7 +2243,7 @@ int CDisplay::RenderTextureView()
 		const float ny = (float)sRect.bottom;
 		const float  x = (float)sDesc.Width;
 		const float  y = (float)sDesc.Height;
-		float f = std::min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
+		float f = min((nx-30) / x,(ny-30) / y) * (m_fTextureZoom/1000.0f);
 
 		float fHalfX = (nx - (f * x)) / 2.0f;
 		float fHalfY = (ny - (f * y)) / 2.0f;

+ 465 - 457
tools/assimp_view/Display.h

@@ -42,6 +42,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #if (!defined AV_DISPLAY_H_INCLUDED)
 #define AV_DISPLAY_H_INCLUDE
 
+#include <windows.h>
+#include <shellapi.h>
+#include <commctrl.h>
+
 // see CDisplay::m_aiImageList
 #define AI_VIEW_IMGLIST_NODE			0x0
 #define AI_VIEW_IMGLIST_MATERIAL		0x1
@@ -49,486 +53,490 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
 #define AI_VIEW_IMGLIST_MODEL			0x4
 
-//-------------------------------------------------------------------------------
-/* Corresponds to the "Display" combobox in the UI
-*/
-//-------------------------------------------------------------------------------
-class CDisplay
-	{
-private:
-
-	// helper class
-	struct Info
-	{
-		Info(	D3DXVECTOR4* p1,
-				AssetHelper::MeshHelper* p2,
-				const char* p3)
-				: pclrColor(p1),pMesh(p2),szShaderParam(p3) {}
-
-		D3DXVECTOR4* pclrColor;
-		AssetHelper::MeshHelper* pMesh;
-		const char* szShaderParam;
-	};
-
-// default constructor
-	CDisplay() 
-		:	m_iViewMode(VIEWMODE_FULL), 
-			m_pcCurrentTexture(NULL),
-			m_pcCurrentNode(NULL),
-			m_pcCurrentMaterial(NULL),
-			m_hImageList(NULL),
-			m_hRoot(NULL),
-			m_fTextureZoom(1000.0f)
-	{
-		this->m_aiImageList[0] = 0;
-		this->m_aiImageList[1] = 1;
-		this->m_aiImageList[2] = 2;
-		this->m_aiImageList[3] = 3;
-		this->m_aiImageList[4] = 4;
-
-		this->m_avCheckerColors[0].x = this->m_avCheckerColors[0].y = this->m_avCheckerColors[0].z = 0.4f;
-		this->m_avCheckerColors[1].x = this->m_avCheckerColors[1].y = this->m_avCheckerColors[1].z = 0.6f;
-	}
-
-public:
-
-
-	//------------------------------------------------------------------
-	enum 
-	{
-		// the full model is displayed
-		VIEWMODE_FULL,
-
-		// a material is displayed on a simple spjere as model
-		VIEWMODE_MATERIAL,
-
-		// a texture with an UV set mapped on it is displayed
-		VIEWMODE_TEXTURE,
-
-		// a single node in the scenegraph is displayed
-		VIEWMODE_NODE,
-	};
-
-
-	//------------------------------------------------------------------
-	// represents a texture in the tree view
-	struct TextureInfo
-	{
-		// texture info
-		IDirect3DTexture9** piTexture;
-
-		// Blend factor of the texture
-		float fBlend;
-
-		// blend operation for the texture
-		aiTextureOp eOp;
-
-		// UV index for the texture
-		unsigned int iUV;
-
-		// Associated tree item
-		HTREEITEM hTreeItem;
-
-		// Original path to the texture
-		std::string szPath;
-
-		// index of the corresponding material
-		unsigned int iMatIndex;
-
-		// type of the texture
-		unsigned int iType;
-	};
-
-	//------------------------------------------------------------------
-	// represents a node in the tree view
-	struct NodeInfo
-	{
-		// node object
-		aiNode* psNode;
-
-		// corresponding tree view item
-		HTREEITEM hTreeItem;
-	};
-
-	//------------------------------------------------------------------
-	// represents a mesh in the tree view
-	struct MeshInfo
-	{
-		// the mesh object
-		aiMesh* psMesh;
-
-		// corresponding tree view item
-		HTREEITEM hTreeItem;
-	};
-
-	//------------------------------------------------------------------
-	// represents a material in the tree view
-	struct MaterialInfo
-	{
-		// material index
-		unsigned int iIndex;
-
-		// material object
-		aiMaterial* psMaterial;
-
-		// ID3DXEffect interface
-		ID3DXEffect* piEffect;
-
-		// corresponding tree view item
-		HTREEITEM hTreeItem;
-	};
-
-	//------------------------------------------------------------------
-	// Singleton accessors
-	static CDisplay s_cInstance;
-	inline static CDisplay& Instance ()
-		{
-		return s_cInstance;
-		}
+namespace AssimpView
+{
+
+    //-------------------------------------------------------------------------------
+    /* Corresponds to the "Display" combobox in the UI
+    */
+    //-------------------------------------------------------------------------------
+    class CDisplay
+    {
+    private:
+
+        // helper class
+        struct Info
+        {
+            Info( D3DXVECTOR4* p1,
+                AssetHelper::MeshHelper* p2,
+                const char* p3 )
+                : pclrColor( p1 ), pMesh( p2 ), szShaderParam( p3 ) {}
+
+            D3DXVECTOR4* pclrColor;
+            AssetHelper::MeshHelper* pMesh;
+            const char* szShaderParam;
+        };
+
+        // default constructor
+        CDisplay()
+            : m_iViewMode( VIEWMODE_FULL ),
+            m_pcCurrentTexture( NULL ),
+            m_pcCurrentNode( NULL ),
+            m_pcCurrentMaterial( NULL ),
+            m_hImageList( NULL ),
+            m_hRoot( NULL ),
+            m_fTextureZoom( 1000.0f )
+        {
+            this->m_aiImageList[ 0 ] = 0;
+            this->m_aiImageList[ 1 ] = 1;
+            this->m_aiImageList[ 2 ] = 2;
+            this->m_aiImageList[ 3 ] = 3;
+            this->m_aiImageList[ 4 ] = 4;
+
+            this->m_avCheckerColors[ 0 ].x = this->m_avCheckerColors[ 0 ].y = this->m_avCheckerColors[ 0 ].z = 0.4f;
+            this->m_avCheckerColors[ 1 ].x = this->m_avCheckerColors[ 1 ].y = this->m_avCheckerColors[ 1 ].z = 0.6f;
+        }
+
+    public:
+
+
+        //------------------------------------------------------------------
+        enum
+        {
+            // the full model is displayed
+            VIEWMODE_FULL,
+
+            // a material is displayed on a simple spjere as model
+            VIEWMODE_MATERIAL,
+
+            // a texture with an UV set mapped on it is displayed
+            VIEWMODE_TEXTURE,
+
+            // a single node in the scenegraph is displayed
+            VIEWMODE_NODE,
+        };
+
+
+        //------------------------------------------------------------------
+        // represents a texture in the tree view
+        struct TextureInfo
+        {
+            // texture info
+            IDirect3DTexture9** piTexture;
+
+            // Blend factor of the texture
+            float fBlend;
+
+            // blend operation for the texture
+            aiTextureOp eOp;
+
+            // UV index for the texture
+            unsigned int iUV;
+
+            // Associated tree item
+            HTREEITEM hTreeItem;
+
+            // Original path to the texture
+            std::string szPath;
+
+            // index of the corresponding material
+            unsigned int iMatIndex;
+
+            // type of the texture
+            unsigned int iType;
+        };
+
+        //------------------------------------------------------------------
+        // represents a node in the tree view
+        struct NodeInfo
+        {
+            // node object
+            aiNode* psNode;
+
+            // corresponding tree view item
+            HTREEITEM hTreeItem;
+        };
+
+        //------------------------------------------------------------------
+        // represents a mesh in the tree view
+        struct MeshInfo
+        {
+            // the mesh object
+            aiMesh* psMesh;
+
+            // corresponding tree view item
+            HTREEITEM hTreeItem;
+        };
+
+        //------------------------------------------------------------------
+        // represents a material in the tree view
+        struct MaterialInfo
+        {
+            // material index
+            unsigned int iIndex;
+
+            // material object
+            aiMaterial* psMaterial;
+
+            // ID3DXEffect interface
+            ID3DXEffect* piEffect;
+
+            // corresponding tree view item
+            HTREEITEM hTreeItem;
+        };
+
+        //------------------------------------------------------------------
+        // Singleton accessors
+        static CDisplay s_cInstance;
+        inline static CDisplay& Instance()
+        {
+            return s_cInstance;
+        }
 
 
-	//------------------------------------------------------------------
-	// Called during the render loop. Renders the scene (including the 
-	// HUD etc) in the current view mode
-	int OnRender();
+        //------------------------------------------------------------------
+        // Called during the render loop. Renders the scene (including the 
+        // HUD etc) in the current view mode
+        int OnRender();
 
-	//------------------------------------------------------------------
-	// called when the user selects another item in the "Display" tree 
-	// view the method determines the new view mode and performs all 
-	// required operations
-	// \param p_hTreeItem Selected tree view item
-	int OnSetup(HTREEITEM p_hTreeItem);
+        //------------------------------------------------------------------
+        // called when the user selects another item in the "Display" tree 
+        // view the method determines the new view mode and performs all 
+        // required operations
+        // \param p_hTreeItem Selected tree view item
+        int OnSetup( HTREEITEM p_hTreeItem );
 
-	//------------------------------------------------------------------
-	// Variant 1: Render the full scene with the asset
-	int RenderFullScene();
+        //------------------------------------------------------------------
+        // Variant 1: Render the full scene with the asset
+        int RenderFullScene();
 
 #if 0
-	//------------------------------------------------------------------
-	// Variant 2: Render only a part of the scene. One node to
-	// be exact
-	int RenderScenePart();
+        //------------------------------------------------------------------
+        // Variant 2: Render only a part of the scene. One node to
+        // be exact
+        int RenderScenePart();
 #endif
 
-	//------------------------------------------------------------------
-	// Variant 3: Render a large sphere and map a given material on it
-	int RenderMaterialView();
-
-	//------------------------------------------------------------------
-	// Variant 4: Render a flat plane, map a texture on it and
-	// display the UV wire on it
-	int RenderTextureView();
-
-	//------------------------------------------------------------------
-	// Fill the UI combobox with a list of all supported view modi
-	//
-	// The display modes are added in order
-	int FillDisplayList(void);
-
-	//------------------------------------------------------------------
-	// Add a material and all sub textures to the display mode list
-	// hRoot - Handle to the root of the tree view
-	// iIndex - Material index
-	int AddMaterialToDisplayList(HTREEITEM hRoot, 
-		unsigned int iIndex);
-
-	//------------------------------------------------------------------
-	// Add a texture to the display list
-	// pcMat - material containing the texture
-	// hTexture - Handle to the material tree item
-	// szPath - Path to the texture
-	// iUVIndex - UV index to be used for the texture
-	// fBlendFactor - Blend factor to be used for the texture
-	// eTextureOp - texture operation to be used for the texture
-	int AddTextureToDisplayList(unsigned int iType,
-		unsigned int iIndex,
-		const aiString* szPath,
-		HTREEITEM hFX, 
-		unsigned int iUVIndex		= 0,
-		const float fBlendFactor	= 0.0f,
-		aiTextureOp eTextureOp		= aiTextureOp_Multiply,
-		unsigned int iMesh			= 0);
-
-	//------------------------------------------------------------------
-	// Add a node to the display list
-	// Recusrivly adds all subnodes as well
-	// iIndex - Index of the node in the parent's child list
-	// iDepth - Current depth of the node
-	// pcNode - Node object
-	// hRoot - Parent tree view node
-	int AddNodeToDisplayList(
-		unsigned int iIndex, 
-		unsigned int iDepth,
-		aiNode* pcNode,
-		HTREEITEM hRoot);
-
-	//------------------------------------------------------------------
-	// Add a mesh to the display list
-	// iIndex - Index of the mesh in the scene's mesh list
-	// hRoot - Parent tree view node
-	int AddMeshToDisplayList(
-		unsigned int iIndex, 
-		HTREEITEM hRoot);
-
-	//------------------------------------------------------------------
-	// Load the image list for the tree view item
-	int LoadImageList(void);
-
-	//------------------------------------------------------------------
-	// Expand all nodes in the tree 
-	int ExpandTree();
-
-	//------------------------------------------------------------------
-	// Fill the UI combobox with a list of all supported animations
-	// The animations are added in order
-	int FillAnimList(void);
-
-	//------------------------------------------------------------------
-	// Clear the combox box containing the list of animations
-	int ClearAnimList(void);
-
-	//------------------------------------------------------------------
-	// Clear the combox box containing the list of scenegraph items
-	int ClearDisplayList(void);
-
-	//------------------------------------------------------------------
-	// Fill in the default statistics
-	int FillDefaultStatistics(void);
-
-	//------------------------------------------------------------------
-	// Called by LoadAsset()
-	// reset the class instance to the default values
-	int Reset(void);
-
-	//------------------------------------------------------------------
-	// Replace the texture that is current selected with
-	// a new texture
-	int ReplaceCurrentTexture(const char* szPath);
-
-	//------------------------------------------------------------------
-	// Display the context menu (if there) for the specified tree item
-	// hItem Valid tree view item handle
-	int ShowTreeViewContextMenu(HTREEITEM hItem);
-
-	//------------------------------------------------------------------
-	// Event handling for pop-up menus displayed by th tree view
-	int HandleTreeViewPopup(WPARAM wParam,LPARAM lParam);
-
-	//------------------------------------------------------------------
-	// Enable animation-related parts of the UI
-	int EnableAnimTools(BOOL hm) ;
-
-	//------------------------------------------------------------------
-	// setter for m_iViewMode
-	inline void SetViewMode(unsigned int p_iNew)
-	{
-		this->m_iViewMode = p_iNew;
-	}
-
-	//------------------------------------------------------------------
-	// getter for m_iViewMode
-	inline unsigned int GetViewMode()
-	{
-		return m_iViewMode;
-	}
-
-	//------------------------------------------------------------------
-	// change the texture view's zoom factor
-	inline void SetTextureViewZoom(float f)
-	{
-		// FIX: Removed log(), seems to make more problems than it fixes
-		this->m_fTextureZoom += f* 15;
-		if (this->m_fTextureZoom < 0.05f)this->m_fTextureZoom = 0.05f;
-	}
-
-	//------------------------------------------------------------------
-	// change the texture view's offset on the x axis
-	inline void SetTextureViewOffsetX(float f)
-	{
-		this->m_vTextureOffset.x += f;
-	}
-
-	//------------------------------------------------------------------
-	// change the texture view's offset on the y axis
-	inline void SetTextureViewOffsetY(float f)
-	{
-		this->m_vTextureOffset.y += f;
-	}
-
-	//------------------------------------------------------------------
-	// add a new texture to the list
-	inline void AddTexture(const TextureInfo& info)
-	{
-		this->m_asTextures.push_back(info);
-	}
-
-	//------------------------------------------------------------------
-	// add a new node to the list
-	inline void AddNode(const NodeInfo& info)
-	{
-		this->m_asNodes.push_back(info);
-	}
-
-	//------------------------------------------------------------------
-	// add a new mesh to the list
-	inline void AddMesh(const MeshInfo& info)
-	{
-		this->m_asMeshes.push_back(info);
-	}
-
-	//------------------------------------------------------------------
-	// add a new material to the list
-	inline void AddMaterial(const MaterialInfo& info)
-	{
-		this->m_asMaterials.push_back(info);
-	}
-
-	//------------------------------------------------------------------
-	// set the primary color of the checker pattern background
-	inline void SetFirstCheckerColor(D3DXVECTOR4 c)
-	{
-		this->m_avCheckerColors[0] = c;
-	}
-
-	//------------------------------------------------------------------
-	// set the secondary color of the checker pattern background
-	inline void SetSecondCheckerColor(D3DXVECTOR4 c)
-	{
-		this->m_avCheckerColors[1] = c;
-	}
-
-	//------------------------------------------------------------------
-	// get the primary color of the checker pattern background
-	inline const D3DXVECTOR4* GetFirstCheckerColor() const
-	{
-		return &this->m_avCheckerColors[0];
-	}
-
-	//------------------------------------------------------------------
-	// get the secondary color of the checker pattern background
-	inline const D3DXVECTOR4* GetSecondCheckerColor() const
-	{
-		return &this->m_avCheckerColors[1];
-	}
-
-private:
-
-	//------------------------------------------------------------------
-	// Render a screen-filling square using the checker pattern shader
-	int RenderPatternBG();
-
-	//------------------------------------------------------------------
-	// Render a given node in the scenegraph
-	// piNode Node to be rendered
-	// piMatrix Current transformation matrix
-	// bAlpha Render alpha or opaque objects only?
-	int RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
-		bool bAlpha = false);
-
-	//------------------------------------------------------------------
-	// Setup the camera for the stereo view rendering mode
-	int SetupStereoView();
-
-	//------------------------------------------------------------------
-	// Render the second view (for the right eye) in stereo mod
-	// m - World matrix
-	int RenderStereoView(const aiMatrix4x4& m);
-
-	//------------------------------------------------------------------
-	// Handle user input
-	int HandleInput();
-
-	//------------------------------------------------------------------
-	// Handle user input for the texture viewer
-	int HandleInputTextureView();
-
-	//------------------------------------------------------------------
-	// Handle user input if no asset is loaded
-	int HandleInputEmptyScene();
-
-	//------------------------------------------------------------------
-	// Draw the HUD (call only if FPS mode isn't active)
-	int DrawHUD();
-
-	//------------------------------------------------------------------
-	// Used by OnSetup().
-	// Do everything necessary to switch to texture view mode
-	int OnSetupTextureView(TextureInfo* pcNew);
-
-	//------------------------------------------------------------------
-	// Used by OnSetup().
-	// Do everything necessary to switch to material view mode
-	int OnSetupMaterialView(MaterialInfo* pcNew);
-
-	//------------------------------------------------------------------
-	// Used by OnSetup().
-	// Do everything necessary to switch to node view mode
-	int OnSetupNodeView(NodeInfo* pcNew);
-
-	//------------------------------------------------------------------
-	// Used by OnSetup().
-	// Do everything necessary to switch back to normal view mode
-	int OnSetupNormalView();
-
-	//------------------------------------------------------------------
-	// Used by HandleTreeViewPopup().
-	int HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam);
-
-	//------------------------------------------------------------------
-	// Render skeleton
-	int RenderSkeleton (aiNode* piNode,const aiMatrix4x4& piMatrix, 
-		const aiMatrix4x4& parent);
-
-	
+        //------------------------------------------------------------------
+        // Variant 3: Render a large sphere and map a given material on it
+        int RenderMaterialView();
+
+        //------------------------------------------------------------------
+        // Variant 4: Render a flat plane, map a texture on it and
+        // display the UV wire on it
+        int RenderTextureView();
+
+        //------------------------------------------------------------------
+        // Fill the UI combobox with a list of all supported view modi
+        //
+        // The display modes are added in order
+        int FillDisplayList( void );
+
+        //------------------------------------------------------------------
+        // Add a material and all sub textures to the display mode list
+        // hRoot - Handle to the root of the tree view
+        // iIndex - Material index
+        int AddMaterialToDisplayList( HTREEITEM hRoot,
+            unsigned int iIndex );
+
+        //------------------------------------------------------------------
+        // Add a texture to the display list
+        // pcMat - material containing the texture
+        // hTexture - Handle to the material tree item
+        // szPath - Path to the texture
+        // iUVIndex - UV index to be used for the texture
+        // fBlendFactor - Blend factor to be used for the texture
+        // eTextureOp - texture operation to be used for the texture
+        int AddTextureToDisplayList( unsigned int iType,
+            unsigned int iIndex,
+            const aiString* szPath,
+            HTREEITEM hFX,
+            unsigned int iUVIndex = 0,
+            const float fBlendFactor = 0.0f,
+            aiTextureOp eTextureOp = aiTextureOp_Multiply,
+            unsigned int iMesh = 0 );
+
+        //------------------------------------------------------------------
+        // Add a node to the display list
+        // Recusrivly adds all subnodes as well
+        // iIndex - Index of the node in the parent's child list
+        // iDepth - Current depth of the node
+        // pcNode - Node object
+        // hRoot - Parent tree view node
+        int AddNodeToDisplayList(
+            unsigned int iIndex,
+            unsigned int iDepth,
+            aiNode* pcNode,
+            HTREEITEM hRoot );
+
+        //------------------------------------------------------------------
+        // Add a mesh to the display list
+        // iIndex - Index of the mesh in the scene's mesh list
+        // hRoot - Parent tree view node
+        int AddMeshToDisplayList(
+            unsigned int iIndex,
+            HTREEITEM hRoot );
+
+        //------------------------------------------------------------------
+        // Load the image list for the tree view item
+        int LoadImageList( void );
+
+        //------------------------------------------------------------------
+        // Expand all nodes in the tree 
+        int ExpandTree();
+
+        //------------------------------------------------------------------
+        // Fill the UI combobox with a list of all supported animations
+        // The animations are added in order
+        int FillAnimList( void );
+
+        //------------------------------------------------------------------
+        // Clear the combox box containing the list of animations
+        int ClearAnimList( void );
+
+        //------------------------------------------------------------------
+        // Clear the combox box containing the list of scenegraph items
+        int ClearDisplayList( void );
+
+        //------------------------------------------------------------------
+        // Fill in the default statistics
+        int FillDefaultStatistics( void );
+
+        //------------------------------------------------------------------
+        // Called by LoadAsset()
+        // reset the class instance to the default values
+        int Reset( void );
+
+        //------------------------------------------------------------------
+        // Replace the texture that is current selected with
+        // a new texture
+        int ReplaceCurrentTexture( const char* szPath );
+
+        //------------------------------------------------------------------
+        // Display the context menu (if there) for the specified tree item
+        // hItem Valid tree view item handle
+        int ShowTreeViewContextMenu( HTREEITEM hItem );
+
+        //------------------------------------------------------------------
+        // Event handling for pop-up menus displayed by th tree view
+        int HandleTreeViewPopup( WPARAM wParam, LPARAM lParam );
+
+        //------------------------------------------------------------------
+        // Enable animation-related parts of the UI
+        int EnableAnimTools( BOOL hm );
+
+        //------------------------------------------------------------------
+        // setter for m_iViewMode
+        inline void SetViewMode( unsigned int p_iNew )
+        {
+            this->m_iViewMode = p_iNew;
+        }
+
+        //------------------------------------------------------------------
+        // getter for m_iViewMode
+        inline unsigned int GetViewMode()
+        {
+            return m_iViewMode;
+        }
+
+        //------------------------------------------------------------------
+        // change the texture view's zoom factor
+        inline void SetTextureViewZoom( float f )
+        {
+            // FIX: Removed log(), seems to make more problems than it fixes
+            this->m_fTextureZoom += f * 15;
+            if( this->m_fTextureZoom < 0.05f )this->m_fTextureZoom = 0.05f;
+        }
+
+        //------------------------------------------------------------------
+        // change the texture view's offset on the x axis
+        inline void SetTextureViewOffsetX( float f )
+        {
+            this->m_vTextureOffset.x += f;
+        }
+
+        //------------------------------------------------------------------
+        // change the texture view's offset on the y axis
+        inline void SetTextureViewOffsetY( float f )
+        {
+            this->m_vTextureOffset.y += f;
+        }
+
+        //------------------------------------------------------------------
+        // add a new texture to the list
+        inline void AddTexture( const TextureInfo& info )
+        {
+            this->m_asTextures.push_back( info );
+        }
+
+        //------------------------------------------------------------------
+        // add a new node to the list
+        inline void AddNode( const NodeInfo& info )
+        {
+            this->m_asNodes.push_back( info );
+        }
+
+        //------------------------------------------------------------------
+        // add a new mesh to the list
+        inline void AddMesh( const MeshInfo& info )
+        {
+            this->m_asMeshes.push_back( info );
+        }
+
+        //------------------------------------------------------------------
+        // add a new material to the list
+        inline void AddMaterial( const MaterialInfo& info )
+        {
+            this->m_asMaterials.push_back( info );
+        }
+
+        //------------------------------------------------------------------
+        // set the primary color of the checker pattern background
+        inline void SetFirstCheckerColor( D3DXVECTOR4 c )
+        {
+            this->m_avCheckerColors[ 0 ] = c;
+        }
+
+        //------------------------------------------------------------------
+        // set the secondary color of the checker pattern background
+        inline void SetSecondCheckerColor( D3DXVECTOR4 c )
+        {
+            this->m_avCheckerColors[ 1 ] = c;
+        }
+
+        //------------------------------------------------------------------
+        // get the primary color of the checker pattern background
+        inline const D3DXVECTOR4* GetFirstCheckerColor() const
+        {
+            return &this->m_avCheckerColors[ 0 ];
+        }
+
+        //------------------------------------------------------------------
+        // get the secondary color of the checker pattern background
+        inline const D3DXVECTOR4* GetSecondCheckerColor() const
+        {
+            return &this->m_avCheckerColors[ 1 ];
+        }
+
+    private:
+
+        //------------------------------------------------------------------
+        // Render a screen-filling square using the checker pattern shader
+        int RenderPatternBG();
+
+        //------------------------------------------------------------------
+        // Render a given node in the scenegraph
+        // piNode Node to be rendered
+        // piMatrix Current transformation matrix
+        // bAlpha Render alpha or opaque objects only?
+        int RenderNode( aiNode* piNode, const aiMatrix4x4& piMatrix,
+            bool bAlpha = false );
+
+        //------------------------------------------------------------------
+        // Setup the camera for the stereo view rendering mode
+        int SetupStereoView();
+
+        //------------------------------------------------------------------
+        // Render the second view (for the right eye) in stereo mod
+        // m - World matrix
+        int RenderStereoView( const aiMatrix4x4& m );
+
+        //------------------------------------------------------------------
+        // Handle user input
+        int HandleInput();
+
+        //------------------------------------------------------------------
+        // Handle user input for the texture viewer
+        int HandleInputTextureView();
+
+        //------------------------------------------------------------------
+        // Handle user input if no asset is loaded
+        int HandleInputEmptyScene();
+
+        //------------------------------------------------------------------
+        // Draw the HUD (call only if FPS mode isn't active)
+        int DrawHUD();
+
+        //------------------------------------------------------------------
+        // Used by OnSetup().
+        // Do everything necessary to switch to texture view mode
+        int OnSetupTextureView( TextureInfo* pcNew );
+
+        //------------------------------------------------------------------
+        // Used by OnSetup().
+        // Do everything necessary to switch to material view mode
+        int OnSetupMaterialView( MaterialInfo* pcNew );
+
+        //------------------------------------------------------------------
+        // Used by OnSetup().
+        // Do everything necessary to switch to node view mode
+        int OnSetupNodeView( NodeInfo* pcNew );
+
+        //------------------------------------------------------------------
+        // Used by OnSetup().
+        // Do everything necessary to switch back to normal view mode
+        int OnSetupNormalView();
+
+        //------------------------------------------------------------------
+        // Used by HandleTreeViewPopup().
+        int HandleTreeViewPopup2( WPARAM wParam, LPARAM lParam );
+
+        //------------------------------------------------------------------
+        // Render skeleton
+        int RenderSkeleton( aiNode* piNode, const aiMatrix4x4& piMatrix,
+            const aiMatrix4x4& parent );
+
+
 
-private:
+    private:
 
-	// view mode
-	unsigned int m_iViewMode;
+        // view mode
+        unsigned int m_iViewMode;
 
-	// List of all textures in the display CB
-	std::vector<TextureInfo> m_asTextures;
+        // List of all textures in the display CB
+        std::vector<TextureInfo> m_asTextures;
 
-	// current texture or NULL if no texture is active
-	TextureInfo* m_pcCurrentTexture;
+        // current texture or NULL if no texture is active
+        TextureInfo* m_pcCurrentTexture;
 
-	// List of all node in the display CB
-	std::vector<NodeInfo> m_asNodes;
+        // List of all node in the display CB
+        std::vector<NodeInfo> m_asNodes;
 
-	// List of all node in the display CB
-	std::vector<MeshInfo> m_asMeshes;
+        // List of all node in the display CB
+        std::vector<MeshInfo> m_asMeshes;
 
-	// current Node or NULL if no Node is active
-	NodeInfo* m_pcCurrentNode;
+        // current Node or NULL if no Node is active
+        NodeInfo* m_pcCurrentNode;
 
-	// List of all materials in the display CB
-	std::vector<MaterialInfo> m_asMaterials;
+        // List of all materials in the display CB
+        std::vector<MaterialInfo> m_asMaterials;
 
-	// current material or NULL if no material is active
-	MaterialInfo* m_pcCurrentMaterial;
+        // current material or NULL if no material is active
+        MaterialInfo* m_pcCurrentMaterial;
 
-	// indices into the image list of the "display" tree view control
-	unsigned int m_aiImageList[5]; /* = {0,1,2,3,4};*/
+        // indices into the image list of the "display" tree view control
+        unsigned int m_aiImageList[ 5 ]; /* = {0,1,2,3,4};*/
 
-	// Image list
-	HIMAGELIST m_hImageList;
+        // Image list
+        HIMAGELIST m_hImageList;
 
-	// Root node of the tree, "Model"
-	HTREEITEM m_hRoot;
+        // Root node of the tree, "Model"
+        HTREEITEM m_hRoot;
 
-	// Current zoom factor of the texture viewer
-	float m_fTextureZoom;
+        // Current zoom factor of the texture viewer
+        float m_fTextureZoom;
 
-	// Current offset (in pixels) of the texture viewer
-	aiVector2D m_vTextureOffset;
+        // Current offset (in pixels) of the texture viewer
+        aiVector2D m_vTextureOffset;
 
-	// Colors used to draw the checker pattern (for the
-	// texture viewer as background )
-	D3DXVECTOR4 m_avCheckerColors[2];
+        // Colors used to draw the checker pattern (for the
+        // texture viewer as background )
+        D3DXVECTOR4 m_avCheckerColors[ 2 ];
 
-	// View projection matrix
-	aiMatrix4x4 mViewProjection;
-	aiVector3D vPos;
-	};
+        // View projection matrix
+        aiMatrix4x4 mViewProjection;
+        aiVector3D vPos;
+    };
 
+}
 #endif // AV_DISPLAY_H_INCLUDE

+ 0 - 2
tools/assimp_view/HelpDialog.cpp

@@ -39,14 +39,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
 #include "richedit.h"
 
 namespace AssimpView {
 
-
 //-------------------------------------------------------------------------------
 // Message procedure for the help dialog
 //-------------------------------------------------------------------------------

+ 0 - 2
tools/assimp_view/Input.cpp

@@ -39,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
-
 namespace AssimpView {
 
 //-------------------------------------------------------------------------------

+ 1 - 4
tools/assimp_view/LogDisplay.cpp

@@ -39,14 +39,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
-
 namespace AssimpView {
 
-
-/* extern */ CLogDisplay CLogDisplay::s_cInstance;
+CLogDisplay CLogDisplay::s_cInstance;
 
 //-------------------------------------------------------------------------------
 void CLogDisplay::AddEntry(const std::string& szText,

+ 45 - 42
tools/assimp_view/LogDisplay.h

@@ -38,59 +38,62 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
+#pragma once
 
-#if (!defined AV_LOG_DISPLAY_H_INCLUDED)
-#define AV_LOG_DISPLAY_H_INCLUDE
+#include <list>
 
-//-------------------------------------------------------------------------------
-/**	\brief Class to display log strings in the upper right corner of the view
-*/
-//-------------------------------------------------------------------------------
-class CLogDisplay
-	{
-private:
+namespace AssimpView
+{
+
+    //-------------------------------------------------------------------------------
+    /**	\brief Class to display log strings in the upper right corner of the view
+    */
+    //-------------------------------------------------------------------------------
+    class CLogDisplay
+    {
+    private:
 
-	CLogDisplay()  {}
+        CLogDisplay()  {}
 
-public:
+    public:
 
-	// data structure for an entry in the log queue
-	struct SEntry
-		{
-		SEntry ()
-			:
-			clrColor(D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00)), dwStartTicks(0)
-				{}
+        // data structure for an entry in the log queue
+        struct SEntry
+        {
+            SEntry()
+                :
+                clrColor( D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) ), dwStartTicks( 0 )
+            {}
 
-		std::string szText;
-		D3DCOLOR clrColor;
-		DWORD dwStartTicks;
-		};
+            std::string szText;
+            D3DCOLOR clrColor;
+            DWORD dwStartTicks;
+        };
 
-	// Singleton accessors
-	static CLogDisplay s_cInstance;
-	inline static CLogDisplay& Instance ()
-		{
-		return s_cInstance;
-		}
+        // Singleton accessors
+        static CLogDisplay s_cInstance;
+        inline static CLogDisplay& Instance()
+        {
+            return s_cInstance;
+        }
 
-	// Add an entry to the log queue
-	void AddEntry(const std::string& szText,
-		const D3DCOLOR clrColor = D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0x00));
+        // Add an entry to the log queue
+        void AddEntry( const std::string& szText,
+            const D3DCOLOR clrColor = D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) );
 
-	// Release any native resources associated with the instance
-	void ReleaseNativeResource();
+        // Release any native resources associated with the instance
+        void ReleaseNativeResource();
 
-	// Recreate any native resources associated with the instance
-	void RecreateNativeResource();
+        // Recreate any native resources associated with the instance
+        void RecreateNativeResource();
 
-	// Called during the render loop
-	void OnRender();
+        // Called during the render loop
+        void OnRender();
 
-private:
+    private:
 
-	std::list<SEntry> asEntries;
-	ID3DXFont* piFont;
-	};
+        std::list<SEntry> asEntries;
+        ID3DXFont* piFont;
+    };
 
-#endif // AV_LOG_DISPLAY_H_INCLUDE
+}

+ 2 - 2
tools/assimp_view/LogWindow.cpp

@@ -39,13 +39,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 #include "richedit.h"
 
 namespace AssimpView {
 
-/* extern */ CLogWindow CLogWindow::s_cInstance;
+CLogWindow CLogWindow::s_cInstance;
+
 extern HKEY g_hRegistry;
 
 // header for the RTF log file

+ 65 - 60
tools/assimp_view/LogWindow.h

@@ -42,87 +42,92 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #if (!defined AV_LOG_WINDOW_H_INCLUDED)
 #define AV_LOG_WINDOW_H_INCLUDE
 
-
-//-------------------------------------------------------------------------------
-/**	\brief Subclass of Assimp::LogStream used to add all log messages to the
- *         log window.
-*/
-//-------------------------------------------------------------------------------
-class CMyLogStream : public Assimp::LogStream
+namespace AssimpView
 {
-public:
-	/**	@brief	Implementation of the abstract method	*/
-	void write(const char* message);
-};
 
 
-//-------------------------------------------------------------------------------
-/**	\brief Class to display log strings in a separate window
-*/
-//-------------------------------------------------------------------------------
-class CLogWindow
-	{
-private:
+    //-------------------------------------------------------------------------------
+    /**	\brief Subclass of Assimp::LogStream used to add all log messages to the
+     *         log window.
+     */
+    //-------------------------------------------------------------------------------
+    class CMyLogStream : public Assimp::LogStream
+    {
+    public:
+        /**	@brief	Implementation of the abstract method	*/
+        void write( const char* message );
+    };
+
+
+    //-------------------------------------------------------------------------------
+    /**	\brief Class to display log strings in a separate window
+    */
+    //-------------------------------------------------------------------------------
+    class CLogWindow
+    {
+    private:
+
+        friend class CMyLogStream;
+        friend INT_PTR CALLBACK LogDialogProc( HWND hwndDlg, UINT uMsg,
+            WPARAM wParam, LPARAM lParam );
 
-	friend class CMyLogStream;
-	friend INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
-		WPARAM wParam,LPARAM lParam);
+        CLogWindow() : hwnd( NULL ), bIsVisible( false ), bUpdate( true ) {}
 
-	CLogWindow() : hwnd(NULL),  bIsVisible(false), bUpdate(true) {}
+    public:
 
-public:
 
+        // Singleton accessors
+        static CLogWindow s_cInstance;
+        inline static CLogWindow& Instance()
+        {
+            return s_cInstance;
+        }
 
-	// Singleton accessors
-	static CLogWindow s_cInstance;
-	inline static CLogWindow& Instance ()
-		{
-		return s_cInstance;
-		}
+        // initializes the log window
+        void Init();
 
-	// initializes the log window
-	void Init ();
+        // Shows the log window
+        void Show();
 
-	// Shows the log window
-	void Show();
+        // Clears the log window
+        void Clear();
 
-	// Clears the log window
-	void Clear();
+        // Save the log window to an user-defined file
+        void Save();
 
-	// Save the log window to an user-defined file
-	void Save();
+        // write a line to the log window
+        void WriteLine( const char* message );
 
-	// write a line to the log window
-	void WriteLine(const char* message);
+        // Set the bUpdate member
+        inline void SetAutoUpdate( bool b )
+        {
+            this->bUpdate = b;
+        }
 
-	// Set the bUpdate member
-	inline void SetAutoUpdate(bool b)
-	{
-		this->bUpdate = b;
-	}
+        // updates the log file
+        void Update();
 
-	// updates the log file
-	void Update();
+    private:
 
-private:
+        // Window handle
+        HWND hwnd;
 
-	// Window handle
-	HWND hwnd;
+        // current text of the window (contains RTF tags)
+        std::string szText;
+        std::string szPlainText;
 
-	// current text of the window (contains RTF tags)
-	std::string szText;
-	std::string szPlainText;
+        // is the log window currently visible?
+        bool bIsVisible;
 
-	// is the log window currently visible?
-	bool bIsVisible;
+        // Specified whether each new log message updates the log automatically
+        bool bUpdate;
 
-	// Specified whether each new log message updates the log automatically
-	bool bUpdate;
 
+    public:
+        // associated log stream
+        CMyLogStream* pcStream;
+    };
 
-public:
-	// associated log stream
-	CMyLogStream* pcStream;
-	};
+}
 
 #endif // AV_LOG_DISPLA

+ 1392 - 1301
tools/assimp_view/Material.cpp

@@ -38,15 +38,106 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
-
-#include "stdafx.h"
 #include "assimp_view.h"
 
+#include "MaterialManager.h"
+#include "AssetHelper.h"
+
+#include <assimp/cimport.h>
+#include <assimp/Importer.hpp>
+#include <assimp/ai_assert.h>
+#include <assimp/cfileio.h>
+#include <assimp/postprocess.h>
+#include <assimp/scene.h>
+#include <assimp/IOSystem.hpp>
+#include <assimp/IOStream.hpp>
+#include <assimp/LogStream.hpp>
+#include <assimp/DefaultLogger.hpp>
+#include <../code/StringComparison.h>
+
+#include <vector>
+#include <algorithm>
 
 namespace AssimpView {
+    
+using namespace Assimp;
+
+extern std::string g_szMaterialShader;
+extern HINSTANCE g_hInstance				/*= NULL*/;
+extern HWND g_hDlg							/*= NULL*/;
+extern IDirect3D9* g_piD3D					/*= NULL*/;
+extern IDirect3DDevice9* g_piDevice			/*= NULL*/;
+extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
+extern double g_fFPS						/*= 0.0f*/;
+extern char g_szFileName[ MAX_PATH ];
+extern ID3DXEffect* g_piDefaultEffect		/*= NULL*/;
+extern ID3DXEffect* g_piNormalsEffect		/*= NULL*/;
+extern ID3DXEffect* g_piPassThroughEffect	/*= NULL*/;
+extern ID3DXEffect* g_piPatternEffect		/*= NULL*/;
+extern bool g_bMousePressed					/*= false*/;
+extern bool g_bMousePressedR				/*= false*/;
+extern bool g_bMousePressedM				/*= false*/;
+extern bool g_bMousePressedBoth				/*= false*/;
+extern float g_fElpasedTime					/*= 0.0f*/;
+extern D3DCAPS9 g_sCaps;
+extern bool g_bLoadingFinished				/*= false*/;
+extern HANDLE g_hThreadHandle				/*= NULL*/;
+extern float g_fWheelPos					/*= -10.0f*/;
+extern bool g_bLoadingCanceled				/*= false*/;
+extern IDirect3DTexture9* g_pcTexture		/*= NULL*/;
+
+extern aiMatrix4x4 g_mWorld;
+extern aiMatrix4x4 g_mWorldRotate;
+extern aiVector3D g_vRotateSpeed			/*= aiVector3D(0.5f,0.5f,0.5f)*/;
+
+extern aiVector3D g_avLightDirs[ 1 ] /* =
+                                        {	aiVector3D(-0.5f,0.6f,0.2f) ,
+                                        aiVector3D(-0.5f,0.5f,0.5f)} */;
+
+
+extern POINT g_mousePos						/*= {0,0};*/;
+extern POINT g_LastmousePos					/*= {0,0}*/;
+extern bool g_bFPSView						/*= false*/;
+extern bool g_bInvert						/*= false*/;
+extern EClickPos g_eClick;
+extern unsigned int g_iCurrentColor			/*= 0*/;
+
+// NOTE: The light intensity is separated from the color, it can
+// directly be manipulated using the middle mouse button.
+// When the user chooses a color from the palette the intensity
+// is reset to 1.0
+// index[2] is the ambient color
+extern float g_fLightIntensity				/*=0.0f*/;
+extern D3DCOLOR g_avLightColors[ 3 ];
+
+extern RenderOptions g_sOptions;
+extern Camera g_sCamera;
+extern AssetHelper *g_pcAsset				/*= NULL*/;
+
+
+//
+// Contains the mask image for the HUD 
+// (used to determine the position of a click)
+//
+// The size of the image is identical to the size of the main 
+// HUD texture
+//
+extern unsigned char* g_szImageMask			/*= NULL*/;
+
+
+extern float g_fACMR /*= 3.0f*/;
+extern IDirect3DQuery9* g_piQuery;
+
+extern bool g_bPlay						/*= false*/;
+
+extern double g_dCurrent;
+extern float g_smoothAngle /*= 80.f*/;
+
+extern unsigned int ppsteps, ppstepsdefault;
+extern bool nopointslines;
 
 
-/*static */ CMaterialManager CMaterialManager::s_cInstance;
+CMaterialManager CMaterialManager::s_cInstance;
 
 //-------------------------------------------------------------------------------
 // D3DX callback function to fill a texture with a checkers pattern
@@ -54,1350 +145,1350 @@ namespace AssimpView {
 // This pattern is used to mark textures which could not be loaded
 //-------------------------------------------------------------------------------
 VOID WINAPI FillFunc(D3DXVECTOR4* pOut, 
-					 CONST D3DXVECTOR2* pTexCoord, 
-					 CONST D3DXVECTOR2* pTexelSize, 
-					 LPVOID pData)
+                     CONST D3DXVECTOR2* pTexCoord, 
+                     CONST D3DXVECTOR2* pTexelSize, 
+                     LPVOID pData)
 {
-	UNREFERENCED_PARAMETER(pData);
-	UNREFERENCED_PARAMETER(pTexelSize);
-
-	// generate a nice checker pattern (yellow/black)
-	// size of a square: 32 * 32 px
-	unsigned int iX = (unsigned int)(pTexCoord->x * 256.0f);
-	unsigned int iY = (unsigned int)(pTexCoord->y * 256.0f);
-
-	bool bBlack = false;
-	if ((iX / 32) % 2 == 0)
-	{
-		if ((iY / 32) % 2 == 0)bBlack = true;
-	}
-	else 
-	{
-		if ((iY / 32) % 2 != 0)bBlack = true;
-	}
-	pOut->w = 1.0f;
-	if (bBlack)
-	{
-		pOut->x = pOut->y = pOut->z = 0.0f;
-	}
-	else
-	{
-		pOut->x = pOut->y = 1.0f;
-		pOut->z = 0.0f;
-	}
-	return;
+    UNREFERENCED_PARAMETER(pData);
+    UNREFERENCED_PARAMETER(pTexelSize);
+
+    // generate a nice checker pattern (yellow/black)
+    // size of a square: 32 * 32 px
+    unsigned int iX = (unsigned int)(pTexCoord->x * 256.0f);
+    unsigned int iY = (unsigned int)(pTexCoord->y * 256.0f);
+
+    bool bBlack = false;
+    if ((iX / 32) % 2 == 0)
+    {
+        if ((iY / 32) % 2 == 0)bBlack = true;
+    }
+    else 
+    {
+        if ((iY / 32) % 2 != 0)bBlack = true;
+    }
+    pOut->w = 1.0f;
+    if (bBlack)
+    {
+        pOut->x = pOut->y = pOut->z = 0.0f;
+    }
+    else
+    {
+        pOut->x = pOut->y = 1.0f;
+        pOut->z = 0.0f;
+    }
+    return;
 }
 
 //-------------------------------------------------------------------------------
 int CMaterialManager::UpdateSpecularMaterials()
-	{
-	if (g_pcAsset && g_pcAsset->pcScene)
-		{
-		for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
-			{
-			if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
-				{
-				this->DeleteMaterial(g_pcAsset->apcMeshes[i]);
-				this->CreateMaterial(g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
-				}
-			}
-		}
-	return 1;
-	}
+    {
+    if (g_pcAsset && g_pcAsset->pcScene)
+        {
+        for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
+            {
+            if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
+                {
+                this->DeleteMaterial(g_pcAsset->apcMeshes[i]);
+                this->CreateMaterial(g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
+                }
+            }
+        }
+    return 1;
+    }
 //-------------------------------------------------------------------------------
 int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut)
 {
-	if  (sDefaultTexture) {
-		sDefaultTexture->AddRef();
-		*p_ppiOut = sDefaultTexture;
-		return 1;
-	}
-	if(FAILED(g_piDevice->CreateTexture(
-		256,
-		256,
-		0,
-		0,
-		D3DFMT_A8R8G8B8,
-		D3DPOOL_MANAGED,
-		p_ppiOut,
-		NULL)))
-	{
-		CLogDisplay::Instance().AddEntry("[ERROR] Unable to create default texture",
-			D3DCOLOR_ARGB(0xFF,0xFF,0,0));
-
-		*p_ppiOut = NULL;
-		return 0;
-	}
-	D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
-	sDefaultTexture = *p_ppiOut;
-	sDefaultTexture->AddRef();
-
-	// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
-	static const GUID guidPrivateData = 
-		{ 0x9785da94, 0x1d96, 0x426b, 
-		{ 0xb3, 0xcb, 0xba, 0xdc, 0x36, 0x34, 0x7f, 0x5e } };
-
-	uint32_t iData = 0xFFFFFFFF;
-	(*p_ppiOut)->SetPrivateData(guidPrivateData,&iData,4,0);
-	return 1;
+    if  (sDefaultTexture) {
+        sDefaultTexture->AddRef();
+        *p_ppiOut = sDefaultTexture;
+        return 1;
+    }
+    if(FAILED(g_piDevice->CreateTexture(
+        256,
+        256,
+        0,
+        0,
+        D3DFMT_A8R8G8B8,
+        D3DPOOL_MANAGED,
+        p_ppiOut,
+        NULL)))
+    {
+        CLogDisplay::Instance().AddEntry("[ERROR] Unable to create default texture",
+            D3DCOLOR_ARGB(0xFF,0xFF,0,0));
+
+        *p_ppiOut = NULL;
+        return 0;
+    }
+    D3DXFillTexture(*p_ppiOut,&FillFunc,NULL);
+    sDefaultTexture = *p_ppiOut;
+    sDefaultTexture->AddRef();
+
+    // {9785DA94-1D96-426b-B3CB-BADC36347F5E}
+    static const GUID guidPrivateData = 
+        { 0x9785da94, 0x1d96, 0x426b, 
+        { 0xb3, 0xcb, 0xba, 0xdc, 0x36, 0x34, 0x7f, 0x5e } };
+
+    uint32_t iData = 0xFFFFFFFF;
+    (*p_ppiOut)->SetPrivateData(guidPrivateData,&iData,4,0);
+    return 1;
 }
 //-------------------------------------------------------------------------------
 bool CMaterialManager::TryLongerPath(char* szTemp,aiString* p_szString)
 {
-	char szTempB[MAX_PATH];
-	strcpy(szTempB,szTemp);
-
-	// go to the beginning of the file name
-	char* szFile = strrchr(szTempB,'\\');
-	if (!szFile)szFile = strrchr(szTempB,'/');
-
-	char* szFile2 = szTemp + (szFile - szTempB)+1;
-	szFile++;
-	char* szExt = strrchr(szFile,'.');
-	if (!szExt)return false;
-	szExt++;
-	*szFile = 0;
-
-	strcat(szTempB,"*.*");
-	const unsigned int iSize = (const unsigned int) ( szExt - 1 - szFile );
-
-	HANDLE          h;
-	WIN32_FIND_DATA info;
-
-	// build a list of files
-	h = FindFirstFile(szTempB, &info);
-	if (h != INVALID_HANDLE_VALUE)
-	{
-		do
-		{
-			if (!(strcmp(info.cFileName, ".") == 0 || strcmp(info.cFileName, "..") == 0))
-			{
-				char* szExtFound = strrchr(info.cFileName, '.');
-				if (szExtFound)
-				{
-					++szExtFound;
-					if (0 == ASSIMP_stricmp(szExtFound,szExt))
-					{
-						const unsigned int iSizeFound = (const unsigned int) ( 
-							szExtFound - 1 - info.cFileName);
-
-						for (unsigned int i = 0; i < iSizeFound;++i)
-							info.cFileName[i] = (CHAR)tolower(info.cFileName[i]);
-
-						if (0 == memcmp(info.cFileName,szFile2, std::min(iSizeFound,iSize)))
-						{
-							// we have it. Build the full path ...
-							char* sz = strrchr(szTempB,'*');
-							*(sz-2) = 0x0;
-
-							strcat(szTempB,info.cFileName);
-
-							// copy the result string back to the aiString
-							const size_t iLen = strlen(szTempB);
-							size_t iLen2 = iLen+1;
-							iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
-							memcpy(p_szString->data,szTempB,iLen2);
-							p_szString->length = iLen;
-							return true;
-						}
-					}
-					// check whether the 8.3 DOS name is matching
-					if (0 == ASSIMP_stricmp(info.cAlternateFileName,p_szString->data))
-					{
-						strcat(szTempB,info.cAlternateFileName);
-
-						// copy the result string back to the aiString
-						const size_t iLen = strlen(szTempB);
-						size_t iLen2 = iLen+1;
-						iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
-						memcpy(p_szString->data,szTempB,iLen2);
-						p_szString->length = iLen;
-						return true;
-					}
-				}
-			}
-		} 
-		while (FindNextFile(h, &info));
-
-		FindClose(h);
-	}
-	return false;
+    char szTempB[MAX_PATH];
+    strcpy(szTempB,szTemp);
+
+    // go to the beginning of the file name
+    char* szFile = strrchr(szTempB,'\\');
+    if (!szFile)szFile = strrchr(szTempB,'/');
+
+    char* szFile2 = szTemp + (szFile - szTempB)+1;
+    szFile++;
+    char* szExt = strrchr(szFile,'.');
+    if (!szExt)return false;
+    szExt++;
+    *szFile = 0;
+
+    strcat(szTempB,"*.*");
+    const unsigned int iSize = (const unsigned int) ( szExt - 1 - szFile );
+
+    HANDLE          h;
+    WIN32_FIND_DATA info;
+
+    // build a list of files
+    h = FindFirstFile(szTempB, &info);
+    if (h != INVALID_HANDLE_VALUE)
+    {
+        do
+        {
+            if (!(strcmp(info.cFileName, ".") == 0 || strcmp(info.cFileName, "..") == 0))
+            {
+                char* szExtFound = strrchr(info.cFileName, '.');
+                if (szExtFound)
+                {
+                    ++szExtFound;
+                    if (0 == ASSIMP_stricmp(szExtFound,szExt))
+                    {
+                        const unsigned int iSizeFound = (const unsigned int) ( 
+                            szExtFound - 1 - info.cFileName);
+
+                        for (unsigned int i = 0; i < iSizeFound;++i)
+                            info.cFileName[i] = (CHAR)tolower(info.cFileName[i]);
+
+                        if (0 == memcmp(info.cFileName,szFile2, min(iSizeFound,iSize)))
+                        {
+                            // we have it. Build the full path ...
+                            char* sz = strrchr(szTempB,'*');
+                            *(sz-2) = 0x0;
+
+                            strcat(szTempB,info.cFileName);
+
+                            // copy the result string back to the aiString
+                            const size_t iLen = strlen(szTempB);
+                            size_t iLen2 = iLen+1;
+                            iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
+                            memcpy(p_szString->data,szTempB,iLen2);
+                            p_szString->length = iLen;
+                            return true;
+                        }
+                    }
+                    // check whether the 8.3 DOS name is matching
+                    if (0 == ASSIMP_stricmp(info.cAlternateFileName,p_szString->data))
+                    {
+                        strcat(szTempB,info.cAlternateFileName);
+
+                        // copy the result string back to the aiString
+                        const size_t iLen = strlen(szTempB);
+                        size_t iLen2 = iLen+1;
+                        iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
+                        memcpy(p_szString->data,szTempB,iLen2);
+                        p_szString->length = iLen;
+                        return true;
+                    }
+                }
+            }
+        } 
+        while (FindNextFile(h, &info));
+
+        FindClose(h);
+    }
+    return false;
 }
 //-------------------------------------------------------------------------------
 int CMaterialManager::FindValidPath(aiString* p_szString)
 {
-	ai_assert(NULL != p_szString);
-	aiString pcpy = *p_szString;
-	if ('*' ==  p_szString->data[0])	{
-		// '*' as first character indicates an embedded file
-		return 5;
-	}
-
-	// first check whether we can directly load the file
-	FILE* pFile = fopen(p_szString->data,"rb");
-	if (pFile)fclose(pFile);
-	else
-	{
-		// check whether we can use the directory of  the asset as relative base
-		char szTemp[MAX_PATH*2], tmp2[MAX_PATH*2];
-		strcpy(szTemp, g_szFileName);
-		strcpy(tmp2,szTemp);
-
-		char* szData = p_szString->data;
-		if (*szData == '\\' || *szData == '/')++szData;
-
-		char* szEnd = strrchr(szTemp,'\\');
-		if (!szEnd)
-		{
-			szEnd = strrchr(szTemp,'/');
-			if (!szEnd)szEnd = szTemp;
-		}
-		szEnd++;
-		*szEnd = 0;
-		strcat(szEnd,szData);
-
-
-		pFile = fopen(szTemp,"rb");
-		if (!pFile)
-		{
-			// convert the string to lower case
-			for (unsigned int i = 0;;++i)
-			{
-				if ('\0' == szTemp[i])break;
-				szTemp[i] = (char)tolower(szTemp[i]);
-			}
-
-			if(TryLongerPath(szTemp,p_szString))return 1;
-			*szEnd = 0;
-
-			// search common sub directories
-			strcat(szEnd,"tex\\");
-			strcat(szEnd,szData);
-
-			pFile = fopen(szTemp,"rb");
-			if (!pFile)
-			{
-				if(TryLongerPath(szTemp,p_szString))return 1;
-
-				*szEnd = 0;
-
-				strcat(szEnd,"textures\\");
-				strcat(szEnd,szData);
-
-				pFile = fopen(szTemp,"rb");
-				if (!pFile)
-				{
-					if(TryLongerPath(szTemp, p_szString))return 1;
-				}
-
-				// patch by mark sibly to look for textures files in the asset's base directory.
-				const char *path=pcpy.data; 
-				const char *p=strrchr( path,'/' ); 
-				if( !p ) p=strrchr( path,'\\' ); 
-				if( p ){ 
-					char *q=strrchr( tmp2,'/' ); 
-					if( !q ) q=strrchr( tmp2,'\\' ); 
-					if( q ){ 
-						strcpy( q+1,p+1 ); 
-						if((pFile=fopen( tmp2,"r" ))){ 
-							fclose( pFile ); 
-							strcpy(p_szString->data,tmp2);
-							p_szString->length = strlen(tmp2);
-							return 1;
-						} 
-					} 
-				}
-				return 0;
-			}
-		}
-		fclose(pFile);
-
-		// copy the result string back to the aiString
-		const size_t iLen = strlen(szTemp);
-		size_t iLen2 = iLen+1;
-		iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
-		memcpy(p_szString->data,szTemp,iLen2);
-		p_szString->length = iLen;
-
-	}
-	return 1;
+    ai_assert(NULL != p_szString);
+    aiString pcpy = *p_szString;
+    if ('*' ==  p_szString->data[0])	{
+        // '*' as first character indicates an embedded file
+        return 5;
+    }
+
+    // first check whether we can directly load the file
+    FILE* pFile = fopen(p_szString->data,"rb");
+    if (pFile)fclose(pFile);
+    else
+    {
+        // check whether we can use the directory of  the asset as relative base
+        char szTemp[MAX_PATH*2], tmp2[MAX_PATH*2];
+        strcpy(szTemp, g_szFileName);
+        strcpy(tmp2,szTemp);
+
+        char* szData = p_szString->data;
+        if (*szData == '\\' || *szData == '/')++szData;
+
+        char* szEnd = strrchr(szTemp,'\\');
+        if (!szEnd)
+        {
+            szEnd = strrchr(szTemp,'/');
+            if (!szEnd)szEnd = szTemp;
+        }
+        szEnd++;
+        *szEnd = 0;
+        strcat(szEnd,szData);
+
+
+        pFile = fopen(szTemp,"rb");
+        if (!pFile)
+        {
+            // convert the string to lower case
+            for (unsigned int i = 0;;++i)
+            {
+                if ('\0' == szTemp[i])break;
+                szTemp[i] = (char)tolower(szTemp[i]);
+            }
+
+            if(TryLongerPath(szTemp,p_szString))return 1;
+            *szEnd = 0;
+
+            // search common sub directories
+            strcat(szEnd,"tex\\");
+            strcat(szEnd,szData);
+
+            pFile = fopen(szTemp,"rb");
+            if (!pFile)
+            {
+                if(TryLongerPath(szTemp,p_szString))return 1;
+
+                *szEnd = 0;
+
+                strcat(szEnd,"textures\\");
+                strcat(szEnd,szData);
+
+                pFile = fopen(szTemp,"rb");
+                if (!pFile)
+                {
+                    if(TryLongerPath(szTemp, p_szString))return 1;
+                }
+
+                // patch by mark sibly to look for textures files in the asset's base directory.
+                const char *path=pcpy.data; 
+                const char *p=strrchr( path,'/' ); 
+                if( !p ) p=strrchr( path,'\\' ); 
+                if( p ){ 
+                    char *q=strrchr( tmp2,'/' ); 
+                    if( !q ) q=strrchr( tmp2,'\\' ); 
+                    if( q ){ 
+                        strcpy( q+1,p+1 ); 
+                        if((pFile=fopen( tmp2,"r" ))){ 
+                            fclose( pFile ); 
+                            strcpy(p_szString->data,tmp2);
+                            p_szString->length = strlen(tmp2);
+                            return 1;
+                        } 
+                    } 
+                }
+                return 0;
+            }
+        }
+        fclose(pFile);
+
+        // copy the result string back to the aiString
+        const size_t iLen = strlen(szTemp);
+        size_t iLen2 = iLen+1;
+        iLen2 = iLen2 > MAXLEN ? MAXLEN : iLen2;
+        memcpy(p_szString->data,szTemp,iLen2);
+        p_szString->length = iLen;
+
+    }
+    return 1;
 }
 //-------------------------------------------------------------------------------
 int CMaterialManager::LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath)
 {
-	ai_assert(NULL != p_ppiOut);
-	ai_assert(NULL != szPath);
-
-	*p_ppiOut = NULL;
-
-	const std::string s = szPath->data;
-	TextureCache::iterator ff;
-	if ((ff = sCachedTextures.find(s)) != sCachedTextures.end()) {
-		*p_ppiOut = (*ff).second;
-		(*p_ppiOut)->AddRef();
-		return 1;
-	}
-
-	// first get a valid path to the texture
-	if( 5 == FindValidPath(szPath))
-	{
-		// embedded file. Find its index
-		unsigned int iIndex = atoi(szPath->data+1);
-		if (iIndex < g_pcAsset->pcScene->mNumTextures)
-		{
-			if (0 == g_pcAsset->pcScene->mTextures[iIndex]->mHeight)
-			{
-				// it is an embedded file ... don't need the file format hint,
-				// simply let D3DX load the file
-				D3DXIMAGE_INFO info;
-				if (FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice,
-					g_pcAsset->pcScene->mTextures[iIndex]->pcData,
-					g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
-					D3DX_DEFAULT,
-					D3DX_DEFAULT,
-					1,
-					D3DUSAGE_AUTOGENMIPMAP,
-					D3DFMT_UNKNOWN,
-					D3DPOOL_MANAGED,
-					D3DX_DEFAULT,
-					D3DX_DEFAULT,
-					0,
-					&info,
-					NULL,
-					p_ppiOut)))
-				{
-					std::string sz = "[ERROR] Unable to load embedded texture (#1): ";
-					sz.append(szPath->data);
-					CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-
-					this->SetDefaultTexture(p_ppiOut);
-					return 1;
-				}
-			}
-			else
-			{
-				// fill a new texture ...
-				if(FAILED(g_piDevice->CreateTexture(
-					g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
-					g_pcAsset->pcScene->mTextures[iIndex]->mHeight,
-					0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,p_ppiOut,NULL)))
-				{
-					std::string sz = "[ERROR] Unable to load embedded texture (#2): ";
-					sz.append(szPath->data);
-					CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-
-					this->SetDefaultTexture(p_ppiOut);
-					return 1;
-				}
-
-				// now copy the data to it ... (assume non pow2 to be supported)
-				D3DLOCKED_RECT sLock;
-				(*p_ppiOut)->LockRect(0,&sLock,NULL,0);
-
-				const aiTexel* pcData = g_pcAsset->pcScene->mTextures[iIndex]->pcData;
-
-				for (unsigned int y = 0; y < g_pcAsset->pcScene->mTextures[iIndex]->mHeight;++y)
-				{
-					memcpy(sLock.pBits,pcData,g_pcAsset->pcScene->mTextures[iIndex]->
-						mWidth *sizeof(aiTexel));
-					sLock.pBits = (char*)sLock.pBits + sLock.Pitch;
-					pcData += g_pcAsset->pcScene->mTextures[iIndex]->mWidth;
-				}
-				(*p_ppiOut)->UnlockRect(0);
-				(*p_ppiOut)->GenerateMipSubLevels();
-			}
-			sCachedTextures[s] = *p_ppiOut;
-			(*p_ppiOut)->AddRef();
-			return 1;
-		}
-		else
-		{
-			std::string sz = "[ERROR] Invalid index for embedded texture: ";
-			sz.append(szPath->data);
-			CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-
-			SetDefaultTexture(p_ppiOut);
-			return 1;
-		}
-	}
-
-	// then call D3DX to load the texture
-	if (FAILED(D3DXCreateTextureFromFileEx(
-		g_piDevice,
-		szPath->data,
-		D3DX_DEFAULT,
-		D3DX_DEFAULT,
-		0,
-		0,
-		D3DFMT_A8R8G8B8,
-		D3DPOOL_MANAGED,
-		D3DX_DEFAULT,
-		D3DX_DEFAULT,
-		0,
-		NULL,
-		NULL,
-		p_ppiOut)))
-	{
-		// error ... use the default texture instead
-		std::string sz = "[ERROR] Unable to load texture: ";
-		sz.append(szPath->data);
-		CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-
-		this->SetDefaultTexture(p_ppiOut);
-	}
-	sCachedTextures[s] = *p_ppiOut;
-	(*p_ppiOut)->AddRef();
-
-	return 1;
+    ai_assert(NULL != p_ppiOut);
+    ai_assert(NULL != szPath);
+
+    *p_ppiOut = NULL;
+
+    const std::string s = szPath->data;
+    TextureCache::iterator ff;
+    if ((ff = sCachedTextures.find(s)) != sCachedTextures.end()) {
+        *p_ppiOut = (*ff).second;
+        (*p_ppiOut)->AddRef();
+        return 1;
+    }
+
+    // first get a valid path to the texture
+    if( 5 == FindValidPath(szPath))
+    {
+        // embedded file. Find its index
+        unsigned int iIndex = atoi(szPath->data+1);
+        if (iIndex < g_pcAsset->pcScene->mNumTextures)
+        {
+            if (0 == g_pcAsset->pcScene->mTextures[iIndex]->mHeight)
+            {
+                // it is an embedded file ... don't need the file format hint,
+                // simply let D3DX load the file
+                D3DXIMAGE_INFO info;
+                if (FAILED(D3DXCreateTextureFromFileInMemoryEx(g_piDevice,
+                    g_pcAsset->pcScene->mTextures[iIndex]->pcData,
+                    g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
+                    D3DX_DEFAULT,
+                    D3DX_DEFAULT,
+                    1,
+                    D3DUSAGE_AUTOGENMIPMAP,
+                    D3DFMT_UNKNOWN,
+                    D3DPOOL_MANAGED,
+                    D3DX_DEFAULT,
+                    D3DX_DEFAULT,
+                    0,
+                    &info,
+                    NULL,
+                    p_ppiOut)))
+                {
+                    std::string sz = "[ERROR] Unable to load embedded texture (#1): ";
+                    sz.append(szPath->data);
+                    CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+
+                    this->SetDefaultTexture(p_ppiOut);
+                    return 1;
+                }
+            }
+            else
+            {
+                // fill a new texture ...
+                if(FAILED(g_piDevice->CreateTexture(
+                    g_pcAsset->pcScene->mTextures[iIndex]->mWidth,
+                    g_pcAsset->pcScene->mTextures[iIndex]->mHeight,
+                    0,D3DUSAGE_AUTOGENMIPMAP,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,p_ppiOut,NULL)))
+                {
+                    std::string sz = "[ERROR] Unable to load embedded texture (#2): ";
+                    sz.append(szPath->data);
+                    CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+
+                    this->SetDefaultTexture(p_ppiOut);
+                    return 1;
+                }
+
+                // now copy the data to it ... (assume non pow2 to be supported)
+                D3DLOCKED_RECT sLock;
+                (*p_ppiOut)->LockRect(0,&sLock,NULL,0);
+
+                const aiTexel* pcData = g_pcAsset->pcScene->mTextures[iIndex]->pcData;
+
+                for (unsigned int y = 0; y < g_pcAsset->pcScene->mTextures[iIndex]->mHeight;++y)
+                {
+                    memcpy(sLock.pBits,pcData,g_pcAsset->pcScene->mTextures[iIndex]->
+                        mWidth *sizeof(aiTexel));
+                    sLock.pBits = (char*)sLock.pBits + sLock.Pitch;
+                    pcData += g_pcAsset->pcScene->mTextures[iIndex]->mWidth;
+                }
+                (*p_ppiOut)->UnlockRect(0);
+                (*p_ppiOut)->GenerateMipSubLevels();
+            }
+            sCachedTextures[s] = *p_ppiOut;
+            (*p_ppiOut)->AddRef();
+            return 1;
+        }
+        else
+        {
+            std::string sz = "[ERROR] Invalid index for embedded texture: ";
+            sz.append(szPath->data);
+            CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+
+            SetDefaultTexture(p_ppiOut);
+            return 1;
+        }
+    }
+
+    // then call D3DX to load the texture
+    if (FAILED(D3DXCreateTextureFromFileEx(
+        g_piDevice,
+        szPath->data,
+        D3DX_DEFAULT,
+        D3DX_DEFAULT,
+        0,
+        0,
+        D3DFMT_A8R8G8B8,
+        D3DPOOL_MANAGED,
+        D3DX_DEFAULT,
+        D3DX_DEFAULT,
+        0,
+        NULL,
+        NULL,
+        p_ppiOut)))
+    {
+        // error ... use the default texture instead
+        std::string sz = "[ERROR] Unable to load texture: ";
+        sz.append(szPath->data);
+        CLogDisplay::Instance().AddEntry(sz,D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+
+        this->SetDefaultTexture(p_ppiOut);
+    }
+    sCachedTextures[s] = *p_ppiOut;
+    (*p_ppiOut)->AddRef();
+
+    return 1;
 }
 //-------------------------------------------------------------------------------
 void CMaterialManager::DeleteMaterial(AssetHelper::MeshHelper* pcIn)
 {
-	if (!pcIn || !pcIn->piEffect)return;
-	pcIn->piEffect->Release();
-
-	// release all textures associated with the material
-	if (pcIn->piDiffuseTexture)
-	{
-		pcIn->piDiffuseTexture->Release();
-		pcIn->piDiffuseTexture = NULL;
-	}
-	if (pcIn->piSpecularTexture)
-	{
-		pcIn->piSpecularTexture->Release();
-		pcIn->piSpecularTexture = NULL;
-	}
-	if (pcIn->piEmissiveTexture)
-	{
-		pcIn->piEmissiveTexture->Release();
-		pcIn->piEmissiveTexture = NULL;
-	}
-	if (pcIn->piAmbientTexture)
-	{
-		pcIn->piAmbientTexture->Release();
-		pcIn->piAmbientTexture = NULL;
-	}
-	if (pcIn->piOpacityTexture)
-	{
-		pcIn->piOpacityTexture->Release();
-		pcIn->piOpacityTexture = NULL;
-	}
-	if (pcIn->piNormalTexture)
-	{
-		pcIn->piNormalTexture->Release();
-		pcIn->piNormalTexture = NULL;
-	}
-	if (pcIn->piShininessTexture)
-	{
-		pcIn->piShininessTexture->Release();
-		pcIn->piShininessTexture = NULL;
-	}
-	if (pcIn->piLightmapTexture)
-	{
-		pcIn->piLightmapTexture->Release();
-		pcIn->piLightmapTexture = NULL;
-	}
-	pcIn->piEffect = NULL;
+    if (!pcIn || !pcIn->piEffect)return;
+    pcIn->piEffect->Release();
+
+    // release all textures associated with the material
+    if (pcIn->piDiffuseTexture)
+    {
+        pcIn->piDiffuseTexture->Release();
+        pcIn->piDiffuseTexture = NULL;
+    }
+    if (pcIn->piSpecularTexture)
+    {
+        pcIn->piSpecularTexture->Release();
+        pcIn->piSpecularTexture = NULL;
+    }
+    if (pcIn->piEmissiveTexture)
+    {
+        pcIn->piEmissiveTexture->Release();
+        pcIn->piEmissiveTexture = NULL;
+    }
+    if (pcIn->piAmbientTexture)
+    {
+        pcIn->piAmbientTexture->Release();
+        pcIn->piAmbientTexture = NULL;
+    }
+    if (pcIn->piOpacityTexture)
+    {
+        pcIn->piOpacityTexture->Release();
+        pcIn->piOpacityTexture = NULL;
+    }
+    if (pcIn->piNormalTexture)
+    {
+        pcIn->piNormalTexture->Release();
+        pcIn->piNormalTexture = NULL;
+    }
+    if (pcIn->piShininessTexture)
+    {
+        pcIn->piShininessTexture->Release();
+        pcIn->piShininessTexture = NULL;
+    }
+    if (pcIn->piLightmapTexture)
+    {
+        pcIn->piLightmapTexture->Release();
+        pcIn->piLightmapTexture = NULL;
+    }
+    pcIn->piEffect = NULL;
 }
 //-------------------------------------------------------------------------------
 void CMaterialManager::HMtoNMIfNecessary(
-	IDirect3DTexture9* piTexture,
-	IDirect3DTexture9** piTextureOut,
-	bool bWasOriginallyHM)
+    IDirect3DTexture9* piTexture,
+    IDirect3DTexture9** piTextureOut,
+    bool bWasOriginallyHM)
 {
-	ai_assert(NULL != piTexture);
-	ai_assert(NULL != piTextureOut);
-
-	bool bMustConvert = false;
-	uintptr_t iElement = 3;
-
-	*piTextureOut = piTexture;
-
-	// Lock the input texture and try to determine its type.
-	// Criterias:
-	// - If r,g,b channel are identical it MUST be a height map
-	// - If one of the rgb channels is used and the others are empty it
-	//   must be a height map, too.
-	// - If the average color of the whole image is something inside the
-	//   purple range we can be sure it is a normal map
-	//
-	// - Otherwise we assume it is a normal map
-	// To increase performance we take not every pixel
-
-	D3DLOCKED_RECT sRect;
-	D3DSURFACE_DESC sDesc;
-	piTexture->GetLevelDesc(0,&sDesc);
-	if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
-	{
-		return;
-	}
-	const int iPitchDiff = (int)sRect.Pitch - (int)(sDesc.Width * 4);
-
-	struct SColor
-	{
-		union
-		{
-			struct {unsigned char b,g,r,a;};
-			char _array[4];
-		};
-	};
-	const SColor* pcData = (const SColor*)sRect.pBits;
-
-	union
-	{
-		const SColor* pcPointer;
-		const unsigned char* pcCharPointer;
-	};
-	pcPointer = pcData;
-
-	// 1. If r,g,b channel are identical it MUST be a height map
-	bool bIsEqual = true;
-	for (unsigned int y = 0; y <  sDesc.Height;++y)
-	{
-		for (unsigned int x = 0; x <  sDesc.Width;++x)
-		{
-			if (pcPointer->b != pcPointer->r || pcPointer->b != pcPointer->g)
-			{
-				bIsEqual = false;
-				break;
-			}
-			pcPointer++;
-		}
-		pcCharPointer += iPitchDiff;
-	}
-	if (bIsEqual)bMustConvert = true;
-	else
-	{
-		// 2. If one of the rgb channels is used and the others are empty it
-		//    must be a height map, too.
-		pcPointer = pcData;
-		while (*pcCharPointer == 0)pcCharPointer++;
-
-		iElement = (uintptr_t)(pcCharPointer - (unsigned char*)pcData) % 4;
-		unsigned int aiIndex[3] = {0,1,2};
-		if (3 != iElement)aiIndex[iElement] = 3;
-
-		pcPointer = pcData;
-
-		bIsEqual = true;
-		if (3 != iElement)
-		{
-			for (unsigned int y = 0; y <  sDesc.Height;++y)
-			{
-				for (unsigned int x = 0; x <  sDesc.Width;++x)
-				{
-					for (unsigned int ii = 0; ii < 3;++ii)
-					{
-						// don't take the alpha channel into account.
-						// if the texture was stored n RGB888 format D3DX has
-						// converted it to ARGB8888 format with a fixed alpha channel
-						if (aiIndex[ii] != 3 && pcPointer->_array[aiIndex[ii]] != 0)
-						{
-							bIsEqual = false;
-							break;
-						}
-					}
-					pcPointer++;
-				}
-				pcCharPointer += iPitchDiff;
-			}
-			if (bIsEqual)bMustConvert = true;
-			else
-			{
-				// If the average color of the whole image is something inside the
-				// purple range we can be sure it is a normal map
-
-				// (calculate the average color line per line to prevent overflows!)
-				pcPointer = pcData;
-				aiColor3D clrColor;
-				for (unsigned int y = 0; y <  sDesc.Height;++y)
-				{
-					aiColor3D clrColorLine;
-					for (unsigned int x = 0; x <  sDesc.Width;++x)
-					{
-						clrColorLine.r += pcPointer->r;
-						clrColorLine.g += pcPointer->g;
-						clrColorLine.b += pcPointer->b;
-						pcPointer++;
-					}
-					clrColor.r += clrColorLine.r /= (float)sDesc.Width;
-					clrColor.g += clrColorLine.g /= (float)sDesc.Width;
-					clrColor.b += clrColorLine.b /= (float)sDesc.Width;
-					pcCharPointer += iPitchDiff;
-				}
-				clrColor.r /= (float)sDesc.Height;
-				clrColor.g /= (float)sDesc.Height;
-				clrColor.b /= (float)sDesc.Height;
-
-				if (!(clrColor.b > 215 && 
-					clrColor.r > 100 && clrColor.r < 140 && 
-					clrColor.g > 100 && clrColor.g < 140))
-				{
-					// Unable to detect. Believe the original value obtained from the loader
-					if (bWasOriginallyHM)
-					{
-						bMustConvert = true;
-					}
-				}
-			}
-		}
-	}
-
-	piTexture->UnlockRect(0);
-
-	// if the input data is assumed to be a height map we'll
-	// need to convert it NOW
-	if (bMustConvert)
-	{
-		D3DSURFACE_DESC sDesc;
-		piTexture->GetLevelDesc(0, &sDesc);
-
-		IDirect3DTexture9* piTempTexture;
-		if(FAILED(g_piDevice->CreateTexture(
-			sDesc.Width,
-			sDesc.Height,
-			piTexture->GetLevelCount(),
-			sDesc.Usage,
-			sDesc.Format,
-			sDesc.Pool, &piTempTexture, NULL)))
-		{
-			CLogDisplay::Instance().AddEntry(
-				"[ERROR] Unable to create normal map texture",
-				D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-			return;
-		}
-
-		DWORD dwFlags;
-		if (3 == iElement)dwFlags = D3DX_CHANNEL_LUMINANCE;
-		else if (2 == iElement)dwFlags = D3DX_CHANNEL_RED;
-		else if (1 == iElement)dwFlags = D3DX_CHANNEL_GREEN;
-		else /*if (0 == iElement)*/dwFlags = D3DX_CHANNEL_BLUE;
-
-		if(FAILED(D3DXComputeNormalMap(piTempTexture,
-			piTexture,NULL,0,dwFlags,1.0f)))
-		{
-			CLogDisplay::Instance().AddEntry(
-				"[ERROR] Unable to compute normal map from height map",
-				D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
-
-			piTempTexture->Release();
-			return;
-		}
-		*piTextureOut = piTempTexture;
-		piTexture->Release();
-	}
+    ai_assert(NULL != piTexture);
+    ai_assert(NULL != piTextureOut);
+
+    bool bMustConvert = false;
+    uintptr_t iElement = 3;
+
+    *piTextureOut = piTexture;
+
+    // Lock the input texture and try to determine its type.
+    // Criterias:
+    // - If r,g,b channel are identical it MUST be a height map
+    // - If one of the rgb channels is used and the others are empty it
+    //   must be a height map, too.
+    // - If the average color of the whole image is something inside the
+    //   purple range we can be sure it is a normal map
+    //
+    // - Otherwise we assume it is a normal map
+    // To increase performance we take not every pixel
+
+    D3DLOCKED_RECT sRect;
+    D3DSURFACE_DESC sDesc;
+    piTexture->GetLevelDesc(0,&sDesc);
+    if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
+    {
+        return;
+    }
+    const int iPitchDiff = (int)sRect.Pitch - (int)(sDesc.Width * 4);
+
+    struct SColor
+    {
+        union
+        {
+            struct {unsigned char b,g,r,a;};
+            char _array[4];
+        };
+    };
+    const SColor* pcData = (const SColor*)sRect.pBits;
+
+    union
+    {
+        const SColor* pcPointer;
+        const unsigned char* pcCharPointer;
+    };
+    pcPointer = pcData;
+
+    // 1. If r,g,b channel are identical it MUST be a height map
+    bool bIsEqual = true;
+    for (unsigned int y = 0; y <  sDesc.Height;++y)
+    {
+        for (unsigned int x = 0; x <  sDesc.Width;++x)
+        {
+            if (pcPointer->b != pcPointer->r || pcPointer->b != pcPointer->g)
+            {
+                bIsEqual = false;
+                break;
+            }
+            pcPointer++;
+        }
+        pcCharPointer += iPitchDiff;
+    }
+    if (bIsEqual)bMustConvert = true;
+    else
+    {
+        // 2. If one of the rgb channels is used and the others are empty it
+        //    must be a height map, too.
+        pcPointer = pcData;
+        while (*pcCharPointer == 0)pcCharPointer++;
+
+        iElement = (uintptr_t)(pcCharPointer - (unsigned char*)pcData) % 4;
+        unsigned int aiIndex[3] = {0,1,2};
+        if (3 != iElement)aiIndex[iElement] = 3;
+
+        pcPointer = pcData;
+
+        bIsEqual = true;
+        if (3 != iElement)
+        {
+            for (unsigned int y = 0; y <  sDesc.Height;++y)
+            {
+                for (unsigned int x = 0; x <  sDesc.Width;++x)
+                {
+                    for (unsigned int ii = 0; ii < 3;++ii)
+                    {
+                        // don't take the alpha channel into account.
+                        // if the texture was stored n RGB888 format D3DX has
+                        // converted it to ARGB8888 format with a fixed alpha channel
+                        if (aiIndex[ii] != 3 && pcPointer->_array[aiIndex[ii]] != 0)
+                        {
+                            bIsEqual = false;
+                            break;
+                        }
+                    }
+                    pcPointer++;
+                }
+                pcCharPointer += iPitchDiff;
+            }
+            if (bIsEqual)bMustConvert = true;
+            else
+            {
+                // If the average color of the whole image is something inside the
+                // purple range we can be sure it is a normal map
+
+                // (calculate the average color line per line to prevent overflows!)
+                pcPointer = pcData;
+                aiColor3D clrColor;
+                for (unsigned int y = 0; y <  sDesc.Height;++y)
+                {
+                    aiColor3D clrColorLine;
+                    for (unsigned int x = 0; x <  sDesc.Width;++x)
+                    {
+                        clrColorLine.r += pcPointer->r;
+                        clrColorLine.g += pcPointer->g;
+                        clrColorLine.b += pcPointer->b;
+                        pcPointer++;
+                    }
+                    clrColor.r += clrColorLine.r /= (float)sDesc.Width;
+                    clrColor.g += clrColorLine.g /= (float)sDesc.Width;
+                    clrColor.b += clrColorLine.b /= (float)sDesc.Width;
+                    pcCharPointer += iPitchDiff;
+                }
+                clrColor.r /= (float)sDesc.Height;
+                clrColor.g /= (float)sDesc.Height;
+                clrColor.b /= (float)sDesc.Height;
+
+                if (!(clrColor.b > 215 && 
+                    clrColor.r > 100 && clrColor.r < 140 && 
+                    clrColor.g > 100 && clrColor.g < 140))
+                {
+                    // Unable to detect. Believe the original value obtained from the loader
+                    if (bWasOriginallyHM)
+                    {
+                        bMustConvert = true;
+                    }
+                }
+            }
+        }
+    }
+
+    piTexture->UnlockRect(0);
+
+    // if the input data is assumed to be a height map we'll
+    // need to convert it NOW
+    if (bMustConvert)
+    {
+        D3DSURFACE_DESC sDesc;
+        piTexture->GetLevelDesc(0, &sDesc);
+
+        IDirect3DTexture9* piTempTexture;
+        if(FAILED(g_piDevice->CreateTexture(
+            sDesc.Width,
+            sDesc.Height,
+            piTexture->GetLevelCount(),
+            sDesc.Usage,
+            sDesc.Format,
+            sDesc.Pool, &piTempTexture, NULL)))
+        {
+            CLogDisplay::Instance().AddEntry(
+                "[ERROR] Unable to create normal map texture",
+                D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+            return;
+        }
+
+        DWORD dwFlags;
+        if (3 == iElement)dwFlags = D3DX_CHANNEL_LUMINANCE;
+        else if (2 == iElement)dwFlags = D3DX_CHANNEL_RED;
+        else if (1 == iElement)dwFlags = D3DX_CHANNEL_GREEN;
+        else /*if (0 == iElement)*/dwFlags = D3DX_CHANNEL_BLUE;
+
+        if(FAILED(D3DXComputeNormalMap(piTempTexture,
+            piTexture,NULL,0,dwFlags,1.0f)))
+        {
+            CLogDisplay::Instance().AddEntry(
+                "[ERROR] Unable to compute normal map from height map",
+                D3DCOLOR_ARGB(0xFF,0xFF,0x0,0x0));
+
+            piTempTexture->Release();
+            return;
+        }
+        *piTextureOut = piTempTexture;
+        piTexture->Release();
+    }
 }
 //-------------------------------------------------------------------------------
 bool CMaterialManager::HasAlphaPixels(IDirect3DTexture9* piTexture)
 {
-	ai_assert(NULL != piTexture);
-
-	D3DLOCKED_RECT sRect;
-	D3DSURFACE_DESC sDesc;
-	piTexture->GetLevelDesc(0,&sDesc);
-	if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
-	{
-		return false;
-	}
-	const int iPitchDiff = (int)sRect.Pitch - (int)(sDesc.Width * 4);
-
-	struct SColor
-	{
-		unsigned char b,g,r,a;;
-	};
-	const SColor* pcData = (const SColor*)sRect.pBits;
-
-	union
-	{
-		const SColor* pcPointer;
-		const unsigned char* pcCharPointer;
-	};
-	pcPointer = pcData;
-	for (unsigned int y = 0; y <  sDesc.Height;++y)
-	{
-		for (unsigned int x = 0; x <  sDesc.Width;++x)
-		{
-			if (pcPointer->a != 0xFF)
-			{
-				piTexture->UnlockRect(0);
-				return true;
-			}
-			pcPointer++;
-		}
-		pcCharPointer += iPitchDiff;
-	}
-	piTexture->UnlockRect(0);
-	return false;
+    ai_assert(NULL != piTexture);
+
+    D3DLOCKED_RECT sRect;
+    D3DSURFACE_DESC sDesc;
+    piTexture->GetLevelDesc(0,&sDesc);
+    if (FAILED(piTexture->LockRect(0,&sRect,NULL,D3DLOCK_READONLY)))
+    {
+        return false;
+    }
+    const int iPitchDiff = (int)sRect.Pitch - (int)(sDesc.Width * 4);
+
+    struct SColor
+    {
+        unsigned char b,g,r,a;;
+    };
+    const SColor* pcData = (const SColor*)sRect.pBits;
+
+    union
+    {
+        const SColor* pcPointer;
+        const unsigned char* pcCharPointer;
+    };
+    pcPointer = pcData;
+    for (unsigned int y = 0; y <  sDesc.Height;++y)
+    {
+        for (unsigned int x = 0; x <  sDesc.Width;++x)
+        {
+            if (pcPointer->a != 0xFF)
+            {
+                piTexture->UnlockRect(0);
+                return true;
+            }
+            pcPointer++;
+        }
+        pcCharPointer += iPitchDiff;
+    }
+    piTexture->UnlockRect(0);
+    return false;
 }
 //-------------------------------------------------------------------------------
 int CMaterialManager::CreateMaterial(
-	AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource)
+    AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource)
 {
-	ai_assert(NULL != pcMesh);
-	ai_assert(NULL != pcSource);
-
-	ID3DXBuffer* piBuffer;
-
-	D3DXMACRO sMacro[64];
-
-	// extract all properties from the ASSIMP material structure
-	const aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[pcSource->mMaterialIndex];
-
-	//
-	// DIFFUSE COLOR --------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_DIFFUSE,
-		(aiColor4D*)&pcMesh->vDiffuseColor))
-	{
-		pcMesh->vDiffuseColor.x = 1.0f;
-		pcMesh->vDiffuseColor.y = 1.0f;
-		pcMesh->vDiffuseColor.z = 1.0f;
-		pcMesh->vDiffuseColor.w = 1.0f;
-	}
-	//
-	// SPECULAR COLOR --------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_SPECULAR,
-		(aiColor4D*)&pcMesh->vSpecularColor))
-	{
-		pcMesh->vSpecularColor.x = 1.0f;
-		pcMesh->vSpecularColor.y = 1.0f;
-		pcMesh->vSpecularColor.z = 1.0f;
-		pcMesh->vSpecularColor.w = 1.0f;
-	}
-	//
-	// AMBIENT COLOR --------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_AMBIENT,
-		(aiColor4D*)&pcMesh->vAmbientColor))
-	{
-		pcMesh->vAmbientColor.x = 0.0f;
-		pcMesh->vAmbientColor.y = 0.0f;
-		pcMesh->vAmbientColor.z = 0.0f;
-		pcMesh->vAmbientColor.w = 1.0f;
-	}
-	//
-	// EMISSIVE COLOR -------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_EMISSIVE,
-		(aiColor4D*)&pcMesh->vEmissiveColor))
-	{
-		pcMesh->vEmissiveColor.x = 0.0f;
-		pcMesh->vEmissiveColor.y = 0.0f;
-		pcMesh->vEmissiveColor.z = 0.0f;
-		pcMesh->vEmissiveColor.w = 1.0f;
-	}
-
-	//
-	// Opacity --------------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_OPACITY,&pcMesh->fOpacity))
-	{
-		pcMesh->fOpacity = 1.0f;
-	}
-
-	//
-	// Shading Model --------------------------------------------------
-	//
-	bool bDefault = false;
-	if(AI_SUCCESS != aiGetMaterialInteger(pcMat,AI_MATKEY_SHADING_MODEL,(int*)&pcMesh->eShadingMode ))
-	{
-		bDefault = true;
-		pcMesh->eShadingMode = aiShadingMode_Gouraud;
-	}
-
-
-	//
-	// Shininess ------------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_SHININESS,&pcMesh->fShininess))
-	{
-		// assume 15 as default shininess
-		pcMesh->fShininess = 15.0f;
-	}
-	else if (bDefault)pcMesh->eShadingMode  = aiShadingMode_Phong;
-
-
-	//
-	// Shininess strength ------------------------------------------------------
-	//
-	if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_SHININESS_STRENGTH,&pcMesh->fSpecularStrength))
-	{
-		// assume 1.0 as default shininess strength
-		pcMesh->fSpecularStrength = 1.0f;
-	}
-
-	aiString szPath;
-
-	aiTextureMapMode mapU(aiTextureMapMode_Wrap),mapV(aiTextureMapMode_Wrap);
-
-	bool bib =false;
-	if (pcSource->mTextureCoords[0])
-	{
-
-		//
-		// DIFFUSE TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_DIFFUSE(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piDiffuseTexture,&szPath);
-
-			aiGetMaterialInteger(pcMat,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(0),(int*)&mapU);
-			aiGetMaterialInteger(pcMat,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0),(int*)&mapV);
-		}
-
-		//
-		// SPECULAR TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_SPECULAR(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piSpecularTexture,&szPath);
-		}
-
-		//
-		// OPACITY TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_OPACITY(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piOpacityTexture,&szPath);
-		}
-		else
-		{
-			int flags = 0;
-			aiGetMaterialInteger(pcMat,AI_MATKEY_TEXFLAGS_DIFFUSE(0),&flags);
-
-			// try to find out whether the diffuse texture has any
-			// non-opaque pixels. If we find a few, use it as opacity texture
-			if (pcMesh->piDiffuseTexture && !(flags & aiTextureFlags_IgnoreAlpha) && HasAlphaPixels(pcMesh->piDiffuseTexture))
-			{
-				int iVal;
-
-				// NOTE: This special value is set by the tree view if the user
-				// manually removes the alpha texture from the view ...
-				if (AI_SUCCESS != aiGetMaterialInteger(pcMat,"no_a_from_d",0,0,&iVal))
-				{
-					pcMesh->piOpacityTexture = pcMesh->piDiffuseTexture;
-					pcMesh->piOpacityTexture->AddRef();
-				}
-			}
-		}
-
-		//
-		// AMBIENT TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_AMBIENT(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piAmbientTexture,&szPath);
-		}
-
-		//
-		// EMISSIVE TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_EMISSIVE(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piEmissiveTexture,&szPath);
-		}
-
-		//
-		// Shininess TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_SHININESS(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piShininessTexture,&szPath);
-		}
-
-		//
-		// Lightmap TEXTURE ------------------------------------------------
-		//
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_LIGHTMAP(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piLightmapTexture,&szPath);
-		}
-
-
-		//
-		// NORMAL/HEIGHT MAP ------------------------------------------------
-		//
-		bool bHM = false;
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_NORMALS(0),&szPath))
-		{
-			LoadTexture(&pcMesh->piNormalTexture,&szPath);
-		}
-		else
-		{
-			if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_HEIGHT(0),&szPath))
-			{
-				LoadTexture(&pcMesh->piNormalTexture,&szPath);
-			}
-			else bib = true;
-			bHM = true;
-		}
-
-		// normal/height maps are sometimes mixed up. Try to detect the type
-		// of the texture automatically
-		if (pcMesh->piNormalTexture)
-		{
-			HMtoNMIfNecessary(pcMesh->piNormalTexture, &pcMesh->piNormalTexture,bHM);
-		}
-	}
-
-	// check whether a global background texture is contained
-	// in this material. Some loaders set this value ...
-	if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_GLOBAL_BACKGROUND_IMAGE,&szPath))
-	{
-		CBackgroundPainter::Instance().SetTextureBG(szPath.data);
-	}
-
-	// BUGFIX: If the shininess is 0.0f disable phong lighting
-	// This is a workaround for some meshes in the DX SDK (e.g. tiny.x)
-	// FIX: Added this check to the x-loader, but the line remains to
-	// catch other loader doing the same ...
-	if (0.0f == pcMesh->fShininess){
-		pcMesh->eShadingMode = aiShadingMode_Gouraud;
-	}
-
-	int two_sided = 0;
-	aiGetMaterialInteger(pcMat,AI_MATKEY_TWOSIDED,&two_sided);
-	pcMesh->twosided = (two_sided != 0);
-
-	// check whether we have already a material using the same
-	// shader. This will decrease loading time rapidly ...
-	for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
-	{
-		if (g_pcAsset->pcScene->mMeshes[i] == pcSource)
-		{
-			break;
-		}
-		AssetHelper::MeshHelper* pc = g_pcAsset->apcMeshes[i];
-
-		if  ((pcMesh->piDiffuseTexture != NULL ? true : false) != 
-			(pc->piDiffuseTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piSpecularTexture != NULL ? true : false) != 
-			(pc->piSpecularTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piAmbientTexture != NULL ? true : false) != 
-			(pc->piAmbientTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piEmissiveTexture != NULL ? true : false) != 
-			(pc->piEmissiveTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piNormalTexture != NULL ? true : false) != 
-			(pc->piNormalTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piOpacityTexture != NULL ? true : false) != 
-			(pc->piOpacityTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piShininessTexture != NULL ? true : false) != 
-			(pc->piShininessTexture != NULL ? true : false))
-			continue;
-		if  ((pcMesh->piLightmapTexture != NULL ? true : false) != 
-			(pc->piLightmapTexture != NULL ? true : false))
-			continue;
-		if ((pcMesh->eShadingMode != aiShadingMode_Gouraud ? true : false) != 
-			(pc->eShadingMode != aiShadingMode_Gouraud ? true : false))
-			continue;
-
-		if ((pcMesh->fOpacity != 1.0f ? true : false) != (pc->fOpacity != 1.0f ? true : false))
-			continue;
-
-		if (pcSource->HasBones() != g_pcAsset->pcScene->mMeshes[i]->HasBones())
-			continue;
-
-		// we can reuse this material
-		if (pc->piEffect)
-		{
-			pcMesh->piEffect = pc->piEffect;
-			pc->bSharedFX = pcMesh->bSharedFX = true;
-			pcMesh->piEffect->AddRef();
-			return 2;
-		}
-	}
-	m_iShaderCount++;
-
-	// build macros for the HLSL compiler
-	unsigned int iCurrent = 0;
-	if (pcMesh->piDiffuseTexture)
-	{
-		sMacro[iCurrent].Name = "AV_DIFFUSE_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-
-		if (mapU == aiTextureMapMode_Wrap)
-			sMacro[iCurrent].Name = "AV_WRAPU";
-		else if (mapU == aiTextureMapMode_Mirror)
-			sMacro[iCurrent].Name = "AV_MIRRORU";
-		else // if (mapU == aiTextureMapMode_Clamp)
-			sMacro[iCurrent].Name = "AV_CLAMPU";
-
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-
-
-		if (mapV == aiTextureMapMode_Wrap)
-			sMacro[iCurrent].Name = "AV_WRAPV";
-		else if (mapV == aiTextureMapMode_Mirror)
-			sMacro[iCurrent].Name = "AV_MIRRORV";
-		else // if (mapV == aiTextureMapMode_Clamp)
-			sMacro[iCurrent].Name = "AV_CLAMPV";
-
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	if (pcMesh->piSpecularTexture)
-	{
-		sMacro[iCurrent].Name = "AV_SPECULAR_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	if (pcMesh->piAmbientTexture)
-	{
-		sMacro[iCurrent].Name = "AV_AMBIENT_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	if (pcMesh->piEmissiveTexture)
-	{
-		sMacro[iCurrent].Name = "AV_EMISSIVE_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	char buff[32];
-	if (pcMesh->piLightmapTexture)
-	{
-		sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-
-		int idx;
-		if(AI_SUCCESS == aiGetMaterialInteger(pcMat,AI_MATKEY_UVWSRC_LIGHTMAP(0),&idx) && idx >= 1 && pcSource->mTextureCoords[idx])	{
-			sMacro[iCurrent].Name = "AV_TWO_UV";
-			sMacro[iCurrent].Definition = "1";
-			++iCurrent;
-
-			sMacro[iCurrent].Definition = "IN.TexCoord1";
-		}
-		else sMacro[iCurrent].Definition = "IN.TexCoord0";
-		sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE_UV_COORD";
-
-		++iCurrent;float f= 1.f;
-		aiGetMaterialFloat(pcMat,AI_MATKEY_TEXBLEND_LIGHTMAP(0),&f);
-		sprintf(buff,"%f",f);
-
-		sMacro[iCurrent].Name = "LM_STRENGTH";
-		sMacro[iCurrent].Definition = buff;
-		++iCurrent;
-	}
-	if (pcMesh->piNormalTexture && !bib)
-	{
-		sMacro[iCurrent].Name = "AV_NORMAL_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	if (pcMesh->piOpacityTexture)
-	{
-		sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-
-		if (pcMesh->piOpacityTexture == pcMesh->piDiffuseTexture)
-		{
-			sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE_REGISTER_MASK";
-			sMacro[iCurrent].Definition = "a";
-			++iCurrent;
-		}
-		else
-		{
-			sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE_REGISTER_MASK";
-			sMacro[iCurrent].Definition = "r";
-			++iCurrent;
-		}
-	}
-
-	if (pcMesh->eShadingMode  != aiShadingMode_Gouraud  && !g_sOptions.bNoSpecular)
-	{
-		sMacro[iCurrent].Name = "AV_SPECULAR_COMPONENT";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-
-		if (pcMesh->piShininessTexture)
-		{
-			sMacro[iCurrent].Name = "AV_SHININESS_TEXTURE";
-			sMacro[iCurrent].Definition = "1";
-			++iCurrent;
-		}
-	}
-	if (1.0f != pcMesh->fOpacity)
-	{
-		sMacro[iCurrent].Name = "AV_OPACITY";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-
-	if( pcSource->HasBones())
-	{
-		sMacro[iCurrent].Name = "AV_SKINNING";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-
-	// If a cubemap is active, we'll need to lookup it for calculating
-	// a physically correct reflection
-	if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode())
-	{
-		sMacro[iCurrent].Name = "AV_SKYBOX_LOOKUP";
-		sMacro[iCurrent].Definition = "1";
-		++iCurrent;
-	}
-	sMacro[iCurrent].Name = NULL;
-	sMacro[iCurrent].Definition = NULL;
-
-	// compile the shader
-	if(FAILED( D3DXCreateEffect(g_piDevice,
-		g_szMaterialShader.c_str(),(UINT)g_szMaterialShader.length(),
-		(const D3DXMACRO*)sMacro,NULL,0,NULL,&pcMesh->piEffect,&piBuffer)))
-	{
-		// failed to compile the shader
-		if( piBuffer) 
-		{
-			MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
-			piBuffer->Release();
-		}
-		// use the default material instead
-		if (g_piDefaultEffect)
-		{
-			pcMesh->piEffect = g_piDefaultEffect;
-			g_piDefaultEffect->AddRef();
-		}
-
-		// get the name of the material and use it in the log message
-		if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szPath) &&
-			'\0' != szPath.data[0])
-		{
-			std::string sz = "[ERROR] Unable to load material: ";
-			sz.append(szPath.data);
-			CLogDisplay::Instance().AddEntry(sz);
-		}
-		else
-		{
-			CLogDisplay::Instance().AddEntry("Unable to load material: UNNAMED");
-		}
-		return 0;
-	} else
-	{
-		// use Fixed Function effect when working with shaderless cards
-		if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
-			pcMesh->piEffect->SetTechnique( "MaterialFX_FF");
-	}
-
-	if( piBuffer) piBuffer->Release();
-
-
-	// now commit all constants to the shader
-	//
-	// This is not necessary for shared shader. Shader constants for
-	// shared shaders are automatically recommited before the shader
-	// is being used for a particular mesh
-
-	if (1.0f != pcMesh->fOpacity)
-		pcMesh->piEffect->SetFloat("TRANSPARENCY",pcMesh->fOpacity);
-	if (pcMesh->eShadingMode  != aiShadingMode_Gouraud && !g_sOptions.bNoSpecular)
-	{
-		pcMesh->piEffect->SetFloat("SPECULARITY",pcMesh->fShininess);
-		pcMesh->piEffect->SetFloat("SPECULAR_STRENGTH",pcMesh->fSpecularStrength);
-	}
-
-	pcMesh->piEffect->SetVector("DIFFUSE_COLOR",&pcMesh->vDiffuseColor);
-	pcMesh->piEffect->SetVector("SPECULAR_COLOR",&pcMesh->vSpecularColor);
-	pcMesh->piEffect->SetVector("AMBIENT_COLOR",&pcMesh->vAmbientColor);
-	pcMesh->piEffect->SetVector("EMISSIVE_COLOR",&pcMesh->vEmissiveColor);
-
-	if (pcMesh->piDiffuseTexture)
-		pcMesh->piEffect->SetTexture("DIFFUSE_TEXTURE",pcMesh->piDiffuseTexture);
-	if (pcMesh->piOpacityTexture)
-		pcMesh->piEffect->SetTexture("OPACITY_TEXTURE",pcMesh->piOpacityTexture);
-	if (pcMesh->piSpecularTexture)
-		pcMesh->piEffect->SetTexture("SPECULAR_TEXTURE",pcMesh->piSpecularTexture);
-	if (pcMesh->piAmbientTexture)
-		pcMesh->piEffect->SetTexture("AMBIENT_TEXTURE",pcMesh->piAmbientTexture);
-	if (pcMesh->piEmissiveTexture)
-		pcMesh->piEffect->SetTexture("EMISSIVE_TEXTURE",pcMesh->piEmissiveTexture);
-	if (pcMesh->piNormalTexture)
-		pcMesh->piEffect->SetTexture("NORMAL_TEXTURE",pcMesh->piNormalTexture);
-	if (pcMesh->piShininessTexture)
-		pcMesh->piEffect->SetTexture("SHININESS_TEXTURE",pcMesh->piShininessTexture);
-	if (pcMesh->piLightmapTexture)
-		pcMesh->piEffect->SetTexture("LIGHTMAP_TEXTURE",pcMesh->piLightmapTexture);
-
-	if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode()){
-		pcMesh->piEffect->SetTexture("lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
-	}
-
-	return 1;
+    ai_assert(NULL != pcMesh);
+    ai_assert(NULL != pcSource);
+
+    ID3DXBuffer* piBuffer;
+
+    D3DXMACRO sMacro[64];
+
+    // extract all properties from the ASSIMP material structure
+    const aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[pcSource->mMaterialIndex];
+
+    //
+    // DIFFUSE COLOR --------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_DIFFUSE,
+        (aiColor4D*)&pcMesh->vDiffuseColor))
+    {
+        pcMesh->vDiffuseColor.x = 1.0f;
+        pcMesh->vDiffuseColor.y = 1.0f;
+        pcMesh->vDiffuseColor.z = 1.0f;
+        pcMesh->vDiffuseColor.w = 1.0f;
+    }
+    //
+    // SPECULAR COLOR --------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_SPECULAR,
+        (aiColor4D*)&pcMesh->vSpecularColor))
+    {
+        pcMesh->vSpecularColor.x = 1.0f;
+        pcMesh->vSpecularColor.y = 1.0f;
+        pcMesh->vSpecularColor.z = 1.0f;
+        pcMesh->vSpecularColor.w = 1.0f;
+    }
+    //
+    // AMBIENT COLOR --------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_AMBIENT,
+        (aiColor4D*)&pcMesh->vAmbientColor))
+    {
+        pcMesh->vAmbientColor.x = 0.0f;
+        pcMesh->vAmbientColor.y = 0.0f;
+        pcMesh->vAmbientColor.z = 0.0f;
+        pcMesh->vAmbientColor.w = 1.0f;
+    }
+    //
+    // EMISSIVE COLOR -------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialColor(pcMat,AI_MATKEY_COLOR_EMISSIVE,
+        (aiColor4D*)&pcMesh->vEmissiveColor))
+    {
+        pcMesh->vEmissiveColor.x = 0.0f;
+        pcMesh->vEmissiveColor.y = 0.0f;
+        pcMesh->vEmissiveColor.z = 0.0f;
+        pcMesh->vEmissiveColor.w = 1.0f;
+    }
+
+    //
+    // Opacity --------------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_OPACITY,&pcMesh->fOpacity))
+    {
+        pcMesh->fOpacity = 1.0f;
+    }
+
+    //
+    // Shading Model --------------------------------------------------
+    //
+    bool bDefault = false;
+    if(AI_SUCCESS != aiGetMaterialInteger(pcMat,AI_MATKEY_SHADING_MODEL,(int*)&pcMesh->eShadingMode ))
+    {
+        bDefault = true;
+        pcMesh->eShadingMode = aiShadingMode_Gouraud;
+    }
+
+
+    //
+    // Shininess ------------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_SHININESS,&pcMesh->fShininess))
+    {
+        // assume 15 as default shininess
+        pcMesh->fShininess = 15.0f;
+    }
+    else if (bDefault)pcMesh->eShadingMode  = aiShadingMode_Phong;
+
+
+    //
+    // Shininess strength ------------------------------------------------------
+    //
+    if(AI_SUCCESS != aiGetMaterialFloat(pcMat,AI_MATKEY_SHININESS_STRENGTH,&pcMesh->fSpecularStrength))
+    {
+        // assume 1.0 as default shininess strength
+        pcMesh->fSpecularStrength = 1.0f;
+    }
+
+    aiString szPath;
+
+    aiTextureMapMode mapU(aiTextureMapMode_Wrap),mapV(aiTextureMapMode_Wrap);
+
+    bool bib =false;
+    if (pcSource->mTextureCoords[0])
+    {
+
+        //
+        // DIFFUSE TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_DIFFUSE(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piDiffuseTexture,&szPath);
+
+            aiGetMaterialInteger(pcMat,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(0),(int*)&mapU);
+            aiGetMaterialInteger(pcMat,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0),(int*)&mapV);
+        }
+
+        //
+        // SPECULAR TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_SPECULAR(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piSpecularTexture,&szPath);
+        }
+
+        //
+        // OPACITY TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_OPACITY(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piOpacityTexture,&szPath);
+        }
+        else
+        {
+            int flags = 0;
+            aiGetMaterialInteger(pcMat,AI_MATKEY_TEXFLAGS_DIFFUSE(0),&flags);
+
+            // try to find out whether the diffuse texture has any
+            // non-opaque pixels. If we find a few, use it as opacity texture
+            if (pcMesh->piDiffuseTexture && !(flags & aiTextureFlags_IgnoreAlpha) && HasAlphaPixels(pcMesh->piDiffuseTexture))
+            {
+                int iVal;
+
+                // NOTE: This special value is set by the tree view if the user
+                // manually removes the alpha texture from the view ...
+                if (AI_SUCCESS != aiGetMaterialInteger(pcMat,"no_a_from_d",0,0,&iVal))
+                {
+                    pcMesh->piOpacityTexture = pcMesh->piDiffuseTexture;
+                    pcMesh->piOpacityTexture->AddRef();
+                }
+            }
+        }
+
+        //
+        // AMBIENT TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_AMBIENT(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piAmbientTexture,&szPath);
+        }
+
+        //
+        // EMISSIVE TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_EMISSIVE(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piEmissiveTexture,&szPath);
+        }
+
+        //
+        // Shininess TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_SHININESS(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piShininessTexture,&szPath);
+        }
+
+        //
+        // Lightmap TEXTURE ------------------------------------------------
+        //
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_LIGHTMAP(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piLightmapTexture,&szPath);
+        }
+
+
+        //
+        // NORMAL/HEIGHT MAP ------------------------------------------------
+        //
+        bool bHM = false;
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_NORMALS(0),&szPath))
+        {
+            LoadTexture(&pcMesh->piNormalTexture,&szPath);
+        }
+        else
+        {
+            if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_TEXTURE_HEIGHT(0),&szPath))
+            {
+                LoadTexture(&pcMesh->piNormalTexture,&szPath);
+            }
+            else bib = true;
+            bHM = true;
+        }
+
+        // normal/height maps are sometimes mixed up. Try to detect the type
+        // of the texture automatically
+        if (pcMesh->piNormalTexture)
+        {
+            HMtoNMIfNecessary(pcMesh->piNormalTexture, &pcMesh->piNormalTexture,bHM);
+        }
+    }
+
+    // check whether a global background texture is contained
+    // in this material. Some loaders set this value ...
+    if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_GLOBAL_BACKGROUND_IMAGE,&szPath))
+    {
+        CBackgroundPainter::Instance().SetTextureBG(szPath.data);
+    }
+
+    // BUGFIX: If the shininess is 0.0f disable phong lighting
+    // This is a workaround for some meshes in the DX SDK (e.g. tiny.x)
+    // FIX: Added this check to the x-loader, but the line remains to
+    // catch other loader doing the same ...
+    if (0.0f == pcMesh->fShininess){
+        pcMesh->eShadingMode = aiShadingMode_Gouraud;
+    }
+
+    int two_sided = 0;
+    aiGetMaterialInteger(pcMat,AI_MATKEY_TWOSIDED,&two_sided);
+    pcMesh->twosided = (two_sided != 0);
+
+    // check whether we have already a material using the same
+    // shader. This will decrease loading time rapidly ...
+    for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
+    {
+        if (g_pcAsset->pcScene->mMeshes[i] == pcSource)
+        {
+            break;
+        }
+        AssetHelper::MeshHelper* pc = g_pcAsset->apcMeshes[i];
+
+        if  ((pcMesh->piDiffuseTexture != NULL ? true : false) != 
+            (pc->piDiffuseTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piSpecularTexture != NULL ? true : false) != 
+            (pc->piSpecularTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piAmbientTexture != NULL ? true : false) != 
+            (pc->piAmbientTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piEmissiveTexture != NULL ? true : false) != 
+            (pc->piEmissiveTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piNormalTexture != NULL ? true : false) != 
+            (pc->piNormalTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piOpacityTexture != NULL ? true : false) != 
+            (pc->piOpacityTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piShininessTexture != NULL ? true : false) != 
+            (pc->piShininessTexture != NULL ? true : false))
+            continue;
+        if  ((pcMesh->piLightmapTexture != NULL ? true : false) != 
+            (pc->piLightmapTexture != NULL ? true : false))
+            continue;
+        if ((pcMesh->eShadingMode != aiShadingMode_Gouraud ? true : false) != 
+            (pc->eShadingMode != aiShadingMode_Gouraud ? true : false))
+            continue;
+
+        if ((pcMesh->fOpacity != 1.0f ? true : false) != (pc->fOpacity != 1.0f ? true : false))
+            continue;
+
+        if (pcSource->HasBones() != g_pcAsset->pcScene->mMeshes[i]->HasBones())
+            continue;
+
+        // we can reuse this material
+        if (pc->piEffect)
+        {
+            pcMesh->piEffect = pc->piEffect;
+            pc->bSharedFX = pcMesh->bSharedFX = true;
+            pcMesh->piEffect->AddRef();
+            return 2;
+        }
+    }
+    m_iShaderCount++;
+
+    // build macros for the HLSL compiler
+    unsigned int iCurrent = 0;
+    if (pcMesh->piDiffuseTexture)
+    {
+        sMacro[iCurrent].Name = "AV_DIFFUSE_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+
+        if (mapU == aiTextureMapMode_Wrap)
+            sMacro[iCurrent].Name = "AV_WRAPU";
+        else if (mapU == aiTextureMapMode_Mirror)
+            sMacro[iCurrent].Name = "AV_MIRRORU";
+        else // if (mapU == aiTextureMapMode_Clamp)
+            sMacro[iCurrent].Name = "AV_CLAMPU";
+
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+
+
+        if (mapV == aiTextureMapMode_Wrap)
+            sMacro[iCurrent].Name = "AV_WRAPV";
+        else if (mapV == aiTextureMapMode_Mirror)
+            sMacro[iCurrent].Name = "AV_MIRRORV";
+        else // if (mapV == aiTextureMapMode_Clamp)
+            sMacro[iCurrent].Name = "AV_CLAMPV";
+
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    if (pcMesh->piSpecularTexture)
+    {
+        sMacro[iCurrent].Name = "AV_SPECULAR_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    if (pcMesh->piAmbientTexture)
+    {
+        sMacro[iCurrent].Name = "AV_AMBIENT_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    if (pcMesh->piEmissiveTexture)
+    {
+        sMacro[iCurrent].Name = "AV_EMISSIVE_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    char buff[32];
+    if (pcMesh->piLightmapTexture)
+    {
+        sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+
+        int idx;
+        if(AI_SUCCESS == aiGetMaterialInteger(pcMat,AI_MATKEY_UVWSRC_LIGHTMAP(0),&idx) && idx >= 1 && pcSource->mTextureCoords[idx])	{
+            sMacro[iCurrent].Name = "AV_TWO_UV";
+            sMacro[iCurrent].Definition = "1";
+            ++iCurrent;
+
+            sMacro[iCurrent].Definition = "IN.TexCoord1";
+        }
+        else sMacro[iCurrent].Definition = "IN.TexCoord0";
+        sMacro[iCurrent].Name = "AV_LIGHTMAP_TEXTURE_UV_COORD";
+
+        ++iCurrent;float f= 1.f;
+        aiGetMaterialFloat(pcMat,AI_MATKEY_TEXBLEND_LIGHTMAP(0),&f);
+        sprintf(buff,"%f",f);
+
+        sMacro[iCurrent].Name = "LM_STRENGTH";
+        sMacro[iCurrent].Definition = buff;
+        ++iCurrent;
+    }
+    if (pcMesh->piNormalTexture && !bib)
+    {
+        sMacro[iCurrent].Name = "AV_NORMAL_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    if (pcMesh->piOpacityTexture)
+    {
+        sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+
+        if (pcMesh->piOpacityTexture == pcMesh->piDiffuseTexture)
+        {
+            sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE_REGISTER_MASK";
+            sMacro[iCurrent].Definition = "a";
+            ++iCurrent;
+        }
+        else
+        {
+            sMacro[iCurrent].Name = "AV_OPACITY_TEXTURE_REGISTER_MASK";
+            sMacro[iCurrent].Definition = "r";
+            ++iCurrent;
+        }
+    }
+
+    if (pcMesh->eShadingMode  != aiShadingMode_Gouraud  && !g_sOptions.bNoSpecular)
+    {
+        sMacro[iCurrent].Name = "AV_SPECULAR_COMPONENT";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+
+        if (pcMesh->piShininessTexture)
+        {
+            sMacro[iCurrent].Name = "AV_SHININESS_TEXTURE";
+            sMacro[iCurrent].Definition = "1";
+            ++iCurrent;
+        }
+    }
+    if (1.0f != pcMesh->fOpacity)
+    {
+        sMacro[iCurrent].Name = "AV_OPACITY";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+
+    if( pcSource->HasBones())
+    {
+        sMacro[iCurrent].Name = "AV_SKINNING";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+
+    // If a cubemap is active, we'll need to lookup it for calculating
+    // a physically correct reflection
+    if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode())
+    {
+        sMacro[iCurrent].Name = "AV_SKYBOX_LOOKUP";
+        sMacro[iCurrent].Definition = "1";
+        ++iCurrent;
+    }
+    sMacro[iCurrent].Name = NULL;
+    sMacro[iCurrent].Definition = NULL;
+
+    // compile the shader
+    if(FAILED( D3DXCreateEffect(g_piDevice,
+        g_szMaterialShader.c_str(),(UINT)g_szMaterialShader.length(),
+        (const D3DXMACRO*)sMacro,NULL,0,NULL,&pcMesh->piEffect,&piBuffer)))
+    {
+        // failed to compile the shader
+        if( piBuffer) 
+        {
+            MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
+            piBuffer->Release();
+        }
+        // use the default material instead
+        if (g_piDefaultEffect)
+        {
+            pcMesh->piEffect = g_piDefaultEffect;
+            g_piDefaultEffect->AddRef();
+        }
+
+        // get the name of the material and use it in the log message
+        if(AI_SUCCESS == aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szPath) &&
+            '\0' != szPath.data[0])
+        {
+            std::string sz = "[ERROR] Unable to load material: ";
+            sz.append(szPath.data);
+            CLogDisplay::Instance().AddEntry(sz);
+        }
+        else
+        {
+            CLogDisplay::Instance().AddEntry("Unable to load material: UNNAMED");
+        }
+        return 0;
+    } else
+    {
+        // use Fixed Function effect when working with shaderless cards
+        if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+            pcMesh->piEffect->SetTechnique( "MaterialFX_FF");
+    }
+
+    if( piBuffer) piBuffer->Release();
+
+
+    // now commit all constants to the shader
+    //
+    // This is not necessary for shared shader. Shader constants for
+    // shared shaders are automatically recommited before the shader
+    // is being used for a particular mesh
+
+    if (1.0f != pcMesh->fOpacity)
+        pcMesh->piEffect->SetFloat("TRANSPARENCY",pcMesh->fOpacity);
+    if (pcMesh->eShadingMode  != aiShadingMode_Gouraud && !g_sOptions.bNoSpecular)
+    {
+        pcMesh->piEffect->SetFloat("SPECULARITY",pcMesh->fShininess);
+        pcMesh->piEffect->SetFloat("SPECULAR_STRENGTH",pcMesh->fSpecularStrength);
+    }
+
+    pcMesh->piEffect->SetVector("DIFFUSE_COLOR",&pcMesh->vDiffuseColor);
+    pcMesh->piEffect->SetVector("SPECULAR_COLOR",&pcMesh->vSpecularColor);
+    pcMesh->piEffect->SetVector("AMBIENT_COLOR",&pcMesh->vAmbientColor);
+    pcMesh->piEffect->SetVector("EMISSIVE_COLOR",&pcMesh->vEmissiveColor);
+
+    if (pcMesh->piDiffuseTexture)
+        pcMesh->piEffect->SetTexture("DIFFUSE_TEXTURE",pcMesh->piDiffuseTexture);
+    if (pcMesh->piOpacityTexture)
+        pcMesh->piEffect->SetTexture("OPACITY_TEXTURE",pcMesh->piOpacityTexture);
+    if (pcMesh->piSpecularTexture)
+        pcMesh->piEffect->SetTexture("SPECULAR_TEXTURE",pcMesh->piSpecularTexture);
+    if (pcMesh->piAmbientTexture)
+        pcMesh->piEffect->SetTexture("AMBIENT_TEXTURE",pcMesh->piAmbientTexture);
+    if (pcMesh->piEmissiveTexture)
+        pcMesh->piEffect->SetTexture("EMISSIVE_TEXTURE",pcMesh->piEmissiveTexture);
+    if (pcMesh->piNormalTexture)
+        pcMesh->piEffect->SetTexture("NORMAL_TEXTURE",pcMesh->piNormalTexture);
+    if (pcMesh->piShininessTexture)
+        pcMesh->piEffect->SetTexture("SHININESS_TEXTURE",pcMesh->piShininessTexture);
+    if (pcMesh->piLightmapTexture)
+        pcMesh->piEffect->SetTexture("LIGHTMAP_TEXTURE",pcMesh->piLightmapTexture);
+
+    if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode()){
+        pcMesh->piEffect->SetTexture("lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
+    }
+
+    return 1;
 }
 //-------------------------------------------------------------------------------
 int CMaterialManager::SetupMaterial (
-	AssetHelper::MeshHelper* pcMesh,
-	const aiMatrix4x4& pcProj,
-	const aiMatrix4x4& aiMe,
-	const aiMatrix4x4& pcCam,
-	const aiVector3D& vPos)
+    AssetHelper::MeshHelper* pcMesh,
+    const aiMatrix4x4& pcProj,
+    const aiMatrix4x4& aiMe,
+    const aiMatrix4x4& pcCam,
+    const aiVector3D& vPos)
 {
-	ai_assert(NULL != pcMesh);
-	if (!pcMesh->piEffect)return 0;
-
-	ID3DXEffect* piEnd = pcMesh->piEffect;
-
-	piEnd->SetMatrix("WorldViewProjection",
-		(const D3DXMATRIX*)&pcProj);
-
-	piEnd->SetMatrix("World",(const D3DXMATRIX*)&aiMe);
-	piEnd->SetMatrix("WorldInverseTranspose",
-		(const D3DXMATRIX*)&pcCam);
-
-	D3DXVECTOR4 apcVec[5];
-	memset(apcVec,0,sizeof(apcVec));
-	apcVec[0].x = g_avLightDirs[0].x;
-	apcVec[0].y = g_avLightDirs[0].y;
-	apcVec[0].z = g_avLightDirs[0].z;
-	apcVec[0].w = 0.0f;
-	apcVec[1].x = g_avLightDirs[0].x * -1.0f;
-	apcVec[1].y = g_avLightDirs[0].y * -1.0f;
-	apcVec[1].z = g_avLightDirs[0].z * -1.0f;
-	apcVec[1].w = 0.0f;
-	D3DXVec4Normalize(&apcVec[0],&apcVec[0]);
-	D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
-	piEnd->SetVectorArray("afLightDir",apcVec,5);
-
-	apcVec[0].x = ((g_avLightColors[0] >> 16)	& 0xFF) / 255.0f;
-	apcVec[0].y = ((g_avLightColors[0] >> 8)	& 0xFF) / 255.0f;
-	apcVec[0].z = ((g_avLightColors[0])			& 0xFF) / 255.0f;
-	apcVec[0].w = 1.0f;
-
-	if( g_sOptions.b3Lights)
-	{
-		apcVec[1].x = ((g_avLightColors[1] >> 16) & 0xFF) / 255.0f;
-		apcVec[1].y = ((g_avLightColors[1] >> 8) & 0xFF) / 255.0f;
-		apcVec[1].z = ((g_avLightColors[1]) & 0xFF) / 255.0f;
-		apcVec[1].w = 0.0f;
-	} else
-	{
-		apcVec[1].x = 0.0f;
-		apcVec[1].y = 0.0f;
-		apcVec[1].z = 0.0f;
-		apcVec[1].w = 0.0f;
-	}
-
-	apcVec[0] *= g_fLightIntensity;
-	apcVec[1] *= g_fLightIntensity;
-	piEnd->SetVectorArray("afLightColor",apcVec,5);
-
-	apcVec[0].x = ((g_avLightColors[2] >> 16)	& 0xFF) / 255.0f;
-	apcVec[0].y = ((g_avLightColors[2] >> 8)	& 0xFF) / 255.0f;
-	apcVec[0].z = ((g_avLightColors[2])			& 0xFF) / 255.0f;
-	apcVec[0].w = 1.0f;
-
-	apcVec[1].x = ((g_avLightColors[2] >> 16)	& 0xFF) / 255.0f;
-	apcVec[1].y = ((g_avLightColors[2] >> 8)	& 0xFF) / 255.0f;
-	apcVec[1].z = ((g_avLightColors[2])			& 0xFF) / 255.0f;
-	apcVec[1].w = 0.0f;
-
-	// FIX: light intensity doesn't apply to ambient color
-	//apcVec[0] *= g_fLightIntensity;
-	//apcVec[1] *= g_fLightIntensity;
-	piEnd->SetVectorArray("afLightColorAmbient",apcVec,5);
-
-
-	apcVec[0].x = vPos.x;
-	apcVec[0].y = vPos.y;
-	apcVec[0].z = vPos.z;
-	piEnd->SetVector( "vCameraPos",&apcVec[0]);
-
-	// if the effect instance is shared by multiple materials we need to
-	// recommit its whole state once per frame ...
-	if (pcMesh->bSharedFX)
-	{
-		// now commit all constants to the shader
-		if (1.0f != pcMesh->fOpacity)
-			pcMesh->piEffect->SetFloat("TRANSPARENCY",pcMesh->fOpacity);
-		if (pcMesh->eShadingMode  != aiShadingMode_Gouraud)
-		{
-			pcMesh->piEffect->SetFloat("SPECULARITY",pcMesh->fShininess);
-			pcMesh->piEffect->SetFloat("SPECULAR_STRENGTH",pcMesh->fSpecularStrength);
-		}
-
-		pcMesh->piEffect->SetVector("DIFFUSE_COLOR",&pcMesh->vDiffuseColor);
-		pcMesh->piEffect->SetVector("SPECULAR_COLOR",&pcMesh->vSpecularColor);
-		pcMesh->piEffect->SetVector("AMBIENT_COLOR",&pcMesh->vAmbientColor);
-		pcMesh->piEffect->SetVector("EMISSIVE_COLOR",&pcMesh->vEmissiveColor);
-
-		if (pcMesh->piOpacityTexture)
-			pcMesh->piEffect->SetTexture("OPACITY_TEXTURE",pcMesh->piOpacityTexture);
-		if (pcMesh->piDiffuseTexture)
-			pcMesh->piEffect->SetTexture("DIFFUSE_TEXTURE",pcMesh->piDiffuseTexture);
-		if (pcMesh->piSpecularTexture)
-			pcMesh->piEffect->SetTexture("SPECULAR_TEXTURE",pcMesh->piSpecularTexture);
-		if (pcMesh->piAmbientTexture)
-			pcMesh->piEffect->SetTexture("AMBIENT_TEXTURE",pcMesh->piAmbientTexture);
-		if (pcMesh->piEmissiveTexture)
-			pcMesh->piEffect->SetTexture("EMISSIVE_TEXTURE",pcMesh->piEmissiveTexture);
-		if (pcMesh->piNormalTexture)
-			pcMesh->piEffect->SetTexture("NORMAL_TEXTURE",pcMesh->piNormalTexture);
-		if (pcMesh->piShininessTexture)
-			pcMesh->piEffect->SetTexture("SHININESS_TEXTURE",pcMesh->piShininessTexture);
-		if (pcMesh->piLightmapTexture)
-			pcMesh->piEffect->SetTexture("LIGHTMAP_TEXTURE",pcMesh->piLightmapTexture);
-
-		if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode())
-		{
-			piEnd->SetTexture("lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
-		}
-	}
-
-	// disable culling, if necessary
-	if (pcMesh->twosided && g_sOptions.bCulling) {
-		g_piDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
-	}
-
-	// setup the correct shader technique to be used for drawing
-	if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
-	{
-		g_piDefaultEffect->SetTechnique( "MaterialFXSpecular_FF");
-	} else
-	if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || g_sOptions.bLowQuality)
-	{
-		if (g_sOptions.b3Lights)
-			piEnd->SetTechnique("MaterialFXSpecular_PS20_D2");
-		else piEnd->SetTechnique("MaterialFXSpecular_PS20_D1");
-	}
-	else
-	{
-		if (g_sOptions.b3Lights)
-			piEnd->SetTechnique("MaterialFXSpecular_D2");
-		else piEnd->SetTechnique("MaterialFXSpecular_D1");
-	}
-
-	// activate the effect
-	UINT dwPasses = 0;
-	piEnd->Begin(&dwPasses,0);
-	piEnd->BeginPass(0);
-	return 1;
+    ai_assert(NULL != pcMesh);
+    if (!pcMesh->piEffect)return 0;
+
+    ID3DXEffect* piEnd = pcMesh->piEffect;
+
+    piEnd->SetMatrix("WorldViewProjection",
+        (const D3DXMATRIX*)&pcProj);
+
+    piEnd->SetMatrix("World",(const D3DXMATRIX*)&aiMe);
+    piEnd->SetMatrix("WorldInverseTranspose",
+        (const D3DXMATRIX*)&pcCam);
+
+    D3DXVECTOR4 apcVec[5];
+    memset(apcVec,0,sizeof(apcVec));
+    apcVec[0].x = g_avLightDirs[0].x;
+    apcVec[0].y = g_avLightDirs[0].y;
+    apcVec[0].z = g_avLightDirs[0].z;
+    apcVec[0].w = 0.0f;
+    apcVec[1].x = g_avLightDirs[0].x * -1.0f;
+    apcVec[1].y = g_avLightDirs[0].y * -1.0f;
+    apcVec[1].z = g_avLightDirs[0].z * -1.0f;
+    apcVec[1].w = 0.0f;
+    D3DXVec4Normalize(&apcVec[0],&apcVec[0]);
+    D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
+    piEnd->SetVectorArray("afLightDir",apcVec,5);
+
+    apcVec[0].x = ((g_avLightColors[0] >> 16)	& 0xFF) / 255.0f;
+    apcVec[0].y = ((g_avLightColors[0] >> 8)	& 0xFF) / 255.0f;
+    apcVec[0].z = ((g_avLightColors[0])			& 0xFF) / 255.0f;
+    apcVec[0].w = 1.0f;
+
+    if( g_sOptions.b3Lights)
+    {
+        apcVec[1].x = ((g_avLightColors[1] >> 16) & 0xFF) / 255.0f;
+        apcVec[1].y = ((g_avLightColors[1] >> 8) & 0xFF) / 255.0f;
+        apcVec[1].z = ((g_avLightColors[1]) & 0xFF) / 255.0f;
+        apcVec[1].w = 0.0f;
+    } else
+    {
+        apcVec[1].x = 0.0f;
+        apcVec[1].y = 0.0f;
+        apcVec[1].z = 0.0f;
+        apcVec[1].w = 0.0f;
+    }
+
+    apcVec[0] *= g_fLightIntensity;
+    apcVec[1] *= g_fLightIntensity;
+    piEnd->SetVectorArray("afLightColor",apcVec,5);
+
+    apcVec[0].x = ((g_avLightColors[2] >> 16)	& 0xFF) / 255.0f;
+    apcVec[0].y = ((g_avLightColors[2] >> 8)	& 0xFF) / 255.0f;
+    apcVec[0].z = ((g_avLightColors[2])			& 0xFF) / 255.0f;
+    apcVec[0].w = 1.0f;
+
+    apcVec[1].x = ((g_avLightColors[2] >> 16)	& 0xFF) / 255.0f;
+    apcVec[1].y = ((g_avLightColors[2] >> 8)	& 0xFF) / 255.0f;
+    apcVec[1].z = ((g_avLightColors[2])			& 0xFF) / 255.0f;
+    apcVec[1].w = 0.0f;
+
+    // FIX: light intensity doesn't apply to ambient color
+    //apcVec[0] *= g_fLightIntensity;
+    //apcVec[1] *= g_fLightIntensity;
+    piEnd->SetVectorArray("afLightColorAmbient",apcVec,5);
+
+
+    apcVec[0].x = vPos.x;
+    apcVec[0].y = vPos.y;
+    apcVec[0].z = vPos.z;
+    piEnd->SetVector( "vCameraPos",&apcVec[0]);
+
+    // if the effect instance is shared by multiple materials we need to
+    // recommit its whole state once per frame ...
+    if (pcMesh->bSharedFX)
+    {
+        // now commit all constants to the shader
+        if (1.0f != pcMesh->fOpacity)
+            pcMesh->piEffect->SetFloat("TRANSPARENCY",pcMesh->fOpacity);
+        if (pcMesh->eShadingMode  != aiShadingMode_Gouraud)
+        {
+            pcMesh->piEffect->SetFloat("SPECULARITY",pcMesh->fShininess);
+            pcMesh->piEffect->SetFloat("SPECULAR_STRENGTH",pcMesh->fSpecularStrength);
+        }
+
+        pcMesh->piEffect->SetVector("DIFFUSE_COLOR",&pcMesh->vDiffuseColor);
+        pcMesh->piEffect->SetVector("SPECULAR_COLOR",&pcMesh->vSpecularColor);
+        pcMesh->piEffect->SetVector("AMBIENT_COLOR",&pcMesh->vAmbientColor);
+        pcMesh->piEffect->SetVector("EMISSIVE_COLOR",&pcMesh->vEmissiveColor);
+
+        if (pcMesh->piOpacityTexture)
+            pcMesh->piEffect->SetTexture("OPACITY_TEXTURE",pcMesh->piOpacityTexture);
+        if (pcMesh->piDiffuseTexture)
+            pcMesh->piEffect->SetTexture("DIFFUSE_TEXTURE",pcMesh->piDiffuseTexture);
+        if (pcMesh->piSpecularTexture)
+            pcMesh->piEffect->SetTexture("SPECULAR_TEXTURE",pcMesh->piSpecularTexture);
+        if (pcMesh->piAmbientTexture)
+            pcMesh->piEffect->SetTexture("AMBIENT_TEXTURE",pcMesh->piAmbientTexture);
+        if (pcMesh->piEmissiveTexture)
+            pcMesh->piEffect->SetTexture("EMISSIVE_TEXTURE",pcMesh->piEmissiveTexture);
+        if (pcMesh->piNormalTexture)
+            pcMesh->piEffect->SetTexture("NORMAL_TEXTURE",pcMesh->piNormalTexture);
+        if (pcMesh->piShininessTexture)
+            pcMesh->piEffect->SetTexture("SHININESS_TEXTURE",pcMesh->piShininessTexture);
+        if (pcMesh->piLightmapTexture)
+            pcMesh->piEffect->SetTexture("LIGHTMAP_TEXTURE",pcMesh->piLightmapTexture);
+
+        if (CBackgroundPainter::TEXTURE_CUBE == CBackgroundPainter::Instance().GetMode())
+        {
+            piEnd->SetTexture("lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
+        }
+    }
+
+    // disable culling, if necessary
+    if (pcMesh->twosided && g_sOptions.bCulling) {
+        g_piDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
+    }
+
+    // setup the correct shader technique to be used for drawing
+    if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+    {
+        g_piDefaultEffect->SetTechnique( "MaterialFXSpecular_FF");
+    } else
+    if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || g_sOptions.bLowQuality)
+    {
+        if (g_sOptions.b3Lights)
+            piEnd->SetTechnique("MaterialFXSpecular_PS20_D2");
+        else piEnd->SetTechnique("MaterialFXSpecular_PS20_D1");
+    }
+    else
+    {
+        if (g_sOptions.b3Lights)
+            piEnd->SetTechnique("MaterialFXSpecular_D2");
+        else piEnd->SetTechnique("MaterialFXSpecular_D1");
+    }
+
+    // activate the effect
+    UINT dwPasses = 0;
+    piEnd->Begin(&dwPasses,0);
+    piEnd->BeginPass(0);
+    return 1;
 }
 //-------------------------------------------------------------------------------
 int CMaterialManager::EndMaterial (AssetHelper::MeshHelper* pcMesh)
 {
-	ai_assert(NULL != pcMesh);
-	if (!pcMesh->piEffect)return 0;
+    ai_assert(NULL != pcMesh);
+    if (!pcMesh->piEffect)return 0;
 
-	// end the effect
-	pcMesh->piEffect->EndPass();
-	pcMesh->piEffect->End();
+    // end the effect
+    pcMesh->piEffect->EndPass();
+    pcMesh->piEffect->End();
 
-	// reenable culling if necessary
-	if (pcMesh->twosided && g_sOptions.bCulling) {
-		g_piDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
-	}		
+    // reenable culling if necessary
+    if (pcMesh->twosided && g_sOptions.bCulling) {
+        g_piDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
+    }		
 
-	return 1;
+    return 1;
 }
 }; // end namespace AssimpView

+ 165 - 159
tools/assimp_view/MaterialManager.h

@@ -39,164 +39,170 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#if (!defined AV_MATERIAL_H_INCLUDED)
-#define AV_MATERIAL_H_INCLUDE
+#pragma once
 
-//-------------------------------------------------------------------------------
-/* Helper class to create, access and destroy materials
-*/
-//-------------------------------------------------------------------------------
-class CMaterialManager
+#include <map>
+
+#include "AssetHelper.h"
+
+namespace AssimpView
 {
-private:
-
-	friend class CDisplay;
-
-	// default constructor
-	CMaterialManager() 
-		:	m_iShaderCount (0), sDefaultTexture() {}
-
-	~CMaterialManager() {
-		if (sDefaultTexture) {
-			sDefaultTexture->Release();
-		}
-		Reset();
-	}
-
-public:
-
-	//------------------------------------------------------------------
-	// Singleton accessors
-	static CMaterialManager s_cInstance;
-	inline static CMaterialManager& Instance ()
-		{
-		return s_cInstance;
-		}
-
-	//------------------------------------------------------------------
-	// Delete all resources of a given material
-	//
-	// Must be called before CreateMaterial() to prevent memory leaking
-	void DeleteMaterial(AssetHelper::MeshHelper* pcIn);
-	
-	//------------------------------------------------------------------
-	// Create the material for a mesh.
-	//
-	// The function checks whether an identical shader is already in use.
-	// A shader is considered to be identical if it has the same input 
-	// signature and takes the same number of texture channels.
-	int CreateMaterial(AssetHelper::MeshHelper* pcMesh,
-		const aiMesh* pcSource);
-
-	//------------------------------------------------------------------
-	// Setup the material for a given mesh
-	// pcMesh Mesh to be rendered
-	// pcProj Projection matrix
-	// aiMe Current world matrix
-	// pcCam Camera matrix
-	// vPos Position of the camera
-	// TODO: Extract camera position from matrix ...
-	//
-	int SetupMaterial (AssetHelper::MeshHelper* pcMesh,
-		const aiMatrix4x4& pcProj,
-		const aiMatrix4x4& aiMe,
-		const aiMatrix4x4& pcCam,
-		const aiVector3D& vPos);
-
-	//------------------------------------------------------------------
-	// End the material for a given mesh
-	// Called after mesh rendering is complete
-	// pcMesh Mesh object
-	int EndMaterial (AssetHelper::MeshHelper* pcMesh);
-
-	//------------------------------------------------------------------
-	// Recreate all specular materials depending on the current 
-	// specularity settings
-	//
-	// Diffuse-only materials are ignored.
-	// Must be called after specular highlights have been toggled
-	int UpdateSpecularMaterials();
-
-	//------------------------------------------------------------------
-	// find a valid path to a texture file
-	//
-	// Handle 8.3 syntax correctly, search the environment of the
-	// executable and the asset for a texture with a name very similar 
-	// to a given one
-	int FindValidPath(aiString* p_szString);
-
-	//------------------------------------------------------------------
-	// Load a texture into memory and create a native D3D texture resource
-	//
-	// The function tries to find a valid path for a texture
-	int LoadTexture(IDirect3DTexture9** p_ppiOut,aiString* szPath);
-
-
-	//------------------------------------------------------------------
-	// Getter for m_iShaderCount
-	//
-	inline unsigned int GetShaderCount()
-	{
-		return this->m_iShaderCount;
-	}
-
-	//------------------------------------------------------------------
-	// Reset the state of the class
-	// Called whenever a new asset is loaded
-	inline void Reset()
-	{
-		this->m_iShaderCount = 0;
-		for (TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it) {
-			(*it).second->Release();
-		}
-		sCachedTextures.clear();
-	}
-
-private:
-
-	//------------------------------------------------------------------
-	// find a valid path to a texture file
-	//
-	// Handle 8.3 syntax correctly, search the environment of the
-	// executable and the asset for a texture with a name very similar 
-	// to a given one
-	bool TryLongerPath(char* szTemp,aiString* p_szString);
-
-	//------------------------------------------------------------------
-	// Setup the default texture for a texture channel
-	//
-	// Generates a default checker pattern for a texture
-	int SetDefaultTexture(IDirect3DTexture9** p_ppiOut);
-
-	//------------------------------------------------------------------
-	// Convert a height map to a normal map if necessary
-	//
-	// The function tries to detect the type of a texture automatically.
-	// However, this wont work in every case.
-	void HMtoNMIfNecessary(IDirect3DTexture9* piTexture,
-		IDirect3DTexture9** piTextureOut,
-		bool bWasOriginallyHM = true);
-
-	//------------------------------------------------------------------
-	// Search for non-opaque pixels in a texture
-	//
-	// A pixel is considered to be non-opaque if its alpha value is
-	// less than 255
-	//------------------------------------------------------------------
-	bool HasAlphaPixels(IDirect3DTexture9* piTexture);
-
-private:
-
-	//
-	// Specifies the number of different shaders generated for
-	// the current asset. This number is incremented by CreateMaterial()
-	// each time a shader isn't found in cache and needs to be created
-	//
-	unsigned int m_iShaderCount;
-	IDirect3DTexture9* sDefaultTexture;
-
-	typedef std::map<std::string,IDirect3DTexture9*> TextureCache;
-	TextureCache sCachedTextures;
-};
-
-#endif //!! include guard
+
+    //-------------------------------------------------------------------------------
+    /* Helper class to create, access and destroy materials
+    */
+    //-------------------------------------------------------------------------------
+    class CMaterialManager
+    {
+    private:
+
+        friend class CDisplay;
+
+        // default constructor
+        CMaterialManager()
+            : m_iShaderCount( 0 ), sDefaultTexture() {}
+
+        ~CMaterialManager() {
+            if( sDefaultTexture ) {
+                sDefaultTexture->Release();
+            }
+            Reset();
+        }
+
+    public:
+
+        //------------------------------------------------------------------
+        // Singleton accessors
+        static CMaterialManager s_cInstance;
+        inline static CMaterialManager& Instance()
+        {
+            return s_cInstance;
+        }
+
+        //------------------------------------------------------------------
+        // Delete all resources of a given material
+        //
+        // Must be called before CreateMaterial() to prevent memory leaking
+        void DeleteMaterial( AssetHelper::MeshHelper* pcIn );
+
+        //------------------------------------------------------------------
+        // Create the material for a mesh.
+        //
+        // The function checks whether an identical shader is already in use.
+        // A shader is considered to be identical if it has the same input 
+        // signature and takes the same number of texture channels.
+        int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
+            const aiMesh* pcSource );
+
+        //------------------------------------------------------------------
+        // Setup the material for a given mesh
+        // pcMesh Mesh to be rendered
+        // pcProj Projection matrix
+        // aiMe Current world matrix
+        // pcCam Camera matrix
+        // vPos Position of the camera
+        // TODO: Extract camera position from matrix ...
+        //
+        int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
+            const aiMatrix4x4& pcProj,
+            const aiMatrix4x4& aiMe,
+            const aiMatrix4x4& pcCam,
+            const aiVector3D& vPos );
+
+        //------------------------------------------------------------------
+        // End the material for a given mesh
+        // Called after mesh rendering is complete
+        // pcMesh Mesh object
+        int EndMaterial( AssetHelper::MeshHelper* pcMesh );
+
+        //------------------------------------------------------------------
+        // Recreate all specular materials depending on the current 
+        // specularity settings
+        //
+        // Diffuse-only materials are ignored.
+        // Must be called after specular highlights have been toggled
+        int UpdateSpecularMaterials();
+
+        //------------------------------------------------------------------
+        // find a valid path to a texture file
+        //
+        // Handle 8.3 syntax correctly, search the environment of the
+        // executable and the asset for a texture with a name very similar 
+        // to a given one
+        int FindValidPath( aiString* p_szString );
+
+        //------------------------------------------------------------------
+        // Load a texture into memory and create a native D3D texture resource
+        //
+        // The function tries to find a valid path for a texture
+        int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
+
+
+        //------------------------------------------------------------------
+        // Getter for m_iShaderCount
+        //
+        inline unsigned int GetShaderCount()
+        {
+            return this->m_iShaderCount;
+        }
+
+        //------------------------------------------------------------------
+        // Reset the state of the class
+        // Called whenever a new asset is loaded
+        inline void Reset()
+        {
+            this->m_iShaderCount = 0;
+            for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) {
+                ( *it ).second->Release();
+            }
+            sCachedTextures.clear();
+        }
+
+    private:
+
+        //------------------------------------------------------------------
+        // find a valid path to a texture file
+        //
+        // Handle 8.3 syntax correctly, search the environment of the
+        // executable and the asset for a texture with a name very similar 
+        // to a given one
+        bool TryLongerPath( char* szTemp, aiString* p_szString );
+
+        //------------------------------------------------------------------
+        // Setup the default texture for a texture channel
+        //
+        // Generates a default checker pattern for a texture
+        int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
+
+        //------------------------------------------------------------------
+        // Convert a height map to a normal map if necessary
+        //
+        // The function tries to detect the type of a texture automatically.
+        // However, this wont work in every case.
+        void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
+            IDirect3DTexture9** piTextureOut,
+            bool bWasOriginallyHM = true );
+
+        //------------------------------------------------------------------
+        // Search for non-opaque pixels in a texture
+        //
+        // A pixel is considered to be non-opaque if its alpha value is
+        // less than 255
+        //------------------------------------------------------------------
+        bool HasAlphaPixels( IDirect3DTexture9* piTexture );
+
+    private:
+
+        //
+        // Specifies the number of different shaders generated for
+        // the current asset. This number is incremented by CreateMaterial()
+        // each time a shader isn't found in cache and needs to be created
+        //
+        unsigned int m_iShaderCount;
+        IDirect3DTexture9* sDefaultTexture;
+
+        typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
+        TextureCache sCachedTextures;
+    };
+
+}

+ 0 - 2
tools/assimp_view/MeshRenderer.cpp

@@ -39,7 +39,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
 #include <map>
@@ -47,7 +46,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace AssimpView {
 
-
 CMeshRenderer CMeshRenderer::s_cInstance;
 
 //-------------------------------------------------------------------------------

+ 40 - 38
tools/assimp_view/MeshRenderer.h

@@ -42,56 +42,58 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #if (!defined AV_MESH_RENDERER_H_INCLUDED)
 #define AV_MESH_RENDERER_H_INCLUDED
 
+namespace AssimpView {
 
 
-//-------------------------------------------------------------------------------
-/* Helper class tp render meshes
-*/
-//-------------------------------------------------------------------------------
-class CMeshRenderer
-{
-private:
+    //-------------------------------------------------------------------------------
+    /* Helper class tp render meshes
+    */
+    //-------------------------------------------------------------------------------
+    class CMeshRenderer
+    {
+    private:
+
+        // default constructor
+        CMeshRenderer()
 
-	// default constructor
-	CMeshRenderer() 
+        {
+            // no other members to initialize
+        }
 
-	{
-		// no other members to initialize
-	}
+    public:
 
-public:
+        //------------------------------------------------------------------
+        // Singleton accessors
+        static CMeshRenderer s_cInstance;
+        inline static CMeshRenderer& Instance()
+        {
+            return s_cInstance;
+        }
 
-	//------------------------------------------------------------------
-	// Singleton accessors
-	static CMeshRenderer s_cInstance;
-	inline static CMeshRenderer& Instance ()
-	{
-		return s_cInstance;
-	}
 
+        //------------------------------------------------------------------
+        // Draw a mesh in the global mesh list using the current pipeline state
+        // iIndex Index of the mesh to be drawn
+        //
+        // The function draws all faces in order, regardless of their distance
+        int DrawUnsorted( unsigned int iIndex );
 
-	//------------------------------------------------------------------
-	// Draw a mesh in the global mesh list using the current pipeline state
-	// iIndex Index of the mesh to be drawn
-	//
-	// The function draws all faces in order, regardless of their distance
-	int DrawUnsorted(unsigned int iIndex);
+        //------------------------------------------------------------------
+        // Draw a mesh in the global mesh list using the current pipeline state
+        // iIndex Index of the mesh to be drawn
+        //
+        // The method sorts all vertices by their distance (back to front)
+        //
+        // mWorld World matrix for the node
+        int DrawSorted( unsigned int iIndex,
+            const aiMatrix4x4& mWorld );
 
-	//------------------------------------------------------------------
-	// Draw a mesh in the global mesh list using the current pipeline state
-	// iIndex Index of the mesh to be drawn
-	//
-	// The method sorts all vertices by their distance (back to front)
-	//
-	// mWorld World matrix for the node
-	int DrawSorted(unsigned int iIndex,
-		const aiMatrix4x4& mWorld);
 
 
+    private:
 
-private:
 
-	
-};
+    };
 
+}
 #endif //!! include guard

+ 7 - 3
tools/assimp_view/MessageProc.cpp

@@ -39,12 +39,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
 
-#include "stdafx.h"
 #include "assimp_view.h"
+#include <assimp/Exporter.hpp>
+#include <algorithm>
+
 #include <windowsx.h>
 
 namespace AssimpView {
 
+using namespace Assimp;
+
 // Static array to keep custom color values
 COLORREF g_aclCustomColors[16] = {0};
 
@@ -1044,9 +1048,9 @@ void DoExport(size_t formatId)
 		ai_assert(strlen(szFileName) <= MAX_PATH);
 
 		// invent a nice default file name 
-		char* sz = std::max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
+		char* sz = max(strrchr(szFileName,'\\'),strrchr(szFileName,'/'));
 		if (sz) {
-			strncpy(sz,std::max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
+			strncpy(sz,max(strrchr(g_szFileName,'\\'),strrchr(g_szFileName,'/')),MAX_PATH);
 		}
 	}
 	else {

+ 1 - 1
tools/assimp_view/Normals.cpp

@@ -40,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
 // note: these are no longer part of the public API, but they are 
@@ -53,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 namespace AssimpView {
 
+using namespace Assimp;
 
 bool g_bWasFlipped = false;
 float g_smoothAngle = 80.f;

+ 0 - 1
tools/assimp_view/SceneAnimator.cpp

@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *  @brief Implementation of the utility class SceneAnimator
  */
 
-#include "stdafx.h"
 #include "assimp_view.h"
 
 using namespace AssimpView;

+ 1295 - 1299
tools/assimp_view/Shaders.cpp

@@ -38,1377 +38,1373 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 */
-
-#include "stdafx.h"
 #include "assimp_view.h"
 
-
-namespace AssimpView 
-{
+namespace AssimpView  {
 
 // ------------------------------------------------------------------------------------------------
 std::string g_szNormalsShader = std::string(
 
-	// World * View * Projection matrix\n"
-	// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
-	"float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
-	"float4 OUTPUT_COLOR;\n"
-	
-	// Vertex shader input structure
-	"struct VS_INPUT\n"
-	"{\n"
-		"// Position\n"
-		"float3 Position : POSITION;\n"
-	"};\n"
-
-	// Vertex shader output structure for pixel shader usage
-	"struct VS_OUTPUT\n"
+    // World * View * Projection matrix\n"
+    // NOTE: Assume that the material uses a WorldViewProjection matrix\n"
+    "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
+    "float4 OUTPUT_COLOR;\n"
+    
+    // Vertex shader input structure
+    "struct VS_INPUT\n"
+    "{\n"
+        "// Position\n"
+        "float3 Position : POSITION;\n"
+    "};\n"
+
+    // Vertex shader output structure for pixel shader usage
+    "struct VS_OUTPUT\n"
   "{\n"
-		"float4 Position : POSITION;\n"
-	"};\n"
+        "float4 Position : POSITION;\n"
+    "};\n"
 
-	// Vertex shader output structure for FixedFunction usage
-	"struct VS_OUTPUT_FF\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
+    // Vertex shader output structure for FixedFunction usage
+    "struct VS_OUTPUT_FF\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
     "float4 Color : COLOR;\n"
-	"};\n"
+    "};\n"
 
-	// Vertex shader for rendering normals using pixel shader
-	"VS_OUTPUT RenderNormalsVS(VS_INPUT IN)\n"
-	"{\n"
-		"// Initialize the output structure with zero\n"
-		"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
+    // Vertex shader for rendering normals using pixel shader
+    "VS_OUTPUT RenderNormalsVS(VS_INPUT IN)\n"
+    "{\n"
+        "// Initialize the output structure with zero\n"
+        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"
 
-		"// Multiply with the WorldViewProjection matrix\n"
-		"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
+        "// Multiply with the WorldViewProjection matrix\n"
+        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
 
-		"return Out;\n"
-	"}\n"
+        "return Out;\n"
+    "}\n"
 
-	// Vertex shader for rendering normals using fixed function pipeline
-	"VS_OUTPUT_FF RenderNormalsVS_FF(VS_INPUT IN)\n"
+    // Vertex shader for rendering normals using fixed function pipeline
+    "VS_OUTPUT_FF RenderNormalsVS_FF(VS_INPUT IN)\n"
   "{\n"
-		"VS_OUTPUT_FF Out;\n"
-		"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
+        "VS_OUTPUT_FF Out;\n"
+        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
     "Out.Color = OUTPUT_COLOR;\n"
-		"return Out;\n"
-	"}\n"
-
-	// Pixel shader
-	"float4 RenderNormalsPS() : COLOR\n"
-	"{\n"
-		"return OUTPUT_COLOR;\n"
-	"}\n"
-
-	// Technique for the normal rendering effect (ps_2_0)
-	"technique RenderNormals\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-		"CullMode=none;\n"
-		"PixelShader = compile ps_2_0 RenderNormalsPS();\n"
-		"VertexShader = compile vs_2_0 RenderNormalsVS();\n"
-		"}\n"
-	"};\n"
-
-	// Technique for the normal rendering effect (fixed function)
-	"technique RenderNormals_FF\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-		  "CullMode=none;\n"
-		  "VertexShader = compile vs_2_0 RenderNormalsVS_FF();\n"
+        "return Out;\n"
+    "}\n"
+
+    // Pixel shader
+    "float4 RenderNormalsPS() : COLOR\n"
+    "{\n"
+        "return OUTPUT_COLOR;\n"
+    "}\n"
+
+    // Technique for the normal rendering effect (ps_2_0)
+    "technique RenderNormals\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+        "CullMode=none;\n"
+        "PixelShader = compile ps_2_0 RenderNormalsPS();\n"
+        "VertexShader = compile vs_2_0 RenderNormalsVS();\n"
+        "}\n"
+    "};\n"
+
+    // Technique for the normal rendering effect (fixed function)
+    "technique RenderNormals_FF\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+          "CullMode=none;\n"
+          "VertexShader = compile vs_2_0 RenderNormalsVS_FF();\n"
       "ColorOp[0] = SelectArg1;\n"
       "ColorArg0[0] = Diffuse;\n"
       "AlphaOp[0] = SelectArg1;\n"
       "AlphaArg0[0] = Diffuse;\n"
-		"}\n"
-	"};\n"
-	);
+        "}\n"
+    "};\n"
+    );
 
 // ------------------------------------------------------------------------------------------------
 std::string g_szSkyboxShader = std::string(
 
-	// Sampler and texture for the skybox
-	"textureCUBE lw_tex_envmap;\n"
-	"samplerCUBE EnvironmentMapSampler = sampler_state\n"
-	"{\n"
-	  "Texture = (lw_tex_envmap);\n"
-	  "AddressU = CLAMP;\n"
-	  "AddressV = CLAMP;\n"
-	  "AddressW = CLAMP;\n"
-
-	  "MAGFILTER = linear;\n"
-	  "MINFILTER = linear;\n"
-	"};\n"
-
-	// World * View * Projection matrix\n"
-	// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
-	"float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
-	
-	// Vertex shader input structure
-	"struct VS_INPUT\n"
-	"{\n"
-		"float3 Position : POSITION;\n"
-		"float3 Texture0 : TEXCOORD0;\n"
-	"};\n"
-
-	// Vertex shader output structure
-	"struct VS_OUTPUT\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float3 Texture0 : TEXCOORD0;\n"
-	"};\n"
-
-	// Vertex shader
-	"VS_OUTPUT RenderSkyBoxVS(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT Out;\n"
-
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
-
-		// Set z to w to ensure z becomes 1.0 after the division through w occurs
-		"Out.Position.z = Out.Position.w;\n"
-	
-		// Simply pass through texture coordinates
-		"Out.Texture0 = IN.Texture0;\n"
-
-		"return Out;\n"
-	"}\n"
-
-	// Pixel shader
-	"float4 RenderSkyBoxPS(float3 Texture0 : TEXCOORD0) : COLOR\n"
-	"{\n"
-		// Lookup the skybox texture
-		"return texCUBE(EnvironmentMapSampler,Texture0) ;\n"
-	"}\n"
-
-	// Technique for the skybox shader (ps_2_0)
-	"technique RenderSkyBox\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-		  "ZWriteEnable = FALSE;\n"
-		  "FogEnable = FALSE;\n"
-		  "CullMode = NONE;\n"
-
-		  "PixelShader = compile ps_2_0 RenderSkyBoxPS();\n"
-		  "VertexShader = compile vs_2_0 RenderSkyBoxVS();\n"
-		"}\n"
-	"};\n"
+    // Sampler and texture for the skybox
+    "textureCUBE lw_tex_envmap;\n"
+    "samplerCUBE EnvironmentMapSampler = sampler_state\n"
+    "{\n"
+      "Texture = (lw_tex_envmap);\n"
+      "AddressU = CLAMP;\n"
+      "AddressV = CLAMP;\n"
+      "AddressW = CLAMP;\n"
+
+      "MAGFILTER = linear;\n"
+      "MINFILTER = linear;\n"
+    "};\n"
+
+    // World * View * Projection matrix\n"
+    // NOTE: Assume that the material uses a WorldViewProjection matrix\n"
+    "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
+    
+    // Vertex shader input structure
+    "struct VS_INPUT\n"
+    "{\n"
+        "float3 Position : POSITION;\n"
+        "float3 Texture0 : TEXCOORD0;\n"
+    "};\n"
+
+    // Vertex shader output structure
+    "struct VS_OUTPUT\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float3 Texture0 : TEXCOORD0;\n"
+    "};\n"
+
+    // Vertex shader
+    "VS_OUTPUT RenderSkyBoxVS(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT Out;\n"
+
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
+
+        // Set z to w to ensure z becomes 1.0 after the division through w occurs
+        "Out.Position.z = Out.Position.w;\n"
+    
+        // Simply pass through texture coordinates
+        "Out.Texture0 = IN.Texture0;\n"
+
+        "return Out;\n"
+    "}\n"
+
+    // Pixel shader
+    "float4 RenderSkyBoxPS(float3 Texture0 : TEXCOORD0) : COLOR\n"
+    "{\n"
+        // Lookup the skybox texture
+        "return texCUBE(EnvironmentMapSampler,Texture0) ;\n"
+    "}\n"
+
+    // Technique for the skybox shader (ps_2_0)
+    "technique RenderSkyBox\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+          "ZWriteEnable = FALSE;\n"
+          "FogEnable = FALSE;\n"
+          "CullMode = NONE;\n"
+
+          "PixelShader = compile ps_2_0 RenderSkyBoxPS();\n"
+          "VertexShader = compile vs_2_0 RenderSkyBoxVS();\n"
+        "}\n"
+    "};\n"
 
   // -------------- same for static background image -----------------
-	"texture TEXTURE_2D;\n"
-	"sampler TEXTURE_SAMPLER = sampler_state\n"
-	"{\n"
-		"Texture = (TEXTURE_2D);\n"
-	"};\n"
-
-	"struct VS_OUTPUT2\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float2 TexCoord0 : TEXCOORD0;\n"
-	"};\n"
-
-	"VS_OUTPUT2 RenderImageVS(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
-	"{\n"
-		"VS_OUTPUT2 Out;\n"
-
-		"Out.Position.xy = INPosition.xy;\n"
-		"Out.Position.z = Out.Position.w = 1.0f;\n"
-		"Out.TexCoord0 = INTexCoord0;\n"
-
-		"return Out;\n"
-	"}\n"
-
-	"float4 RenderImagePS(float2 IN : TEXCOORD0) : COLOR\n"
-	"{\n"
-		"return tex2D(TEXTURE_SAMPLER,IN);\n"
-	"}\n"
-
-	// Technique for the background image shader (ps_2_0)
-	"technique RenderImage2D\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"ZWriteEnable = FALSE;\n"
-			"FogEnable = FALSE;\n"
-			"CullMode = NONE;\n"
-	
-			"PixelShader = compile ps_2_0 RenderImagePS();\n"
-			"VertexShader = compile vs_2_0 RenderImageVS();\n"
-		"}\n"
-	"};\n"
-	);
+    "texture TEXTURE_2D;\n"
+    "sampler TEXTURE_SAMPLER = sampler_state\n"
+    "{\n"
+        "Texture = (TEXTURE_2D);\n"
+    "};\n"
+
+    "struct VS_OUTPUT2\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float2 TexCoord0 : TEXCOORD0;\n"
+    "};\n"
+
+    "VS_OUTPUT2 RenderImageVS(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
+    "{\n"
+        "VS_OUTPUT2 Out;\n"
+
+        "Out.Position.xy = INPosition.xy;\n"
+        "Out.Position.z = Out.Position.w = 1.0f;\n"
+        "Out.TexCoord0 = INTexCoord0;\n"
+
+        "return Out;\n"
+    "}\n"
+
+    "float4 RenderImagePS(float2 IN : TEXCOORD0) : COLOR\n"
+    "{\n"
+        "return tex2D(TEXTURE_SAMPLER,IN);\n"
+    "}\n"
+
+    // Technique for the background image shader (ps_2_0)
+    "technique RenderImage2D\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "ZWriteEnable = FALSE;\n"
+            "FogEnable = FALSE;\n"
+            "CullMode = NONE;\n"
+    
+            "PixelShader = compile ps_2_0 RenderImagePS();\n"
+            "VertexShader = compile vs_2_0 RenderImageVS();\n"
+        "}\n"
+    "};\n"
+    );
 
 std::string g_szDefaultShader = std::string(
 
-	// World * View * Projection matrix
-	// NOTE: Assume that the material uses a WorldViewProjection matrix
-	"float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
-	"float4x4 World					: WORLD;\n"
-	"float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"
+    // World * View * Projection matrix
+    // NOTE: Assume that the material uses a WorldViewProjection matrix
+    "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
+    "float4x4 World					: WORLD;\n"
+    "float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"
 
-	// light colors
-	"float3 afLightColor[5];\n"
-	// light direction
-	"float3 afLightDir[5];\n"
+    // light colors
+    "float3 afLightColor[5];\n"
+    // light direction
+    "float3 afLightDir[5];\n"
 
-	// position of the camera in worldspace\n"
-	"float3 vCameraPos : CAMERAPOSITION;\n"
+    // position of the camera in worldspace\n"
+    "float3 vCameraPos : CAMERAPOSITION;\n"
 
-	// Bone matrices
+    // Bone matrices
 //	"#ifdef AV_SKINNING \n"
-	"float4x3 gBoneMatrix[60]; \n"
+    "float4x3 gBoneMatrix[60]; \n"
 //	"#endif // AV_SKINNING \n"
 
-	// Vertex shader input structure
-	"struct VS_INPUT\n"
-	"{\n"
-		"float3 Position : POSITION;\n"
-		"float3 Normal : NORMAL;\n"
+    // Vertex shader input structure
+    "struct VS_INPUT\n"
+    "{\n"
+        "float3 Position : POSITION;\n"
+        "float3 Normal : NORMAL;\n"
 //		"#ifdef AV_SKINNING \n"
-			"float4 BlendIndices : BLENDINDICES;\n"
-			"float4 BlendWeights : BLENDWEIGHT;\n"
+            "float4 BlendIndices : BLENDINDICES;\n"
+            "float4 BlendWeights : BLENDWEIGHT;\n"
 //		"#endif // AV_SKINNING \n"
-	"};\n"
-
-	// Vertex shader output structure for pixel shader usage
-	"struct VS_OUTPUT\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float3 ViewDir : TEXCOORD0;\n"
-		"float3 Normal : TEXCOORD1;\n"
-	"};\n"
-
-	// Vertex shader output structure for fixed function
-	"struct VS_OUTPUT_FF\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float4 Color : COLOR;\n"
-	"};\n"
-
-	// Vertex shader for pixel shader usage
-	"VS_OUTPUT DefaultVShader(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT Out;\n"
+    "};\n"
+
+    // Vertex shader output structure for pixel shader usage
+    "struct VS_OUTPUT\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float3 ViewDir : TEXCOORD0;\n"
+        "float3 Normal : TEXCOORD1;\n"
+    "};\n"
+
+    // Vertex shader output structure for fixed function
+    "struct VS_OUTPUT_FF\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float4 Color : COLOR;\n"
+    "};\n"
+
+    // Vertex shader for pixel shader usage
+    "VS_OUTPUT DefaultVShader(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT Out;\n"
 
 //		"#ifdef AV_SKINNING \n"
-		"float4 weights = IN.BlendWeights; \n"
-		"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
-		"float4 localPos = float4( IN.Position, 1.0f); \n"
-		"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
+        "float4 weights = IN.BlendWeights; \n"
+        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
+        "float4 localPos = float4( IN.Position, 1.0f); \n"
+        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
 //		"#else \n"
 //		"float3 objPos = IN.Position; \n"
 //		"#endif // AV_SKINNING \n"
 
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
-		"float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
-		"Out.ViewDir = vCameraPos - WorldPos;\n"
-		"Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
+        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
+        "Out.ViewDir = vCameraPos - WorldPos;\n"
+        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
 
-		"return Out;\n"
-	"}\n"
+        "return Out;\n"
+    "}\n"
 
-	// Vertex shader for fixed function pipeline
-	"VS_OUTPUT_FF DefaultVShader_FF(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT_FF Out;\n"
+    // Vertex shader for fixed function pipeline
+    "VS_OUTPUT_FF DefaultVShader_FF(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT_FF Out;\n"
 
 //		"#ifdef AV_SKINNING \n"
-		"float4 weights = IN.BlendWeights; \n"
-		"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
-		"float4 localPos = float4( IN.Position, 1.0f); \n"
-		"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
+        "float4 weights = IN.BlendWeights; \n"
+        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
+        "float4 localPos = float4( IN.Position, 1.0f); \n"
+        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
 //		"#else \n"
 //		"float3 objPos = IN.Position; \n"
 //		"#endif // AV_SKINNING \n"
 
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
-
-		"float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"
-
-		// per-vertex lighting. We simply assume light colors of unused lights to be black
-		"Out.Color = float4( 0.2f, 0.2f, 0.2f, 1.0f); \n"
-		"for( int a = 0; a < 2; a++)\n"
-		"  Out.Color.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
-			"return Out;\n"
-	"}\n"
-
-	// Pixel shader for one light
-	"float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"float3 Normal = normalize(IN.Normal);\n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-			"float3 Reflect = reflect (Normal,afLightDir[0]);\n"
-			"float fHalfLambert = L1*L1;\n"
-			"OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
-				"saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,ViewDir),9));\n"
-		"}\n"
-		"return OUT;\n"
-	"}\n"
-
-	// Pixel shader for two lights
-	"float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"float3 Normal = normalize(IN.Normal);\n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-			"float3 Reflect = reflect (ViewDir,Normal);\n"
-			"float fHalfLambert = L1*L1;\n"
-			"OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
-			"saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[0]),9));\n"
-		"}\n"
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
-			"float3 Reflect = reflect (ViewDir,Normal);\n"
-			"float fHalfLambert = L1*L1;\n"
-			"OUT.rgb += afLightColor[1] * (fHalfLambert +\n"
-			"saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[1]),9));\n"
-		"}\n"
-		"return OUT;\n"
-	"}\n"
-	// ----------------------------------------------------------------------------
-	"float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"float3 Normal = normalize(IN.Normal);\n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[0]);\n"
-			"float3 Reflect = reflect (Normal,afLightDir[0]);\n"
-			"OUT.rgb += afLightColor[0] * ((L1) +\n"
-			"pow(dot(Reflect,ViewDir),9));\n"
-		"}\n"
-
-		"return OUT;\n"
-	"}\n"
-	// ----------------------------------------------------------------------------
-	"float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"float3 Normal = normalize(IN.Normal);\n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[0]);\n"
-			"float3 Reflect = reflect (Normal,afLightDir[0]);\n"
-			"OUT.rgb += afLightColor[0] * ((L1) +\n"
-			"pow(dot(Reflect,ViewDir),9));\n"
-		"}\n"
-		"{\n"
-			"float L1 = dot(Normal,afLightDir[1]);\n"
-			"float3 Reflect = reflect (Normal,afLightDir[1]);\n"
-			"OUT.rgb += afLightColor[1] * ((L1) +\n"
-			"pow(dot(Reflect,ViewDir),9));\n"
-		"}\n"
-		"return OUT;\n"
-	"}\n"
-
-
-	// Technique for the default effect
-	"technique DefaultFXSpecular_D1\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"CullMode=none;\n"
-			"PixelShader = compile ps_3_0 DefaultPShaderSpecular_D1();\n"
-			"VertexShader = compile vs_3_0 DefaultVShader();\n"
-		"}\n"
-	"};\n"
-	"technique DefaultFXSpecular_D2\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"CullMode=none;\n"
-			"PixelShader = compile ps_3_0 DefaultPShaderSpecular_D2();\n"
-			"VertexShader = compile vs_3_0 DefaultVShader();\n"
-		"}\n"
-	"};\n"
-
-	// Technique for the default effect (ps_2_0)
-	"technique DefaultFXSpecular_PS20_D1\n"
-	"{\n"
-		"pass p0\n"
-  	"{\n"
-		  "CullMode=none;\n"
-		  "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D1();\n"
-		  "VertexShader = compile vs_2_0 DefaultVShader();\n"
-		"}\n"
-	"};\n"
-	"technique DefaultFXSpecular_PS20_D2\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-		  "CullMode=none;\n"
-		  "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D2();\n"
-		  "VertexShader = compile vs_2_0 DefaultVShader();\n"
-		"}\n"
-	"};\n"
-
-	// Technique for the default effect using the fixed function pixel pipeline
-	"technique DefaultFXSpecular_FF\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"CullMode=none;\n"
-			"VertexShader = compile vs_2_0 DefaultVShader_FF();\n"
-			"ColorOp[0] = SelectArg1;\n"
-			"ColorArg0[0] = Diffuse;\n"
-			"AlphaOp[0] = SelectArg1;\n"
-			"AlphaArg0[0] = Diffuse;\n"
-		"}\n"
-	"};\n"
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
+
+        "float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"
+
+        // per-vertex lighting. We simply assume light colors of unused lights to be black
+        "Out.Color = float4( 0.2f, 0.2f, 0.2f, 1.0f); \n"
+        "for( int a = 0; a < 2; a++)\n"
+        "  Out.Color.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
+            "return Out;\n"
+    "}\n"
+
+    // Pixel shader for one light
+    "float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "float3 Normal = normalize(IN.Normal);\n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+            "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
+            "float fHalfLambert = L1*L1;\n"
+            "OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
+                "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,ViewDir),9));\n"
+        "}\n"
+        "return OUT;\n"
+    "}\n"
+
+    // Pixel shader for two lights
+    "float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "float3 Normal = normalize(IN.Normal);\n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+            "float3 Reflect = reflect (ViewDir,Normal);\n"
+            "float fHalfLambert = L1*L1;\n"
+            "OUT.rgb += afLightColor[0] * (fHalfLambert +\n"
+            "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[0]),9));\n"
+        "}\n"
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
+            "float3 Reflect = reflect (ViewDir,Normal);\n"
+            "float fHalfLambert = L1*L1;\n"
+            "OUT.rgb += afLightColor[1] * (fHalfLambert +\n"
+            "saturate(fHalfLambert * 4.0f) * pow(dot(Reflect,afLightDir[1]),9));\n"
+        "}\n"
+        "return OUT;\n"
+    "}\n"
+    // ----------------------------------------------------------------------------
+    "float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "float3 Normal = normalize(IN.Normal);\n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[0]);\n"
+            "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
+            "OUT.rgb += afLightColor[0] * ((L1) +\n"
+            "pow(dot(Reflect,ViewDir),9));\n"
+        "}\n"
+
+        "return OUT;\n"
+    "}\n"
+    // ----------------------------------------------------------------------------
+    "float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "float3 Normal = normalize(IN.Normal);\n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[0]);\n"
+            "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
+            "OUT.rgb += afLightColor[0] * ((L1) +\n"
+            "pow(dot(Reflect,ViewDir),9));\n"
+        "}\n"
+        "{\n"
+            "float L1 = dot(Normal,afLightDir[1]);\n"
+            "float3 Reflect = reflect (Normal,afLightDir[1]);\n"
+            "OUT.rgb += afLightColor[1] * ((L1) +\n"
+            "pow(dot(Reflect,ViewDir),9));\n"
+        "}\n"
+        "return OUT;\n"
+    "}\n"
+
+
+    // Technique for the default effect
+    "technique DefaultFXSpecular_D1\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "CullMode=none;\n"
+            "PixelShader = compile ps_3_0 DefaultPShaderSpecular_D1();\n"
+            "VertexShader = compile vs_3_0 DefaultVShader();\n"
+        "}\n"
+    "};\n"
+    "technique DefaultFXSpecular_D2\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "CullMode=none;\n"
+            "PixelShader = compile ps_3_0 DefaultPShaderSpecular_D2();\n"
+            "VertexShader = compile vs_3_0 DefaultVShader();\n"
+        "}\n"
+    "};\n"
+
+    // Technique for the default effect (ps_2_0)
+    "technique DefaultFXSpecular_PS20_D1\n"
+    "{\n"
+        "pass p0\n"
+    "{\n"
+          "CullMode=none;\n"
+          "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D1();\n"
+          "VertexShader = compile vs_2_0 DefaultVShader();\n"
+        "}\n"
+    "};\n"
+    "technique DefaultFXSpecular_PS20_D2\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+          "CullMode=none;\n"
+          "PixelShader = compile ps_2_0 DefaultPShaderSpecular_PS20_D2();\n"
+          "VertexShader = compile vs_2_0 DefaultVShader();\n"
+        "}\n"
+    "};\n"
+
+    // Technique for the default effect using the fixed function pixel pipeline
+    "technique DefaultFXSpecular_FF\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "CullMode=none;\n"
+            "VertexShader = compile vs_2_0 DefaultVShader_FF();\n"
+            "ColorOp[0] = SelectArg1;\n"
+            "ColorArg0[0] = Diffuse;\n"
+            "AlphaOp[0] = SelectArg1;\n"
+            "AlphaArg0[0] = Diffuse;\n"
+        "}\n"
+    "};\n"
   );
 
 
 std::string g_szMaterialShader = std::string(
 
-	// World * View * Projection matrix
+    // World * View * Projection matrix
   // NOTE: Assume that the material uses a WorldViewProjection matrix
-	"float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
-	"float4x4 World					: WORLD;\n"
-	"float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"
-
-	"#ifndef AV_DISABLESSS\n"
-	"float4x3 ViewProj;\n"
-	"float4x3 InvViewProj;\n"
-	"#endif\n"
-
-	"float4 DIFFUSE_COLOR;\n"
-	"float4 SPECULAR_COLOR;\n"
-	"float4 AMBIENT_COLOR;\n"
-	"float4 EMISSIVE_COLOR;\n"
-
-	"#ifdef AV_SPECULAR_COMPONENT\n"
-	"float SPECULARITY;\n"
-	"float SPECULAR_STRENGTH;\n"
-	"#endif\n"
-	"#ifdef AV_OPACITY\n"
-	"float TRANSPARENCY;\n"
-	"#endif\n"
-
-	// light colors (diffuse and specular)
-	"float4 afLightColor[5];\n"
-	"float4 afLightColorAmbient[5];\n"
-
-	// light direction
-	"float3 afLightDir[5];\n"
-
-	// position of the camera in worldspace
-	"float3 vCameraPos : CAMERAPOSITION;\n"
-
-	// Bone matrices
-	"#ifdef AV_SKINNING \n"
-	"float4x3 gBoneMatrix[60]; \n"
-	"#endif // AV_SKINNING \n"
-
-	"#ifdef AV_DIFFUSE_TEXTURE\n"
-		"texture DIFFUSE_TEXTURE;\n"
-		"sampler DIFFUSE_SAMPLER\n"
-		"{\n"
-		  "Texture = <DIFFUSE_TEXTURE>;\n"
-		  "#ifdef AV_WRAPU\n"
-		  "AddressU = WRAP;\n"
-		  "#endif\n"
-		  "#ifdef AV_MIRRORU\n"
-		  "AddressU = MIRROR;\n"
-		  "#endif\n"
-		  "#ifdef AV_CLAMPU\n"
-		  "AddressU = CLAMP;\n"
-		  "#endif\n"
-		  "#ifdef AV_WRAPV\n"
-		  "AddressV = WRAP;\n"
-		  "#endif\n"
-		  "#ifdef AV_MIRRORV\n"
-		  "AddressV = MIRROR;\n"
-		  "#endif\n"
-		  "#ifdef AV_CLAMPV\n"
-		  "AddressV = CLAMP;\n"
-		  "#endif\n"
-		"};\n"
-	"#endif // AV_DIFFUSE_TEXTUR\n"
-
-	"#ifdef AV_DIFFUSE_TEXTURE2\n"
-		"texture DIFFUSE_TEXTURE2;\n"
-		"sampler DIFFUSE_SAMPLER2\n"
-		"{\n"
-		  "Texture = <DIFFUSE_TEXTURE2>;\n"
-		"};\n"
-	"#endif // AV_DIFFUSE_TEXTUR2\n"
-
-	"#ifdef AV_SPECULAR_TEXTURE\n"
-		"texture SPECULAR_TEXTURE;\n"
-		"sampler SPECULAR_SAMPLER\n"
-		"{\n"
-		  "Texture = <SPECULAR_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_SPECULAR_TEXTUR\n"
-
-	"#ifdef AV_AMBIENT_TEXTURE\n"
-		"texture AMBIENT_TEXTURE;\n"
-		"sampler AMBIENT_SAMPLER\n"
-		"{\n"
-		  "Texture = <AMBIENT_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_AMBIENT_TEXTUR\n"
-
-	"#ifdef AV_LIGHTMAP_TEXTURE\n"
-		"texture LIGHTMAP_TEXTURE;\n"
-		"sampler LIGHTMAP_SAMPLER\n"
-		"{\n"
-		  "Texture = <LIGHTMAP_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_LIGHTMAP_TEXTURE\n"
-
-	"#ifdef AV_OPACITY_TEXTURE\n"
-		"texture OPACITY_TEXTURE;\n"
-		"sampler OPACITY_SAMPLER\n"
-		"{\n"
-		  "Texture = <OPACITY_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_OPACITY_TEXTURE\n"
-
-	"#ifdef AV_EMISSIVE_TEXTURE\n"
-		"texture EMISSIVE_TEXTURE;\n"
-		"sampler EMISSIVE_SAMPLER\n"
-		"{\n"
-		  "Texture = <EMISSIVE_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_EMISSIVE_TEXTUR\n"
-
-	"#ifdef AV_NORMAL_TEXTURE\n"
-		"texture NORMAL_TEXTURE;\n"
-		"sampler NORMAL_SAMPLER\n"
-		"{\n"
-		  "Texture = <NORMAL_TEXTURE>;\n"
-		"};\n"
-	"#endif // AV_NORMAL_TEXTURE\n"
-
-	"#ifdef AV_SKYBOX_LOOKUP\n"
-		"textureCUBE lw_tex_envmap;\n"
-		"samplerCUBE EnvironmentMapSampler = sampler_state\n"
-		"{\n"
-		  "Texture = (lw_tex_envmap);\n"
-		  "AddressU = CLAMP;\n"
-		  "AddressV = CLAMP;\n"
-		  "AddressW = CLAMP;\n"
-
-		  "MAGFILTER = linear;\n"
-		  "MINFILTER = linear;\n"
-		"};\n"
-	"#endif // AV_SKYBOX_LOOKUP\n"
-
-	// Vertex shader input structure
-	"struct VS_INPUT\n"
-	"{\n"
-		"float3 Position : POSITION;\n"
-		"float3 Normal : NORMAL;\n"
-		"float4 Color : COLOR0;\n"
-		"float3 Tangent   : TANGENT;\n"
-		"float3 Bitangent : BINORMAL;\n"
-		"float2 TexCoord0 : TEXCOORD0;\n"
-		"#ifdef AV_TWO_UV \n"
-		"float2 TexCoord1 : TEXCOORD1;\n"
-		"#endif \n"
-		  "#ifdef AV_SKINNING \n"
-			"float4 BlendIndices : BLENDINDICES;\n"
-			"float4 BlendWeights : BLENDWEIGHT;\n"
-		 "#endif // AV_SKINNING \n"
-	"};\n"
-
-	// Vertex shader output structure for pixel shader usage
-	"struct VS_OUTPUT\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float3 ViewDir : TEXCOORD0;\n"
-
-		"float4 Color : COLOR0;\n"
-
-		"#ifndef AV_NORMAL_TEXTURE\n"
-		"float3 Normal  : TEXCOORD1;\n"
-		"#endif\n"
-
-		"float2 TexCoord0 : TEXCOORD2;\n"
-		"#ifdef AV_TWO_UV \n"
-		"float2 TexCoord1 : TEXCOORD3;\n"
-		"#endif \n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3 Light0 : TEXCOORD3;\n"
-		"float3 Light1 : TEXCOORD4;\n"
-		"#endif\n"
-	"};\n"
-
-	// Vertex shader output structure for fixed function pixel pipeline
-	"struct VS_OUTPUT_FF\n"
-	"{\n"
-		"float4 Position : POSITION;\n"
-		"float4 DiffuseColor : COLOR0;\n"
-		"float4 SpecularColor : COLOR1;\n"
-		"float2 TexCoord0 : TEXCOORD0;\n"
-	"};\n"
-
-
-	// Selective SuperSampling in screenspace for reflection lookups
-	"#define GetSSSCubeMap(_refl) (texCUBElod(EnvironmentMapSampler,float4(_refl,0.0f)).rgb) \n"
-
-
-	// Vertex shader for pixel shader usage and one light
-	"VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
-
-		"#ifdef AV_SKINNING \n"
-		"float4 weights = IN.BlendWeights; \n"
-		"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
-		"float4 localPos = float4( IN.Position, 1.0f); \n"
-		"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
-		"#else \n"
-		"float3 objPos = IN.Position; \n"
-		"#endif // AV_SKINNING \n"
-
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
-		"float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
-		"Out.TexCoord0 = IN.TexCoord0;\n"
-		"#ifdef AV_TWO_UV \n"
-		"Out.TexCoord1 = IN.TexCoord1;\n"
-		"#endif\n"
-		"Out.Color = IN.Color;\n"
-
-		"#ifndef AV_NORMAL_TEXTURE\n"
-		"Out.ViewDir = vCameraPos - WorldPos;\n"
-		"Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
-		"#endif\n"
-		
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
-		"float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
-		"Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
-		"Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
-		"#endif\n"
-		"return Out;\n"
-	"}\n"
-
-	// Vertex shader for pixel shader usage and two lights
-	"VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
-
-		"#ifdef AV_SKINNING \n"
-		"float4 weights = IN.BlendWeights; \n"
-		"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
-		"float4 localPos = float4( IN.Position, 1.0f); \n"
-		"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
-		"#else \n"
-		"float3 objPos = IN.Position; \n"
-		"#endif // AV_SKINNING \n"
-
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
-		"float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
-		"Out.TexCoord0 = IN.TexCoord0;\n"
-		"#ifdef AV_TWO_UV \n"
-		"Out.TexCoord1 = IN.TexCoord1;\n"
-		"#endif\n"
-		"Out.Color = IN.Color;\n"
-
-		"#ifndef AV_NORMAL_TEXTURE\n"
-		"Out.ViewDir = vCameraPos - WorldPos;\n"
-		"Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
-		"#endif\n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
-		"float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
-		"Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
-		"Out.Light1         = normalize(mul(WTTS, afLightDir[1] ));\n"
-		"Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
-		"#endif\n"
-		"return Out;\n"
-	"}\n"
-
-	// Vertex shader for zero to five lights using the fixed function pixel pipeline
-	"VS_OUTPUT_FF MaterialVShader_FF(VS_INPUT IN)\n"
-	"{\n"
-		"VS_OUTPUT_FF Out = (VS_OUTPUT_FF)0;\n"
-
-		"#ifdef AV_SKINNING \n"
-		"float4 weights = IN.BlendWeights; \n"
-		"weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
-		"float4 localPos = float4( IN.Position, 1.0f); \n"
-		"float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
-		"objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
-		"#else \n"
-		"float3 objPos = IN.Position; \n"
-		"#endif // AV_SKINNING \n"
-
-		// Multiply with the WorldViewProjection matrix
-		"Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
-		"float3 worldPos = mul( float4( objPos, 1.0f), World);\n"
-		"float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"
-		"Out.TexCoord0 = IN.TexCoord0;\n"
-
-		// calculate per-vertex diffuse lighting including ambient part
-		"float4 diffuseColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
-		"for( int a = 0; a < 2; a++) \n"
-		"  diffuseColor.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
-		// factor in material properties and a bit of ambient lighting
-		"Out.DiffuseColor = diffuseColor * DIFFUSE_COLOR + float4( 0.2f, 0.2f, 0.2f, 1.0f) * AMBIENT_COLOR; ; \n"
-
-		// and specular including emissive part
-		"float4 specularColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-		"float3 viewDir = normalize( worldPos - vCameraPos); \n"
-		"for( int a = 0; a < 2; a++) \n"
-		"{ \n"
-		"  float3 reflDir = reflect( afLightDir[a], worldNormal); \n"
-		"  float specIntensity = pow( saturate( dot( reflDir, viewDir)), SPECULARITY) * SPECULAR_STRENGTH; \n"
-		"  specularColor.rgb += afLightColor[a] * specIntensity; \n"
-		"} \n"
-		"#endif // AV_SPECULAR_COMPONENT\n"
-		// factor in material properties and the emissive part
-		"Out.SpecularColor = specularColor * SPECULAR_COLOR + EMISSIVE_COLOR; \n"
-
-		"return Out;\n"
-	"}\n"
-
-
-	// Pixel shader - one light
-	"float4 MaterialPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3 IN_Light0 = normalize(IN.Light0);\n"
-		"float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
-		"#else\n"
-		"float3 Normal = normalize(IN.Normal);\n"
-		"#endif \n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-			"float3 Reflect = normalize(reflect (-ViewDir,Normal));\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-
-		"{\n"
-		"#ifdef AV_NORMAL_TEXTURE\n"
-			"float L1 =  dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_0 IN_Light0\n"
-			// would need to convert the reflection vector into world space ....
-			// simply let it ...
-		"#else\n"
-			"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_0 afLightDir[0]\n"
-		"#endif\n"
-		"#ifdef AV_DIFFUSE_TEXTURE2\n"
-			"float fHalfLambert = 1.f;\n"
-		"#else\n"
-			"float fHalfLambert = L1*L1;\n"
-		"#endif \n"
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert * IN.Color.rgb +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert * IN.Color.rgb +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-			"#ifndef AV_SKYBOX_LOOKUP\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#else\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#endif // !AV_SKYBOX_LOOKUP\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-     		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-		"#ifdef AV_OPACITY\n"
-		"OUT.a = TRANSPARENCY;\n"
-		"#endif\n"
-		"#ifdef AV_LIGHTMAP_TEXTURE\n"
-		"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
-		"#endif\n"
-		"#ifdef AV_OPACITY_TEXTURE\n"
-		"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
-		"#endif\n"
-		"return OUT;\n"
-
-		"#undef AV_LIGHT_0\n"
-	"}\n"
-
-	// Pixel shader - two lights
-	"float4 MaterialPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3 IN_Light0 = normalize(IN.Light0);\n"
-		"float3 IN_Light1 = normalize(IN.Light1);\n"
-		"float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
-		"#else\n"
-		"float3 Normal = normalize(IN.Normal);\n"
-		"#endif \n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-			"float3 Reflect = -normalize(reflect (ViewDir,Normal));\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-
-		"{\n"
-		
-		"#ifdef AV_NORMAL_TEXTURE\n"
-			"float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_0 IN_Light0\n"
-		"#else\n"
-			"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_0 afLightDir[0]\n"
-		"#endif\n"
-			"float fHalfLambert = L1*L1;\n"
-			
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert  * IN.Color.rgb +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-			"#ifndef AV_SKYBOX_LOOKUP\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#else\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#endif // !AV_SKYBOX_LOOKUP\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-		"{\n"
-		"#ifdef AV_NORMAL_TEXTURE\n"
-			"float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_1 IN_Light1\n"
-		"#else\n"
-			"float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
-			"#define AV_LIGHT_1 afLightDir[1]\n"
-		"#endif\n"
-			"float fHalfLambert = L1*L1;\n"
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * fHalfLambert   * IN.Color.rgb +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-			"#ifndef AV_SKYBOX_LOOKUP\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#else\n"
-				"#ifdef AV_SPECULAR_TEXTURE\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
-				"#else\n"
-					"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
-				"#endif // !AV_SPECULAR_TEXTURE\n"
-			"#endif // !AV_SKYBOX_LOOKUP\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-		"#ifdef AV_OPACITY\n"
-		"OUT.a = TRANSPARENCY;\n"
-		"#endif\n"
-		"#ifdef AV_LIGHTMAP_TEXTURE\n"
-		"OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
-		"#endif\n"
-		"#ifdef AV_OPACITY_TEXTURE\n"
-		"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
-		"#endif\n"
-		"return OUT;\n"
-
-		"#undef AV_LIGHT_0\n"
-		"#undef AV_LIGHT_1\n"
-	"}\n"
-
-	// Same pixel shader again, one light
-	"float4 MaterialPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3 IN_Light0 = normalize(IN.Light0);\n"
-		"float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
-		"#else\n"
-		"float3 Normal = normalize(IN.Normal);\n"
-		"#endif \n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,IN_Light0);\n"
-		"#else\n"
-		"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,afLightDir[0]);\n"
-		"#endif\n"
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_SPECULAR_TEXTURE\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#else\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#endif // !AV_SPECULAR_TEXTURE\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-
-		"#ifdef AV_OPACITY\n"
-		"OUT.a = TRANSPARENCY;\n"
-		"#endif\n"
-		"#ifdef AV_OPACITY_TEXTURE\n"
-		"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
-		"#endif\n"
-		"return OUT;\n"
-	"}\n"
-
-	// Same pixel shader again, two lights
-	"float4 MaterialPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
-	"{\n"
-		"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
-
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float3 IN_Light0 = normalize(IN.Light0);\n"
-		"float3 IN_Light1 = normalize(IN.Light1);\n"
-		"float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0) - 1.0f);\n"
-		"#else\n"
-		"float3 Normal = normalize(IN.Normal);\n"
-		"#endif \n"
-		"float3 ViewDir = normalize(IN.ViewDir);\n"
-
-		"{\n"
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,IN_Light0);\n"
-		"#else\n"
-		"float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,afLightDir[0]);\n"
-		"#endif\n"
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_SPECULAR_TEXTURE\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#else\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#endif // !AV_SPECULAR_TEXTURE\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-		"{\n"
-		"#ifdef AV_NORMAL_TEXTURE\n"
-		"float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,IN_Light1);\n"
-		"#else\n"
-		"float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
-		"float3 Reflect = reflect (Normal,afLightDir[1]);\n"
-		"#endif\n"
-		"#ifdef AV_DIFFUSE_TEXTURE\n"
-			"OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
-		"#else\n"
-			"OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
-		"#endif // !AV_DIFFUSE_TEXTURE\n"
-
-		"#ifdef AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_SPECULAR_TEXTURE\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#else\n"
-			"SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
-		"#endif // !AV_SPECULAR_TEXTURE\n"
-		"#endif // !AV_SPECULAR_COMPONENT\n"
-		"#ifdef AV_AMBIENT_TEXTURE\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
-		"#else\n"
-			"AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
-		"#endif // !AV_AMBIENT_TEXTURE\n"
-		"#ifdef AV_EMISSIVE_TEXTURE\n"
-			"EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
-		"#else \n"
-			"EMISSIVE_COLOR.rgb;\n"
-		"#endif // !AV_EMISSIVE_TEXTURE\n"
-		"}\n"
-
-		"#ifdef AV_OPACITY\n"
-		"OUT.a = TRANSPARENCY;\n"
-		"#endif\n"
-		"#ifdef AV_OPACITY_TEXTURE\n"
-		"OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
-		"#endif\n"
-		"return OUT;\n"
-	"}\n"
-
-
-	// Technique for the material effect
-	"technique MaterialFXSpecular_D1\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"#ifdef AV_OPACITY_TEXTURE\n"
-			"AlphaBlendEnable=TRUE;"
-			"SrcBlend = srcalpha;\n"
-			"DestBlend = invsrcalpha;\n"
-			"#else\n"
-			"#ifdef AV_OPACITY\n"
-			"AlphaBlendEnable=TRUE;"
-			"SrcBlend = srcalpha;\n"
-			"DestBlend = invsrcalpha;\n"
-			"#endif \n"
-			"#endif\n"
-
-			"PixelShader = compile ps_3_0 MaterialPShaderSpecular_D1();\n"
-			"VertexShader = compile vs_3_0 MaterialVShader_D1();\n"
-		"}\n"
-	"};\n"
-	"technique MaterialFXSpecular_D2\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"#ifdef AV_OPACITY_TEXTURE\n"
-			"AlphaBlendEnable=TRUE;"
-			"SrcBlend = srcalpha;\n"
-			"DestBlend = invsrcalpha;\n"
-			"#else\n"
-			"#ifdef AV_OPACITY\n"
-			"AlphaBlendEnable=TRUE;"
-			"SrcBlend = srcalpha;\n"
-			"DestBlend = invsrcalpha;\n"
-			"#endif \n"
-			"#endif\n"
-
-			"PixelShader = compile ps_3_0 MaterialPShaderSpecular_D2();\n"
-			"VertexShader = compile vs_3_0 MaterialVShader_D2();\n"
-		"}\n"
-	"};\n"
-
-	// Technique for the material effect (ps_2_0)
-	"technique MaterialFXSpecular_PS20_D1\n"
-	"{\n"
-		"pass p0\n"
-  	"{\n"
-		  "#ifdef AV_OPACITY_TEXTURE\n"
-		  "AlphaBlendEnable=TRUE;"
-		  "SrcBlend = srcalpha;\n"
-		  "DestBlend = invsrcalpha;\n"
-		  "#else\n"
-		  "#ifdef AV_OPACITY\n"
-		  "AlphaBlendEnable=TRUE;"
-		  "SrcBlend = srcalpha;\n"
-		  "DestBlend = invsrcalpha;\n"
-		  "#endif \n"
-		  "#endif\n"
-
-		  "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D1();\n"
-		  "VertexShader = compile vs_2_0 MaterialVShader_D1();\n"
-		"}\n"
-	"};\n"
-
-	"technique MaterialFXSpecular_PS20_D2\n"
-	"{\n"
-		"pass p0\n"
-	  "{\n"
-		  "//CullMode=none;\n"
-
-		  "#ifdef AV_OPACITY_TEXTURE\n"
-		  "AlphaBlendEnable=TRUE;"
-		  "SrcBlend = srcalpha;\n"
-		  "DestBlend = invsrcalpha;\n"
-		  "#else\n"
-		  "#ifdef AV_OPACITY\n"
-		  "AlphaBlendEnable=TRUE;"
-		  "SrcBlend = srcalpha;\n"
-		  "DestBlend = invsrcalpha;\n"
-		  "#endif \n"
-		  "#endif\n"
-
-		  "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D2();\n"
-		  "VertexShader = compile vs_2_0 MaterialVShader_D2();\n"
-		"}\n"
-	"};\n"
-
-	// Technique for the material effect using fixed function pixel pipeline
-	"technique MaterialFX_FF\n"
-	"{\n"
-		"pass p0\n"
-		"{\n"
-			"//CullMode=none;\n"
-			"SpecularEnable = true; \n"
-			"VertexShader = compile vs_2_0 MaterialVShader_FF();\n"
-			"ColorOp[0] = Modulate;\n"
-			"ColorArg0[0] = Texture;\n"
-			"ColorArg1[0] = Diffuse;\n"
-			"AlphaOp[0] = Modulate;\n"
-			"AlphaArg0[0] = Texture;\n"
-			"AlphaArg1[0] = Diffuse;\n"
-		"}\n"
-	"};\n"
-	);
+    "float4x4 WorldViewProjection	: WORLDVIEWPROJECTION;\n"
+    "float4x4 World					: WORLD;\n"
+    "float4x3 WorldInverseTranspose	: WORLDINVERSETRANSPOSE;\n"
+
+    "#ifndef AV_DISABLESSS\n"
+    "float4x3 ViewProj;\n"
+    "float4x3 InvViewProj;\n"
+    "#endif\n"
+
+    "float4 DIFFUSE_COLOR;\n"
+    "float4 SPECULAR_COLOR;\n"
+    "float4 AMBIENT_COLOR;\n"
+    "float4 EMISSIVE_COLOR;\n"
+
+    "#ifdef AV_SPECULAR_COMPONENT\n"
+    "float SPECULARITY;\n"
+    "float SPECULAR_STRENGTH;\n"
+    "#endif\n"
+    "#ifdef AV_OPACITY\n"
+    "float TRANSPARENCY;\n"
+    "#endif\n"
+
+    // light colors (diffuse and specular)
+    "float4 afLightColor[5];\n"
+    "float4 afLightColorAmbient[5];\n"
+
+    // light direction
+    "float3 afLightDir[5];\n"
+
+    // position of the camera in worldspace
+    "float3 vCameraPos : CAMERAPOSITION;\n"
+
+    // Bone matrices
+    "#ifdef AV_SKINNING \n"
+    "float4x3 gBoneMatrix[60]; \n"
+    "#endif // AV_SKINNING \n"
+
+    "#ifdef AV_DIFFUSE_TEXTURE\n"
+        "texture DIFFUSE_TEXTURE;\n"
+        "sampler DIFFUSE_SAMPLER\n"
+        "{\n"
+          "Texture = <DIFFUSE_TEXTURE>;\n"
+          "#ifdef AV_WRAPU\n"
+          "AddressU = WRAP;\n"
+          "#endif\n"
+          "#ifdef AV_MIRRORU\n"
+          "AddressU = MIRROR;\n"
+          "#endif\n"
+          "#ifdef AV_CLAMPU\n"
+          "AddressU = CLAMP;\n"
+          "#endif\n"
+          "#ifdef AV_WRAPV\n"
+          "AddressV = WRAP;\n"
+          "#endif\n"
+          "#ifdef AV_MIRRORV\n"
+          "AddressV = MIRROR;\n"
+          "#endif\n"
+          "#ifdef AV_CLAMPV\n"
+          "AddressV = CLAMP;\n"
+          "#endif\n"
+        "};\n"
+    "#endif // AV_DIFFUSE_TEXTUR\n"
+
+    "#ifdef AV_DIFFUSE_TEXTURE2\n"
+        "texture DIFFUSE_TEXTURE2;\n"
+        "sampler DIFFUSE_SAMPLER2\n"
+        "{\n"
+          "Texture = <DIFFUSE_TEXTURE2>;\n"
+        "};\n"
+    "#endif // AV_DIFFUSE_TEXTUR2\n"
+
+    "#ifdef AV_SPECULAR_TEXTURE\n"
+        "texture SPECULAR_TEXTURE;\n"
+        "sampler SPECULAR_SAMPLER\n"
+        "{\n"
+          "Texture = <SPECULAR_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_SPECULAR_TEXTUR\n"
+
+    "#ifdef AV_AMBIENT_TEXTURE\n"
+        "texture AMBIENT_TEXTURE;\n"
+        "sampler AMBIENT_SAMPLER\n"
+        "{\n"
+          "Texture = <AMBIENT_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_AMBIENT_TEXTUR\n"
+
+    "#ifdef AV_LIGHTMAP_TEXTURE\n"
+        "texture LIGHTMAP_TEXTURE;\n"
+        "sampler LIGHTMAP_SAMPLER\n"
+        "{\n"
+          "Texture = <LIGHTMAP_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_LIGHTMAP_TEXTURE\n"
+
+    "#ifdef AV_OPACITY_TEXTURE\n"
+        "texture OPACITY_TEXTURE;\n"
+        "sampler OPACITY_SAMPLER\n"
+        "{\n"
+          "Texture = <OPACITY_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_OPACITY_TEXTURE\n"
+
+    "#ifdef AV_EMISSIVE_TEXTURE\n"
+        "texture EMISSIVE_TEXTURE;\n"
+        "sampler EMISSIVE_SAMPLER\n"
+        "{\n"
+          "Texture = <EMISSIVE_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_EMISSIVE_TEXTUR\n"
+
+    "#ifdef AV_NORMAL_TEXTURE\n"
+        "texture NORMAL_TEXTURE;\n"
+        "sampler NORMAL_SAMPLER\n"
+        "{\n"
+          "Texture = <NORMAL_TEXTURE>;\n"
+        "};\n"
+    "#endif // AV_NORMAL_TEXTURE\n"
+
+    "#ifdef AV_SKYBOX_LOOKUP\n"
+        "textureCUBE lw_tex_envmap;\n"
+        "samplerCUBE EnvironmentMapSampler = sampler_state\n"
+        "{\n"
+          "Texture = (lw_tex_envmap);\n"
+          "AddressU = CLAMP;\n"
+          "AddressV = CLAMP;\n"
+          "AddressW = CLAMP;\n"
+
+          "MAGFILTER = linear;\n"
+          "MINFILTER = linear;\n"
+        "};\n"
+    "#endif // AV_SKYBOX_LOOKUP\n"
+
+    // Vertex shader input structure
+    "struct VS_INPUT\n"
+    "{\n"
+        "float3 Position : POSITION;\n"
+        "float3 Normal : NORMAL;\n"
+        "float4 Color : COLOR0;\n"
+        "float3 Tangent   : TANGENT;\n"
+        "float3 Bitangent : BINORMAL;\n"
+        "float2 TexCoord0 : TEXCOORD0;\n"
+        "#ifdef AV_TWO_UV \n"
+        "float2 TexCoord1 : TEXCOORD1;\n"
+        "#endif \n"
+          "#ifdef AV_SKINNING \n"
+            "float4 BlendIndices : BLENDINDICES;\n"
+            "float4 BlendWeights : BLENDWEIGHT;\n"
+         "#endif // AV_SKINNING \n"
+    "};\n"
+
+    // Vertex shader output structure for pixel shader usage
+    "struct VS_OUTPUT\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float3 ViewDir : TEXCOORD0;\n"
+
+        "float4 Color : COLOR0;\n"
+
+        "#ifndef AV_NORMAL_TEXTURE\n"
+        "float3 Normal  : TEXCOORD1;\n"
+        "#endif\n"
+
+        "float2 TexCoord0 : TEXCOORD2;\n"
+        "#ifdef AV_TWO_UV \n"
+        "float2 TexCoord1 : TEXCOORD3;\n"
+        "#endif \n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3 Light0 : TEXCOORD3;\n"
+        "float3 Light1 : TEXCOORD4;\n"
+        "#endif\n"
+    "};\n"
+
+    // Vertex shader output structure for fixed function pixel pipeline
+    "struct VS_OUTPUT_FF\n"
+    "{\n"
+        "float4 Position : POSITION;\n"
+        "float4 DiffuseColor : COLOR0;\n"
+        "float4 SpecularColor : COLOR1;\n"
+        "float2 TexCoord0 : TEXCOORD0;\n"
+    "};\n"
+
+
+    // Selective SuperSampling in screenspace for reflection lookups
+    "#define GetSSSCubeMap(_refl) (texCUBElod(EnvironmentMapSampler,float4(_refl,0.0f)).rgb) \n"
+
+
+    // Vertex shader for pixel shader usage and one light
+    "VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"
+
+        "#ifdef AV_SKINNING \n"
+        "float4 weights = IN.BlendWeights; \n"
+        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
+        "float4 localPos = float4( IN.Position, 1.0f); \n"
+        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
+        "#else \n"
+        "float3 objPos = IN.Position; \n"
+        "#endif // AV_SKINNING \n"
+
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
+        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
+        "Out.TexCoord0 = IN.TexCoord0;\n"
+        "#ifdef AV_TWO_UV \n"
+        "Out.TexCoord1 = IN.TexCoord1;\n"
+        "#endif\n"
+        "Out.Color = IN.Color;\n"
+
+        "#ifndef AV_NORMAL_TEXTURE\n"
+        "Out.ViewDir = vCameraPos - WorldPos;\n"
+        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
+        "#endif\n"
+        
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
+        "float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
+        "Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
+        "Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
+        "#endif\n"
+        "return Out;\n"
+    "}\n"
+
+    // Vertex shader for pixel shader usage and two lights
+    "VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT Out = (VS_OUTPUT)0;\n"
+
+        "#ifdef AV_SKINNING \n"
+        "float4 weights = IN.BlendWeights; \n"
+        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
+        "float4 localPos = float4( IN.Position, 1.0f); \n"
+        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
+        "#else \n"
+        "float3 objPos = IN.Position; \n"
+        "#endif // AV_SKINNING \n"
+
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
+        "float3 WorldPos = mul( float4( objPos, 1.0f), World);\n"
+        "Out.TexCoord0 = IN.TexCoord0;\n"
+        "#ifdef AV_TWO_UV \n"
+        "Out.TexCoord1 = IN.TexCoord1;\n"
+        "#endif\n"
+        "Out.Color = IN.Color;\n"
+
+        "#ifndef AV_NORMAL_TEXTURE\n"
+        "Out.ViewDir = vCameraPos - WorldPos;\n"
+        "Out.Normal = mul(IN.Normal,WorldInverseTranspose);\n"
+        "#endif\n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3x3 TBNMatrix = float3x3(IN.Tangent, IN.Bitangent, IN.Normal);\n"
+        "float3x3 WTTS      = mul(TBNMatrix, (float3x3)WorldInverseTranspose);\n"
+        "Out.Light0         = normalize(mul(WTTS, afLightDir[0] ));\n"
+        "Out.Light1         = normalize(mul(WTTS, afLightDir[1] ));\n"
+        "Out.ViewDir = normalize(mul(WTTS, (vCameraPos - WorldPos)));\n"
+        "#endif\n"
+        "return Out;\n"
+    "}\n"
+
+    // Vertex shader for zero to five lights using the fixed function pixel pipeline
+    "VS_OUTPUT_FF MaterialVShader_FF(VS_INPUT IN)\n"
+    "{\n"
+        "VS_OUTPUT_FF Out = (VS_OUTPUT_FF)0;\n"
+
+        "#ifdef AV_SKINNING \n"
+        "float4 weights = IN.BlendWeights; \n"
+        "weights.w = 1.0f - dot( weights.xyz, float3( 1, 1, 1)); \n"
+        "float4 localPos = float4( IN.Position, 1.0f); \n"
+        "float3 objPos = mul( localPos, gBoneMatrix[IN.BlendIndices.x]) * weights.x; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.y]) * weights.y; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.z]) * weights.z; \n"
+        "objPos += mul( localPos, gBoneMatrix[IN.BlendIndices.w]) * weights.w; \n"
+        "#else \n"
+        "float3 objPos = IN.Position; \n"
+        "#endif // AV_SKINNING \n"
+
+        // Multiply with the WorldViewProjection matrix
+        "Out.Position = mul( float4( objPos, 1.0f), WorldViewProjection);\n"
+        "float3 worldPos = mul( float4( objPos, 1.0f), World);\n"
+        "float3 worldNormal = normalize( mul( IN.Normal, (float3x3) WorldInverseTranspose)); \n"
+        "Out.TexCoord0 = IN.TexCoord0;\n"
+
+        // calculate per-vertex diffuse lighting including ambient part
+        "float4 diffuseColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
+        "for( int a = 0; a < 2; a++) \n"
+        "  diffuseColor.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
+        // factor in material properties and a bit of ambient lighting
+        "Out.DiffuseColor = diffuseColor * DIFFUSE_COLOR + float4( 0.2f, 0.2f, 0.2f, 1.0f) * AMBIENT_COLOR; ; \n"
+
+        // and specular including emissive part
+        "float4 specularColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+        "float3 viewDir = normalize( worldPos - vCameraPos); \n"
+        "for( int a = 0; a < 2; a++) \n"
+        "{ \n"
+        "  float3 reflDir = reflect( afLightDir[a], worldNormal); \n"
+        "  float specIntensity = pow( saturate( dot( reflDir, viewDir)), SPECULARITY) * SPECULAR_STRENGTH; \n"
+        "  specularColor.rgb += afLightColor[a] * specIntensity; \n"
+        "} \n"
+        "#endif // AV_SPECULAR_COMPONENT\n"
+        // factor in material properties and the emissive part
+        "Out.SpecularColor = specularColor * SPECULAR_COLOR + EMISSIVE_COLOR; \n"
+
+        "return Out;\n"
+    "}\n"
+
+
+    // Pixel shader - one light
+    "float4 MaterialPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3 IN_Light0 = normalize(IN.Light0);\n"
+        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
+        "#else\n"
+        "float3 Normal = normalize(IN.Normal);\n"
+        "#endif \n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+            "float3 Reflect = normalize(reflect (-ViewDir,Normal));\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+
+        "{\n"
+        "#ifdef AV_NORMAL_TEXTURE\n"
+            "float L1 =  dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_0 IN_Light0\n"
+            // would need to convert the reflection vector into world space ....
+            // simply let it ...
+        "#else\n"
+            "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_0 afLightDir[0]\n"
+        "#endif\n"
+        "#ifdef AV_DIFFUSE_TEXTURE2\n"
+            "float fHalfLambert = 1.f;\n"
+        "#else\n"
+            "float fHalfLambert = L1*L1;\n"
+        "#endif \n"
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert * IN.Color.rgb +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert * IN.Color.rgb +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+            "#ifndef AV_SKYBOX_LOOKUP\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#else\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#endif // !AV_SKYBOX_LOOKUP\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+            "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+        "#ifdef AV_OPACITY\n"
+        "OUT.a = TRANSPARENCY;\n"
+        "#endif\n"
+        "#ifdef AV_LIGHTMAP_TEXTURE\n"
+        "OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
+        "#endif\n"
+        "#ifdef AV_OPACITY_TEXTURE\n"
+        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
+        "#endif\n"
+        "return OUT;\n"
+
+        "#undef AV_LIGHT_0\n"
+    "}\n"
+
+    // Pixel shader - two lights
+    "float4 MaterialPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3 IN_Light0 = normalize(IN.Light0);\n"
+        "float3 IN_Light1 = normalize(IN.Light1);\n"
+        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
+        "#else\n"
+        "float3 Normal = normalize(IN.Normal);\n"
+        "#endif \n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+            "float3 Reflect = -normalize(reflect (ViewDir,Normal));\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+
+        "{\n"
+        
+        "#ifdef AV_NORMAL_TEXTURE\n"
+            "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_0 IN_Light0\n"
+        "#else\n"
+            "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_0 afLightDir[0]\n"
+        "#endif\n"
+            "float fHalfLambert = L1*L1;\n"
+            
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * fHalfLambert  * IN.Color.rgb +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+            "#ifndef AV_SKYBOX_LOOKUP\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#else\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_0),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#endif // !AV_SKYBOX_LOOKUP\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb + \n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+        "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+        "{\n"
+        "#ifdef AV_NORMAL_TEXTURE\n"
+            "float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_1 IN_Light1\n"
+        "#else\n"
+            "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
+            "#define AV_LIGHT_1 afLightDir[1]\n"
+        "#endif\n"
+            "float fHalfLambert = L1*L1;\n"
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * fHalfLambert  * IN.Color.rgb +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * fHalfLambert   * IN.Color.rgb +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+            "#ifndef AV_SKYBOX_LOOKUP\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#else\n"
+                "#ifdef AV_SPECULAR_TEXTURE\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
+                "#else\n"
+                    "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * GetSSSCubeMap(Reflect) * (saturate(fHalfLambert * 2.0f) * pow(dot(Reflect,AV_LIGHT_1),SPECULARITY)) + \n"
+                "#endif // !AV_SPECULAR_TEXTURE\n"
+            "#endif // !AV_SKYBOX_LOOKUP\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb + \n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+        "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+        "#ifdef AV_OPACITY\n"
+        "OUT.a = TRANSPARENCY;\n"
+        "#endif\n"
+        "#ifdef AV_LIGHTMAP_TEXTURE\n"
+        "OUT.rgb *= tex2D(LIGHTMAP_SAMPLER,AV_LIGHTMAP_TEXTURE_UV_COORD).rgb*LM_STRENGTH;\n"
+        "#endif\n"
+        "#ifdef AV_OPACITY_TEXTURE\n"
+        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
+        "#endif\n"
+        "return OUT;\n"
+
+        "#undef AV_LIGHT_0\n"
+        "#undef AV_LIGHT_1\n"
+    "}\n"
+
+    // Same pixel shader again, one light
+    "float4 MaterialPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3 IN_Light0 = normalize(IN.Light0);\n"
+        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0).rgb - 1.0f);\n"
+        "#else\n"
+        "float3 Normal = normalize(IN.Normal);\n"
+        "#endif \n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,IN_Light0);\n"
+        "#else\n"
+        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
+        "#endif\n"
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_SPECULAR_TEXTURE\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#else\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#endif // !AV_SPECULAR_TEXTURE\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+        "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+
+        "#ifdef AV_OPACITY\n"
+        "OUT.a = TRANSPARENCY;\n"
+        "#endif\n"
+        "#ifdef AV_OPACITY_TEXTURE\n"
+        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
+        "#endif\n"
+        "return OUT;\n"
+    "}\n"
+
+    // Same pixel shader again, two lights
+    "float4 MaterialPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
+    "{\n"
+        "float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
+
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float3 IN_Light0 = normalize(IN.Light0);\n"
+        "float3 IN_Light1 = normalize(IN.Light1);\n"
+        "float3 Normal  =  normalize(2.0f * tex2D(NORMAL_SAMPLER, IN.TexCoord0) - 1.0f);\n"
+        "#else\n"
+        "float3 Normal = normalize(IN.Normal);\n"
+        "#endif \n"
+        "float3 ViewDir = normalize(IN.ViewDir);\n"
+
+        "{\n"
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float L1 = dot(Normal,IN_Light0) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,IN_Light0);\n"
+        "#else\n"
+        "float L1 = dot(Normal,afLightDir[0]) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,afLightDir[0]);\n"
+        "#endif\n"
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[0].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_SPECULAR_TEXTURE\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#else\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[0].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#endif // !AV_SPECULAR_TEXTURE\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[0].rgb +\n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+        "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+        "{\n"
+        "#ifdef AV_NORMAL_TEXTURE\n"
+        "float L1 = dot(Normal,IN_Light1) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,IN_Light1);\n"
+        "#else\n"
+        "float L1 = dot(Normal,afLightDir[1]) * 0.5f + 0.5f;\n"
+        "float3 Reflect = reflect (Normal,afLightDir[1]);\n"
+        "#endif\n"
+        "#ifdef AV_DIFFUSE_TEXTURE\n"
+            "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * tex2D(DIFFUSE_SAMPLER,IN.TexCoord0).rgb * L1 +\n"
+        "#else\n"
+            "OUT.rgb += afLightColor[1].rgb * DIFFUSE_COLOR.rgb * L1 +\n"
+        "#endif // !AV_DIFFUSE_TEXTURE\n"
+
+        "#ifdef AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_SPECULAR_TEXTURE\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * tex2D(SPECULAR_SAMPLER,IN.TexCoord0).rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#else\n"
+            "SPECULAR_COLOR.rgb * SPECULAR_STRENGTH * afLightColor[1].rgb * (saturate(L1 * 4.0f) * pow(dot(Reflect,ViewDir),SPECULARITY)) + \n"
+        "#endif // !AV_SPECULAR_TEXTURE\n"
+        "#endif // !AV_SPECULAR_COMPONENT\n"
+        "#ifdef AV_AMBIENT_TEXTURE\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb * tex2D(AMBIENT_SAMPLER,IN.TexCoord0).rgb +\n"
+        "#else\n"
+            "AMBIENT_COLOR.rgb * afLightColorAmbient[1].rgb + \n"
+        "#endif // !AV_AMBIENT_TEXTURE\n"
+        "#ifdef AV_EMISSIVE_TEXTURE\n"
+            "EMISSIVE_COLOR.rgb * tex2D(EMISSIVE_SAMPLER,IN.TexCoord0).rgb;\n"
+        "#else \n"
+            "EMISSIVE_COLOR.rgb;\n"
+        "#endif // !AV_EMISSIVE_TEXTURE\n"
+        "}\n"
+
+        "#ifdef AV_OPACITY\n"
+        "OUT.a = TRANSPARENCY;\n"
+        "#endif\n"
+        "#ifdef AV_OPACITY_TEXTURE\n"
+        "OUT.a *= tex2D(OPACITY_SAMPLER,IN.TexCoord0). AV_OPACITY_TEXTURE_REGISTER_MASK;\n"
+        "#endif\n"
+        "return OUT;\n"
+    "}\n"
+
+
+    // Technique for the material effect
+    "technique MaterialFXSpecular_D1\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "#ifdef AV_OPACITY_TEXTURE\n"
+            "AlphaBlendEnable=TRUE;"
+            "SrcBlend = srcalpha;\n"
+            "DestBlend = invsrcalpha;\n"
+            "#else\n"
+            "#ifdef AV_OPACITY\n"
+            "AlphaBlendEnable=TRUE;"
+            "SrcBlend = srcalpha;\n"
+            "DestBlend = invsrcalpha;\n"
+            "#endif \n"
+            "#endif\n"
+
+            "PixelShader = compile ps_3_0 MaterialPShaderSpecular_D1();\n"
+            "VertexShader = compile vs_3_0 MaterialVShader_D1();\n"
+        "}\n"
+    "};\n"
+    "technique MaterialFXSpecular_D2\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "#ifdef AV_OPACITY_TEXTURE\n"
+            "AlphaBlendEnable=TRUE;"
+            "SrcBlend = srcalpha;\n"
+            "DestBlend = invsrcalpha;\n"
+            "#else\n"
+            "#ifdef AV_OPACITY\n"
+            "AlphaBlendEnable=TRUE;"
+            "SrcBlend = srcalpha;\n"
+            "DestBlend = invsrcalpha;\n"
+            "#endif \n"
+            "#endif\n"
+
+            "PixelShader = compile ps_3_0 MaterialPShaderSpecular_D2();\n"
+            "VertexShader = compile vs_3_0 MaterialVShader_D2();\n"
+        "}\n"
+    "};\n"
+
+    // Technique for the material effect (ps_2_0)
+    "technique MaterialFXSpecular_PS20_D1\n"
+    "{\n"
+        "pass p0\n"
+    "{\n"
+          "#ifdef AV_OPACITY_TEXTURE\n"
+          "AlphaBlendEnable=TRUE;"
+          "SrcBlend = srcalpha;\n"
+          "DestBlend = invsrcalpha;\n"
+          "#else\n"
+          "#ifdef AV_OPACITY\n"
+          "AlphaBlendEnable=TRUE;"
+          "SrcBlend = srcalpha;\n"
+          "DestBlend = invsrcalpha;\n"
+          "#endif \n"
+          "#endif\n"
+
+          "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D1();\n"
+          "VertexShader = compile vs_2_0 MaterialVShader_D1();\n"
+        "}\n"
+    "};\n"
+
+    "technique MaterialFXSpecular_PS20_D2\n"
+    "{\n"
+        "pass p0\n"
+      "{\n"
+          "//CullMode=none;\n"
+
+          "#ifdef AV_OPACITY_TEXTURE\n"
+          "AlphaBlendEnable=TRUE;"
+          "SrcBlend = srcalpha;\n"
+          "DestBlend = invsrcalpha;\n"
+          "#else\n"
+          "#ifdef AV_OPACITY\n"
+          "AlphaBlendEnable=TRUE;"
+          "SrcBlend = srcalpha;\n"
+          "DestBlend = invsrcalpha;\n"
+          "#endif \n"
+          "#endif\n"
+
+          "PixelShader = compile ps_2_0 MaterialPShaderSpecular_PS20_D2();\n"
+          "VertexShader = compile vs_2_0 MaterialVShader_D2();\n"
+        "}\n"
+    "};\n"
+
+    // Technique for the material effect using fixed function pixel pipeline
+    "technique MaterialFX_FF\n"
+    "{\n"
+        "pass p0\n"
+        "{\n"
+            "//CullMode=none;\n"
+            "SpecularEnable = true; \n"
+            "VertexShader = compile vs_2_0 MaterialVShader_FF();\n"
+            "ColorOp[0] = Modulate;\n"
+            "ColorArg0[0] = Texture;\n"
+            "ColorArg1[0] = Diffuse;\n"
+            "AlphaOp[0] = Modulate;\n"
+            "AlphaArg0[0] = Texture;\n"
+            "AlphaArg1[0] = Diffuse;\n"
+        "}\n"
+    "};\n"
+    );
 
 std::string g_szPassThroughShader = std::string(
-		"texture TEXTURE_2D;\n"
-		"sampler TEXTURE_SAMPLER = sampler_state\n"
-		"{\n"
-			"Texture = (TEXTURE_2D);\n"
-			"MinFilter = POINT;\n"
-			"MagFilter = POINT;\n"
-		"};\n"
+        "texture TEXTURE_2D;\n"
+        "sampler TEXTURE_SAMPLER = sampler_state\n"
+        "{\n"
+            "Texture = (TEXTURE_2D);\n"
+            "MinFilter = POINT;\n"
+            "MagFilter = POINT;\n"
+        "};\n"
 
     // Vertex Shader output for pixel shader usage
-		"struct VS_OUTPUT\n"
-		"{\n"
-			"float4 Position : POSITION;\n"
-			"float2 TexCoord0 : TEXCOORD0;\n"
-		"};\n"
+        "struct VS_OUTPUT\n"
+        "{\n"
+            "float4 Position : POSITION;\n"
+            "float2 TexCoord0 : TEXCOORD0;\n"
+        "};\n"
 
     // vertex shader for pixel shader usage
-		"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
-		"{\n"
-			"VS_OUTPUT Out;\n"
-
-			"Out.Position = INPosition;\n"
-			"Out.TexCoord0 = INTexCoord0;\n"
-
-			"return Out;\n"
-		"}\n"
-
-		// simply lookup a texture
-		"float4 PassThrough_PS(float2 IN : TEXCOORD0) : COLOR\n"
-		"{\n"
- 		"  return tex2D(TEXTURE_SAMPLER,IN);\n"
-		"}\n"
-
-		// visualize the alpha channel (in black) -> use a
-		"float4 PassThroughAlphaA_PS(float2 IN : TEXCOORD0) : COLOR\n"
-		"{\n"
-		"  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).a);\n"
-		"}\n"
-
-		// visualize the alpha channel (in black) -> use r
-		"float4 PassThroughAlphaR_PS(float2 IN : TEXCOORD0) : COLOR\n"
-		"{\n"
-		"  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).r);\n"
-		"}\n"
-
-		// Simple pass-through technique
-		"technique PassThrough\n"
-		"{\n"
-			"pass p0\n"
-			"{\n"
-				"FillMode=Solid;\n"
-				"ZEnable = FALSE;\n"
-				"CullMode = none;\n"
-				"AlphaBlendEnable = TRUE;\n"
-				"SrcBlend =srcalpha;\n"
-				"DestBlend =invsrcalpha;\n"
-				"PixelShader = compile ps_2_0 PassThrough_PS();\n"
-				"VertexShader = compile vs_2_0 DefaultVShader();\n"
-			"}\n"
-		"};\n"
-
-		// Pass-through technique which visualizes the texture's alpha channel
-		"technique PassThroughAlphaFromA\n"
-		"{\n"
-			"pass p0\n"
-			"{\n"
-				"FillMode=Solid;\n"
-				"ZEnable = FALSE;\n"
-				"CullMode = none;\n"
-				"AlphaBlendEnable = TRUE;\n"
-				"SrcBlend =srcalpha;\n"
-				"DestBlend =invsrcalpha;\n"
-				"PixelShader = compile ps_2_0 PassThroughAlphaA_PS();\n"
-				"VertexShader = compile vs_2_0 DefaultVShader();\n"
-			"}\n"
-		"};\n"
-
-		// Pass-through technique which visualizes the texture's red channel
-		"technique PassThroughAlphaFromR\n"
-		"{\n"
-			"pass p0\n"
-			"{\n"
-				"FillMode=Solid;\n"
-				"ZEnable = FALSE;\n"
-				"CullMode = none;\n"
-				"AlphaBlendEnable = TRUE;\n"
-				"SrcBlend =srcalpha;\n"
-				"DestBlend =invsrcalpha;\n"
-				"PixelShader = compile ps_2_0 PassThroughAlphaR_PS();\n"
-				"VertexShader = compile vs_2_0 DefaultVShader();\n"
-			"}\n"
-		"};\n"
-
-		// technique for fixed function pixel pipeline
-		"technique PassThrough_FF\n"
-		"{\n"
-			"pass p0\n"
-			"{\n"
-				"ZEnable = FALSE;\n"
-				"CullMode = none;\n"
-				"AlphaBlendEnable = TRUE;\n"
-				"SrcBlend =srcalpha;\n"
-				"DestBlend =invsrcalpha;\n"
-				"VertexShader = compile vs_2_0 DefaultVShader();\n"
+        "VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
+        "{\n"
+            "VS_OUTPUT Out;\n"
+
+            "Out.Position = INPosition;\n"
+            "Out.TexCoord0 = INTexCoord0;\n"
+
+            "return Out;\n"
+        "}\n"
+
+        // simply lookup a texture
+        "float4 PassThrough_PS(float2 IN : TEXCOORD0) : COLOR\n"
+        "{\n"
+        "  return tex2D(TEXTURE_SAMPLER,IN);\n"
+        "}\n"
+
+        // visualize the alpha channel (in black) -> use a
+        "float4 PassThroughAlphaA_PS(float2 IN : TEXCOORD0) : COLOR\n"
+        "{\n"
+        "  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).a);\n"
+        "}\n"
+
+        // visualize the alpha channel (in black) -> use r
+        "float4 PassThroughAlphaR_PS(float2 IN : TEXCOORD0) : COLOR\n"
+        "{\n"
+        "  return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).r);\n"
+        "}\n"
+
+        // Simple pass-through technique
+        "technique PassThrough\n"
+        "{\n"
+            "pass p0\n"
+            "{\n"
+                "FillMode=Solid;\n"
+                "ZEnable = FALSE;\n"
+                "CullMode = none;\n"
+                "AlphaBlendEnable = TRUE;\n"
+                "SrcBlend =srcalpha;\n"
+                "DestBlend =invsrcalpha;\n"
+                "PixelShader = compile ps_2_0 PassThrough_PS();\n"
+                "VertexShader = compile vs_2_0 DefaultVShader();\n"
+            "}\n"
+        "};\n"
+
+        // Pass-through technique which visualizes the texture's alpha channel
+        "technique PassThroughAlphaFromA\n"
+        "{\n"
+            "pass p0\n"
+            "{\n"
+                "FillMode=Solid;\n"
+                "ZEnable = FALSE;\n"
+                "CullMode = none;\n"
+                "AlphaBlendEnable = TRUE;\n"
+                "SrcBlend =srcalpha;\n"
+                "DestBlend =invsrcalpha;\n"
+                "PixelShader = compile ps_2_0 PassThroughAlphaA_PS();\n"
+                "VertexShader = compile vs_2_0 DefaultVShader();\n"
+            "}\n"
+        "};\n"
+
+        // Pass-through technique which visualizes the texture's red channel
+        "technique PassThroughAlphaFromR\n"
+        "{\n"
+            "pass p0\n"
+            "{\n"
+                "FillMode=Solid;\n"
+                "ZEnable = FALSE;\n"
+                "CullMode = none;\n"
+                "AlphaBlendEnable = TRUE;\n"
+                "SrcBlend =srcalpha;\n"
+                "DestBlend =invsrcalpha;\n"
+                "PixelShader = compile ps_2_0 PassThroughAlphaR_PS();\n"
+                "VertexShader = compile vs_2_0 DefaultVShader();\n"
+            "}\n"
+        "};\n"
+
+        // technique for fixed function pixel pipeline
+        "technique PassThrough_FF\n"
+        "{\n"
+            "pass p0\n"
+            "{\n"
+                "ZEnable = FALSE;\n"
+                "CullMode = none;\n"
+                "AlphaBlendEnable = TRUE;\n"
+                "SrcBlend =srcalpha;\n"
+                "DestBlend =invsrcalpha;\n"
+                "VertexShader = compile vs_2_0 DefaultVShader();\n"
         "ColorOp[0] = SelectArg1;\n"
         "ColorArg0[0] = Texture;\n"
         "AlphaOp[0] = SelectArg1;\n"
         "AlphaArg0[0] = Texture;\n"
-			"}\n"
-		"};\n"
+            "}\n"
+        "};\n"
     );
 
 std::string g_szCheckerBackgroundShader = std::string(
 
-		// the two colors used to draw the checker pattern
-		"float3 COLOR_ONE = float3(0.4f,0.4f,0.4f);\n"
-		"float3 COLOR_TWO = float3(0.6f,0.6f,0.6f);\n"
+        // the two colors used to draw the checker pattern
+        "float3 COLOR_ONE = float3(0.4f,0.4f,0.4f);\n"
+        "float3 COLOR_TWO = float3(0.6f,0.6f,0.6f);\n"
 
-		// size of a square in both x and y direction
-		"float SQUARE_SIZE = 10.0f;\n"
+        // size of a square in both x and y direction
+        "float SQUARE_SIZE = 10.0f;\n"
 
     // vertex shader output structure
-		"struct VS_OUTPUT\n"
-		"{\n"
-			"float4 Position : POSITION;\n"	
-		"};\n"
+        "struct VS_OUTPUT\n"
+        "{\n"
+            "float4 Position : POSITION;\n"	
+        "};\n"
 
     // vertex shader 
-		"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
-		"{\n"
-			"VS_OUTPUT Out;\n"
-
-			"Out.Position = INPosition;\n"
-			"return Out;\n"
-		"}\n"
-
-		// pixel shader
-		"float4 MakePattern_PS(float2 IN : VPOS) : COLOR\n"
-		"{\n"
-		  "float2 fDiv = IN / SQUARE_SIZE;\n"
-		  "float3 fColor = COLOR_ONE;\n"
-		  "if (0 == round(fmod(round(fDiv.x),2)))\n"
-		  "{\n"
-		  "  if (0 == round(fmod(round(fDiv.y),2))) fColor = COLOR_TWO;\n"
-		  "}\n"
-		  "else if (0 != round(fmod(round(fDiv.y),2)))fColor = COLOR_TWO;\n"
-		  "return float4(fColor,1.0f);"
-		"}\n"
-	
-		// technique to generate a pattern
-		"technique MakePattern\n"
-		"{\n"
-		  "pass p0\n"
-		  "{\n"
-		    "FillMode=Solid;\n"
-		    "ZEnable = FALSE;\n"
-		    "CullMode = none;\n"
-		    "PixelShader = compile ps_3_0 MakePattern_PS();\n"
-		    "VertexShader = compile vs_3_0 DefaultVShader();\n"
-		  "}\n"
-		"};\n"
-		);
-	};
+        "VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
+        "{\n"
+            "VS_OUTPUT Out;\n"
+
+            "Out.Position = INPosition;\n"
+            "return Out;\n"
+        "}\n"
+
+        // pixel shader
+        "float4 MakePattern_PS(float2 IN : VPOS) : COLOR\n"
+        "{\n"
+          "float2 fDiv = IN / SQUARE_SIZE;\n"
+          "float3 fColor = COLOR_ONE;\n"
+          "if (0 == round(fmod(round(fDiv.x),2)))\n"
+          "{\n"
+          "  if (0 == round(fmod(round(fDiv.y),2))) fColor = COLOR_TWO;\n"
+          "}\n"
+          "else if (0 != round(fmod(round(fDiv.y),2)))fColor = COLOR_TWO;\n"
+          "return float4(fColor,1.0f);"
+        "}\n"
+    
+        // technique to generate a pattern
+        "technique MakePattern\n"
+        "{\n"
+          "pass p0\n"
+          "{\n"
+            "FillMode=Solid;\n"
+            "ZEnable = FALSE;\n"
+            "CullMode = none;\n"
+            "PixelShader = compile ps_3_0 MakePattern_PS();\n"
+            "VertexShader = compile vs_3_0 DefaultVShader();\n"
+          "}\n"
+        "};\n"
+        );
+    };

Fichier diff supprimé car celui-ci est trop grand
+ 523 - 522
tools/assimp_view/assimp_view.cpp


+ 37 - 36
tools/assimp_view/assimp_view.h

@@ -47,6 +47,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // include resource definitions
 #include "resource.h"
 
+#include <assert.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+#include <stdio.h>
+#include <time.h>
+
 // Include ASSIMP headers (XXX: do we really need all of them?)
 #include <assimp/cimport.h>
 #include <assimp/Importer.hpp>
@@ -59,17 +67,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assimp/LogStream.hpp>
 #include <assimp/DefaultLogger.hpp>
 
-#include "../../code/AssimpPCH.h" /* HACK */
  
 #include "../../code/MaterialSystem.h"   // aiMaterial class
 #include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
 
 // in order for std::min and std::max to behave properly
-#ifdef min 
-#undef min
-#endif // min
-#ifdef max 
-#undef max
+#ifndef max
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#endif // max
+#ifndef min
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
 #endif // min
 
 #include <time.h>
@@ -77,11 +84,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // default movement speed 
 #define MOVE_SPEED 3.f
 
-using namespace Assimp;
-
-namespace AssimpView 
-{
-
 #include "AssetHelper.h"
 #include "Camera.h"
 #include "RenderOptions.h"
@@ -93,7 +95,6 @@ namespace AssimpView
 #include "MeshRenderer.h"
 #include "MaterialManager.h"
 
-} // end of namespace AssimpView - for a while
 
 // outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
 #include "AnimEvaluator.h"
@@ -105,30 +106,30 @@ namespace AssimpView
 //-------------------------------------------------------------------------------
 // Function prototypes
 //-------------------------------------------------------------------------------
-	int InitD3D(void);
-	int ShutdownD3D(void);
-	int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
-	int CreateDevice (void);
-	int ShutdownDevice(void);
-	int GetProjectionMatrix (aiMatrix4x4& p_mOut);
-	int LoadAsset(void);
-	int CreateAssetData(void);
-	int DeleteAssetData(bool bNoMaterials = false);
-	int ScaleAsset(void);
-	int DeleteAsset(void);
-	int SetupFPSView();
+int InitD3D(void);
+int ShutdownD3D(void);
+int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
+int CreateDevice (void);
+int ShutdownDevice(void);
+int GetProjectionMatrix (aiMatrix4x4& p_mOut);
+int LoadAsset(void);
+int CreateAssetData(void);
+int DeleteAssetData(bool bNoMaterials = false);
+int ScaleAsset(void);
+int DeleteAsset(void);
+int SetupFPSView();
 	
-	aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
-	int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
+aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
+int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
 
-	void HandleMouseInputFPS( void );
-	void HandleMouseInputLightRotate( void );
-	void HandleMouseInputLocal( void );
-	void HandleKeyboardInputFPS( void );
-	void HandleMouseInputLightIntensityAndColor( void );
-	void HandleMouseInputSkyBox( void );
-	void HandleKeyboardInputTextureView( void );
-	void HandleMouseInputTextureView( void );
+void HandleMouseInputFPS( void );
+void HandleMouseInputLightRotate( void );
+void HandleMouseInputLocal( void );
+void HandleKeyboardInputFPS( void );
+void HandleMouseInputLightIntensityAndColor( void );
+void HandleMouseInputSkyBox( void );
+void HandleKeyboardInputTextureView( void );
+void HandleMouseInputTextureView( void );
 
 
 //-------------------------------------------------------------------------------
@@ -160,7 +161,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
 
 //-------------------------------------------------------------------------------
 // 
-// Dialog prcoedure for the help dialog
+// Dialog procedure for the help dialog
 //
 //-------------------------------------------------------------------------------
 INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
@@ -182,7 +183,7 @@ type clamp(intype in)
 {
 	// for unsigned types only ...
 	intype mask = (0x1u << (sizeof(type)*8))-1;
-	return (type)std::max((intype)0,std::min(in,mask));
+	return (type)max((intype)0,min(in,mask));
 }
 
 

+ 12 - 12
workspaces/xcode3/assimp.xcodeproj/project.pbxproj

@@ -117,11 +117,11 @@
 		2B7F478E1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
 		2B7F478F1708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
 		2B7F47901708365200A106A9 /* tuple.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45961708365100A106A9 /* tuple.hpp */; };
-		2B7F479B1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
-		2B7F479C1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
-		2B7F479D1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
-		2B7F479E1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
-		2B7F479F1708365200A106A9 /* ByteSwap.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwap.h */; };
+		2B7F479B1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
+		2B7F479C1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
+		2B7F479D1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
+		2B7F479E1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
+		2B7F479F1708365200A106A9 /* ByteSwapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B7F45991708365100A106A9 /* ByteSwapper.h */; };
 		2B7F47A01708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
 		2B7F47A11708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
 		2B7F47A21708365200A106A9 /* CalcTangentsProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */; };
@@ -2018,7 +2018,7 @@
 		2B7F45931708365100A106A9 /* static_assert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = static_assert.hpp; sourceTree = "<group>"; };
 		2B7F45941708365100A106A9 /* timer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = timer.hpp; sourceTree = "<group>"; };
 		2B7F45961708365100A106A9 /* tuple.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tuple.hpp; sourceTree = "<group>"; };
-		2B7F45991708365100A106A9 /* ByteSwap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteSwap.h; sourceTree = "<group>"; };
+		2B7F45991708365100A106A9 /* ByteSwapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteSwapper.h; sourceTree = "<group>"; };
 		2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CalcTangentsProcess.cpp; sourceTree = "<group>"; };
 		2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalcTangentsProcess.h; sourceTree = "<group>"; };
 		2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CInterfaceIOWrapper.h; sourceTree = "<group>"; };
@@ -2509,7 +2509,7 @@
 				2B7F45761708365100A106A9 /* BaseProcess.cpp */,
 				2B7F45771708365100A106A9 /* BaseProcess.h */,
 				2B7F45831708365100A106A9 /* BlobIOSystem.h */,
-				2B7F45991708365100A106A9 /* ByteSwap.h */,
+				2B7F45991708365100A106A9 /* ByteSwapper.h */,
 				2B7F459A1708365100A106A9 /* CalcTangentsProcess.cpp */,
 				2B7F459B1708365100A106A9 /* CalcTangentsProcess.h */,
 				2B7F459C1708365100A106A9 /* CInterfaceIOWrapper.h */,
@@ -3517,7 +3517,7 @@
 				2B7F47841708365200A106A9 /* static_assert.hpp in Headers */,
 				2B7F47891708365200A106A9 /* timer.hpp in Headers */,
 				2B7F478E1708365200A106A9 /* tuple.hpp in Headers */,
-				2B7F479D1708365200A106A9 /* ByteSwap.h in Headers */,
+				2B7F479D1708365200A106A9 /* ByteSwapper.h in Headers */,
 				2B7F47A71708365200A106A9 /* CalcTangentsProcess.h in Headers */,
 				2B7F47AC1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
 				2B7F47C51708365200A106A9 /* ColladaExporter.h in Headers */,
@@ -3765,7 +3765,7 @@
 				2B7F47851708365200A106A9 /* static_assert.hpp in Headers */,
 				2B7F478A1708365200A106A9 /* timer.hpp in Headers */,
 				2B7F478F1708365200A106A9 /* tuple.hpp in Headers */,
-				2B7F479E1708365200A106A9 /* ByteSwap.h in Headers */,
+				2B7F479E1708365200A106A9 /* ByteSwapper.h in Headers */,
 				2B7F47A81708365200A106A9 /* CalcTangentsProcess.h in Headers */,
 				2B7F47AD1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
 				2B7F47C61708365200A106A9 /* ColladaExporter.h in Headers */,
@@ -4013,7 +4013,7 @@
 				2B7F47861708365200A106A9 /* static_assert.hpp in Headers */,
 				2B7F478B1708365200A106A9 /* timer.hpp in Headers */,
 				2B7F47901708365200A106A9 /* tuple.hpp in Headers */,
-				2B7F479F1708365200A106A9 /* ByteSwap.h in Headers */,
+				2B7F479F1708365200A106A9 /* ByteSwapper.h in Headers */,
 				2B7F47A91708365200A106A9 /* CalcTangentsProcess.h in Headers */,
 				2B7F47AE1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
 				2B7F47C71708365200A106A9 /* ColladaExporter.h in Headers */,
@@ -4261,7 +4261,7 @@
 				2B7F47821708365200A106A9 /* static_assert.hpp in Headers */,
 				2B7F47871708365200A106A9 /* timer.hpp in Headers */,
 				2B7F478C1708365200A106A9 /* tuple.hpp in Headers */,
-				2B7F479B1708365200A106A9 /* ByteSwap.h in Headers */,
+				2B7F479B1708365200A106A9 /* ByteSwapper.h in Headers */,
 				2B7F47A51708365200A106A9 /* CalcTangentsProcess.h in Headers */,
 				2B7F47AA1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
 				2B7F47C31708365200A106A9 /* ColladaExporter.h in Headers */,
@@ -4509,7 +4509,7 @@
 				2B7F47831708365200A106A9 /* static_assert.hpp in Headers */,
 				2B7F47881708365200A106A9 /* timer.hpp in Headers */,
 				2B7F478D1708365200A106A9 /* tuple.hpp in Headers */,
-				2B7F479C1708365200A106A9 /* ByteSwap.h in Headers */,
+				2B7F479C1708365200A106A9 /* ByteSwapper.h in Headers */,
 				2B7F47A61708365200A106A9 /* CalcTangentsProcess.h in Headers */,
 				2B7F47AB1708365200A106A9 /* CInterfaceIOWrapper.h in Headers */,
 				2B7F47C41708365200A106A9 /* ColladaExporter.h in Headers */,

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff