Browse Source

Skeleton FBX importer code added

Marko Pintera 13 years ago
parent
commit
60366ddb01

+ 90 - 0
CamelotFBXImporter/CamelotFBXImporter.vcxproj

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{7F449698-73DF-4203-9F31-0877DBF01695}</ProjectGuid>
+    <RootNamespace>CamelotFBXImporter</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v110</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <OutDir>..\bin\$(Configuration)\</OutDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <AdditionalIncludeDirectories>../CamelotRenderer/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FBX_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalLibraryDirectories>../lib/$(Configuration);../Dependencies/lib/Debug;./Dependencies/lib/Debug</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotRenderer.lib;CamelotUtility.lib;libboost_signals-vc110-mt-gd-1_49.lib;fbxsdk-2013.2-mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>../CamelotRenderer/Include;../CamelotUtility/Include;./Include;../Dependencies/Include;./Dependencies/Include</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>CM_FBX_EXPORTS;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <AdditionalLibraryDirectories>../lib/$(Configuration);../Dependencies/lib/Release;./Dependencies/lib/Release</AdditionalLibraryDirectories>
+      <AdditionalDependencies>CamelotRenderer.lib;CamelotUtility.lib;libboost_signals-vc110-mt-1_49.lib;fbxsdk-2013.2-md.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <ImportLibrary>..\lib\$(Configuration)\$(TargetName).lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\CmFBXImporter.h" />
+    <ClInclude Include="Include\CmFBXPrerequisites.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmFBXImporter.cpp" />
+    <ClCompile Include="Source\CmFBXPlugin.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 33 - 0
CamelotFBXImporter/CamelotFBXImporter.vcxproj.filters

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\CmFBXPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmFBXImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\CmFBXImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmFBXPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

+ 43 - 0
CamelotFBXImporter/Include/CmFBXImporter.h

@@ -0,0 +1,43 @@
+#pragma once
+
+#include "CmFBXPrerequisites.h"
+#include "CmSpecificImporter.h"
+#include "CmImporter.h"
+
+namespace CamelotEngine
+{
+	class CM_FBX_EXPORT FBXImporter : public SpecificImporter
+	{
+	public:
+		FBXImporter();
+		virtual ~FBXImporter();
+
+		/**
+		 * @brief	Should only be called by the plugin when its being loaded.
+		 */
+		static void startUp()
+		{
+			static FBXImporter* importer = nullptr;
+			if(importer == nullptr)
+			{
+				importer = new FBXImporter();
+				Importer::instance().registerAssetImporter(importer);
+			}
+		}
+
+		/** Inherited from SpecificImporter */
+		virtual bool isExtensionSupported(const String& ext) const;
+
+		/** Inherited from SpecificImporter */
+		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const; 
+
+		/** Inherited from SpecificImporter */
+		virtual ResourcePtr import(DataStreamPtr fileData);
+	private:
+		vector<String>::type mExtensions;
+		std::unordered_map<String, int> mExtensionToFID;
+
+		String magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const;
+		TextureDataPtr importRawImage(DataStreamPtr fileData);
+	};
+}

+ 19 - 0
CamelotFBXImporter/Include/CmFBXPrerequisites.h

@@ -0,0 +1,19 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+
+#if (CM_PLATFORM == CM_PLATFORM_WIN32) && !defined(__MINGW32__)
+#	ifdef CM_FBX_EXPORTS
+#		define CM_FBX_EXPORT __declspec(dllexport)
+#	else
+#       if defined( __MINGW32__ )
+#           define CM_FBX_EXPORT
+#       else
+#    		define CM_FBX_EXPORT __declspec(dllimport)
+#       endif
+#	endif
+#elif defined ( CM_GCC_VISIBILITY )
+#    define CM_FBX_EXPORT  __attribute__ ((visibility("default")))
+#else
+#    define CM_FBX_EXPORT
+#endif

+ 45 - 0
CamelotFBXImporter/Source/CmFBXImporter.cpp

@@ -0,0 +1,45 @@
+#include "CmFBXImporter.h"
+#include "CmResource.h"
+#include "CmDebug.h"
+#include "CmDataStream.h"
+#include "CmPath.h"
+
+namespace CamelotEngine
+{
+	FBXImporter::FBXImporter()
+		:SpecificImporter() 
+	{
+
+	}
+
+	FBXImporter::~FBXImporter() 
+	{
+
+	}
+
+	bool FBXImporter::isExtensionSupported(const String& ext) const
+	{
+		String lowerCaseExt = ext;
+		StringUtil::toLowerCase(lowerCaseExt);
+
+		return find(mExtensions.begin(), mExtensions.end(), lowerCaseExt) != mExtensions.end();
+	}
+
+	bool FBXImporter::isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const
+	{
+		String ext = magicNumToExtension(magicNumPtr, numBytes);
+
+		return isExtensionSupported(ext);
+	}
+
+	String FBXImporter::magicNumToExtension(const UINT8* magic, UINT32 maxBytes) const
+	{
+
+		return StringUtil::BLANK;
+	}
+
+	ResourcePtr FBXImporter::import(DataStreamPtr fileData)
+	{
+		return nullptr;
+	}
+}

+ 16 - 0
CamelotFBXImporter/Source/CmFBXPlugin.cpp

@@ -0,0 +1,16 @@
+#include "CmFBXPrerequisites.h"
+#include "CmFBXImporter.h"
+
+namespace CamelotEngine
+{
+	extern "C" CM_FBX_EXPORT const String& getPluginName()
+	{
+		static String pluginName = "FBXImporter";
+		return pluginName;
+	}
+
+	extern "C" CM_FBX_EXPORT void loadPlugin()
+	{
+		FBXImporter::startUp();
+	}
+}

+ 12 - 0
CamelotRenderer.sln

@@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotFreeImgImporter", "C
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 		{9B21D41C-516B-43BF-9B10-E99B599C7589} = {9B21D41C-516B-43BF-9B10-E99B599C7589}
 	EndProjectSection
 	EndProjectSection
 EndProject
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CamelotFBXImporter", "CamelotFBXImporter\CamelotFBXImporter.vcxproj", "{7F449698-73DF-4203-9F31-0877DBF01695}"
+EndProject
 Global
 Global
 	GlobalSection(SubversionScc) = preSolution
 	GlobalSection(SubversionScc) = preSolution
 		Svn-Managed = True
 		Svn-Managed = True
@@ -107,6 +109,16 @@ Global
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Mixed Platforms.Build.0 = Release|Win32
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Mixed Platforms.Build.0 = Release|Win32
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Win32.ActiveCfg = Release|Win32
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Win32.ActiveCfg = Release|Win32
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Win32.Build.0 = Release|Win32
 		{122B7A22-0C62-4B35-B661-EBF3F394EA79}.Release|Win32.Build.0 = Release|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Debug|Any CPU.ActiveCfg = Debug|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Debug|Win32.ActiveCfg = Debug|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Debug|Win32.Build.0 = Debug|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Release|Any CPU.ActiveCfg = Release|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Release|Mixed Platforms.Build.0 = Release|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Release|Win32.ActiveCfg = Release|Win32
+		{7F449698-73DF-4203-9F31-0877DBF01695}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 1 - 1
CamelotRenderer/Include/CmSpecificImporter.h

@@ -12,7 +12,7 @@ namespace CamelotEngine
 	 *			On initialization this class must register itself with the Importer module,
 	 *			On initialization this class must register itself with the Importer module,
 	 *			which delegates asset import calls to a specific importer.
 	 *			which delegates asset import calls to a specific importer.
 	 */
 	 */
-	class SpecificImporter
+	class CM_EXPORT SpecificImporter
 	{
 	{
 	public:
 	public:
 		SpecificImporter() {}
 		SpecificImporter() {}

+ 27 - 7
Dependencies.txt

@@ -1,14 +1,34 @@
-Camelot relies on following 3rd party libraries:
- - Boost 1.49 (Later versions might work as well, but you need to test it on your own)
+Camelot relies on the following 3rd party libraries:
+ - Boost 1.49
     - http://www.boost.org
     - http://www.boost.org
  - Cg 3.1
  - Cg 3.1
     - http://developer.nvidia.com/cg-toolkit
     - http://developer.nvidia.com/cg-toolkit
 
 
 Place dependency files in:
 Place dependency files in:
- - Library include files in /Dependencies/Include
- - Static library files in /Dependencies/lib/Debug and /Dependencies/lib/Release
- - Dynamic library files in /bin/Debug and /bin/Release (Possibly others if you define other configuration types)
+ - Library include files in (CamelotRootDir)/Dependencies/Include
+ - Static library files in (CamelotRootDir)/Dependencies/lib/Debug and (CamelotRootDir)/Dependencies/lib/Release
+ - Dynamic library files in (CamelotRootDir)/bin/Debug and (CamelotRootDir)/bin/Release (Possibly others if you define other configuration types)
+
+----------------------------------------------------------------------------------
+
+Camelot plug-in dependencies:
+
+CamelotFBXImporter (optional) relies on:
+ - FBX SDK 2013.2
+   - http://usa.autodesk.com/fbx
+
+CamelotFreeImgImporter (optional) relies on:
+ - FreeImage 3.13.1
+  - http://freeimage.sourceforge.net
+
+Place plug-in specific dependency files in:
+ - Library include files in (CamelotRootDir)/(PluginDir)/Dependencies/Include
+ - Static library files in (CamelotRootDir)/(PluginDir)/Dependencies/lib/Debug and (CamelotRootDir)/(PluginDir)/Dependencies/lib/Release
+ - Dynamic library files in (CamelotRootDir)/bin/Debug and (CamelotRootDir)/bin/Release (Possibly others if you define other configuration types)
+
+ ----------------------------------------------------------------------------------
 
 
 Listed dependencies have not been provided with the engine source code. 
 Listed dependencies have not been provided with the engine source code. 
-You will need to grab them manually from the specified links, and place them 
-in the above specified folders. 
+You will need to grab them manually from the specified links, 
+(compile them, depending if library comes pre-compiled or not), 
+and place them in the above specified folders.