Fix CRLF
This commit is contained in:
parent
92b29be383
commit
97b2835ae6
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
*.sdf
|
*.sdf
|
||||||
*.opensdf
|
*.opensdf
|
||||||
*.user
|
*.user
|
||||||
*.suo
|
*.suo
|
||||||
/*.dll
|
/*.dll
|
||||||
Debug/
|
Debug/
|
||||||
Release/
|
Release/
|
||||||
ipch/
|
ipch/
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
# Visual Studio 2010
|
# Visual Studio 2010
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssimpToMesh", "AssimpToMesh\AssimpToMesh.vcxproj", "{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssimpToMesh", "AssimpToMesh\AssimpToMesh.vcxproj", "{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Debug|Win32.ActiveCfg = Debug|Win32
|
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Debug|Win32.Build.0 = Debug|Win32
|
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Release|Win32.ActiveCfg = Release|Win32
|
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Release|Win32.Build.0 = Release|Win32
|
{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}.Release|Win32.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -1,107 +1,107 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}</ProjectGuid>
|
<ProjectGuid>{1706D477-F8C1-4CD9-A9F6-06A9D903FD3C}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>AssimpToMesh</RootNamespace>
|
<RootNamespace>AssimpToMesh</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<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" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>true</LinkIncremental>
|
<LinkIncremental>true</LinkIncremental>
|
||||||
<IncludePath>E:\assimp--2.0.863-sdk\include;$(IncludePath)</IncludePath>
|
<IncludePath>E:\assimp--2.0.863-sdk\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>E:\assimp--2.0.863-sdk\lib\assimp_debug-dll_win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>E:\assimp--2.0.863-sdk\lib\assimp_debug-dll_win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IncludePath>E:\assimp--2.0.863-sdk\include;$(IncludePath)</IncludePath>
|
<IncludePath>E:\assimp--2.0.863-sdk\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>E:\assimp--2.0.863-sdk\lib\assimp_release-dll_win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>E:\assimp--2.0.863-sdk\lib\assimp_release-dll_win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
</PrecompiledHeader>
|
</PrecompiledHeader>
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\assimputils\assimpgeometry.cpp" />
|
<ClCompile Include="src\assimputils\assimpgeometry.cpp" />
|
||||||
<ClCompile Include="src\assimputils\assimpsceneinfo.cpp" />
|
<ClCompile Include="src\assimputils\assimpsceneinfo.cpp" />
|
||||||
<ClCompile Include="src\convert\meshutils.cpp" />
|
<ClCompile Include="src\convert\meshutils.cpp" />
|
||||||
<ClCompile Include="src\convert\skeletalanimated.cpp" />
|
<ClCompile Include="src\convert\skeletalanimated.cpp" />
|
||||||
<ClCompile Include="src\convert\static.cpp" />
|
<ClCompile Include="src\convert\static.cpp" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\nodetree\nodetree.cpp" />
|
<ClCompile Include="src\nodetree\nodetree.cpp" />
|
||||||
<ClCompile Include="src\utils\fileutils.cpp" />
|
<ClCompile Include="src\utils\fileutils.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\assimputils\types.h" />
|
<ClInclude Include="src\assimputils\types.h" />
|
||||||
<ClInclude Include="src\assimputils\utils.h" />
|
<ClInclude Include="src\assimputils\utils.h" />
|
||||||
<ClInclude Include="src\convert\convert.h" />
|
<ClInclude Include="src\convert\convert.h" />
|
||||||
<ClInclude Include="src\convert\mesh.h" />
|
<ClInclude Include="src\convert\mesh.h" />
|
||||||
<ClInclude Include="src\convert\meshjoint.h" />
|
<ClInclude Include="src\convert\meshjoint.h" />
|
||||||
<ClInclude Include="src\convert\meshmaterial.h" />
|
<ClInclude Include="src\convert\meshmaterial.h" />
|
||||||
<ClInclude Include="src\convert\meshtriangle.h" />
|
<ClInclude Include="src\convert\meshtriangle.h" />
|
||||||
<ClInclude Include="src\convert\submesh.h" />
|
<ClInclude Include="src\convert\submesh.h" />
|
||||||
<ClInclude Include="src\nodetree\nodetree.h" />
|
<ClInclude Include="src\nodetree\nodetree.h" />
|
||||||
<ClInclude Include="src\utils\utils.h" />
|
<ClInclude Include="src\utils\utils.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,75 +1,75 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Source Files">
|
<Filter Include="Source Files">
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Header Files">
|
<Filter Include="Header Files">
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Resource Files">
|
<Filter Include="Resource Files">
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
<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>
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\main.cpp">
|
<ClCompile Include="src\main.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\utils\fileutils.cpp">
|
<ClCompile Include="src\utils\fileutils.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\assimputils\assimpsceneinfo.cpp">
|
<ClCompile Include="src\assimputils\assimpsceneinfo.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\convert\static.cpp">
|
<ClCompile Include="src\convert\static.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\convert\skeletalanimated.cpp">
|
<ClCompile Include="src\convert\skeletalanimated.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\nodetree\nodetree.cpp">
|
<ClCompile Include="src\nodetree\nodetree.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\convert\meshutils.cpp">
|
<ClCompile Include="src\convert\meshutils.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\assimputils\assimpgeometry.cpp">
|
<ClCompile Include="src\assimputils\assimpgeometry.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\utils\utils.h">
|
<ClInclude Include="src\utils\utils.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\assimputils\utils.h">
|
<ClInclude Include="src\assimputils\utils.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\convert.h">
|
<ClInclude Include="src\convert\convert.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\nodetree\nodetree.h">
|
<ClInclude Include="src\nodetree\nodetree.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\mesh.h">
|
<ClInclude Include="src\convert\mesh.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\assimputils\types.h">
|
<ClInclude Include="src\assimputils\types.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\meshmaterial.h">
|
<ClInclude Include="src\convert\meshmaterial.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\meshtriangle.h">
|
<ClInclude Include="src\convert\meshtriangle.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\submesh.h">
|
<ClInclude Include="src\convert\submesh.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\convert\meshjoint.h">
|
<ClInclude Include="src\convert\meshjoint.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,82 +1,82 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
// determine if a vertex is already contained in the bucket, if so matchingIndex will contain the index of the matching vertex
|
// determine if a vertex is already contained in the bucket, if so matchingIndex will contain the index of the matching vertex
|
||||||
bool FindVertex(const aiVector3D &vertex, const AssimpVertices &bucket, unsigned int &matchingIndex)
|
bool FindVertex(const aiVector3D &vertex, const AssimpVertices &bucket, unsigned int &matchingIndex)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < bucket.size(); ++i)
|
for (unsigned int i = 0; i < bucket.size(); ++i)
|
||||||
{
|
{
|
||||||
if (vertex == bucket[i])
|
if (vertex == bucket[i])
|
||||||
{
|
{
|
||||||
matchingIndex = i;
|
matchingIndex = i;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectVerticesInMesh(
|
void CollectVerticesInMesh(
|
||||||
const aiMesh *mesh,
|
const aiMesh *mesh,
|
||||||
AssimpVertices &verticesBucket,
|
AssimpVertices &verticesBucket,
|
||||||
AssimpVertices &normalsBucket,
|
AssimpVertices &normalsBucket,
|
||||||
AssimpVertices &texCoordsBucket,
|
AssimpVertices &texCoordsBucket,
|
||||||
AssimpVertexIndices &indexMapping)
|
AssimpVertexIndices &indexMapping)
|
||||||
{
|
{
|
||||||
bool hasTexCoords = mesh->HasTextureCoords(0);
|
bool hasTexCoords = mesh->HasTextureCoords(0);
|
||||||
bool hasNormals = mesh->HasNormals();
|
bool hasNormals = mesh->HasNormals();
|
||||||
|
|
||||||
indexMapping.resize(mesh->mNumVertices);
|
indexMapping.resize(mesh->mNumVertices);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i)
|
for (unsigned int i = 0; i < mesh->mNumVertices; ++i)
|
||||||
{
|
{
|
||||||
unsigned int matchingIndex = 0;
|
unsigned int matchingIndex = 0;
|
||||||
aiVector3D vertex = mesh->mVertices[i];
|
aiVector3D vertex = mesh->mVertices[i];
|
||||||
|
|
||||||
// TODO: this seems to not work quite so well... might have something to do with the
|
// TODO: this seems to not work quite so well... might have something to do with the
|
||||||
// fact that ASSIMP is already taking care of duplicate vertices and indexing as
|
// fact that ASSIMP is already taking care of duplicate vertices and indexing as
|
||||||
// appropriate? the problem seems to be only with tex coords though....
|
// appropriate? the problem seems to be only with tex coords though....
|
||||||
//if (!FindVertex(vertex, verticesBucket, matchingIndex))
|
//if (!FindVertex(vertex, verticesBucket, matchingIndex))
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
// vertex isn't in the bucket already, add it, and then record mapping between the mesh vertex index and the bucket vertex index
|
// vertex isn't in the bucket already, add it, and then record mapping between the mesh vertex index and the bucket vertex index
|
||||||
verticesBucket.push_back(vertex);
|
verticesBucket.push_back(vertex);
|
||||||
matchingIndex = verticesBucket.size() - 1;
|
matchingIndex = verticesBucket.size() - 1;
|
||||||
|
|
||||||
// also copy the normal and tex coord into the appropriate buckets
|
// also copy the normal and tex coord into the appropriate buckets
|
||||||
// TODO: check if mesh has normals and/or tex coords first!
|
// TODO: check if mesh has normals and/or tex coords first!
|
||||||
if (hasNormals)
|
if (hasNormals)
|
||||||
{
|
{
|
||||||
aiVector3D normal = mesh->mNormals[i];
|
aiVector3D normal = mesh->mNormals[i];
|
||||||
normalsBucket.push_back(normal);
|
normalsBucket.push_back(normal);
|
||||||
}
|
}
|
||||||
if (hasTexCoords)
|
if (hasTexCoords)
|
||||||
{
|
{
|
||||||
aiVector3D texCoord = mesh->mTextureCoords[0][i];
|
aiVector3D texCoord = mesh->mTextureCoords[0][i];
|
||||||
texCoordsBucket.push_back(texCoord);
|
texCoordsBucket.push_back(texCoord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stating the obvious so when i come back here and read this, i know instantly
|
// stating the obvious so when i come back here and read this, i know instantly
|
||||||
// what the fuck is going on (sad, I know):
|
// what the fuck is going on (sad, I know):
|
||||||
// i = index into mesh's separate vertices list
|
// i = index into mesh's separate vertices list
|
||||||
// matchingIndex = index into bucket's vertices list
|
// matchingIndex = index into bucket's vertices list
|
||||||
indexMapping[i] = matchingIndex;
|
indexMapping[i] = matchingIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectAllMeshVertices(
|
void CollectAllMeshVertices(
|
||||||
const aiScene *scene,
|
const aiScene *scene,
|
||||||
AssimpVertices &verticesBucket,
|
AssimpVertices &verticesBucket,
|
||||||
AssimpVertices &normalsBucket,
|
AssimpVertices &normalsBucket,
|
||||||
AssimpVertices &texCoordsBucket,
|
AssimpVertices &texCoordsBucket,
|
||||||
AssimpVerticesMap &indexMapping)
|
AssimpVerticesMap &indexMapping)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
AssimpVertexIndices indexes;
|
AssimpVertexIndices indexes;
|
||||||
CollectVerticesInMesh(mesh, verticesBucket, normalsBucket, texCoordsBucket, indexes);
|
CollectVerticesInMesh(mesh, verticesBucket, normalsBucket, texCoordsBucket, indexes);
|
||||||
|
|
||||||
indexMapping[i] = indexes;
|
indexMapping[i] = indexes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
bool IsSceneAnimated(const aiScene *scene)
|
bool IsSceneAnimated(const aiScene *scene)
|
||||||
{
|
{
|
||||||
return scene->HasAnimations();
|
return scene->HasAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSceneSkeletal(const aiScene *scene)
|
bool IsSceneSkeletal(const aiScene *scene)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
if (scene->mMeshes[i]->HasBones())
|
if (scene->mMeshes[i]->HasBones())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSceneStatic(const aiScene *scene)
|
bool IsSceneStatic(const aiScene *scene)
|
||||||
{
|
{
|
||||||
if (IsSceneAnimated(scene) || IsSceneSkeletal(scene))
|
if (IsSceneAnimated(scene) || IsSceneSkeletal(scene))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef __ASSIMPUTILS_TYPES_H_INCLUDED__
|
#ifndef __ASSIMPUTILS_TYPES_H_INCLUDED__
|
||||||
#define __ASSIMPUTILS_TYPES_H_INCLUDED__
|
#define __ASSIMPUTILS_TYPES_H_INCLUDED__
|
||||||
|
|
||||||
#include <aiTypes.h>
|
#include <aiTypes.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
typedef std::vector<aiVector3D> AssimpVertices;
|
typedef std::vector<aiVector3D> AssimpVertices;
|
||||||
|
|
||||||
typedef std::vector<unsigned int> AssimpVertexIndices;
|
typedef std::vector<unsigned int> AssimpVertexIndices;
|
||||||
typedef std::map<unsigned int, AssimpVertexIndices> AssimpVerticesMap;
|
typedef std::map<unsigned int, AssimpVertexIndices> AssimpVerticesMap;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
#ifndef __ASSIMPUTILS_UTILS_H_INCLUDED__
|
#ifndef __ASSIMPUTILS_UTILS_H_INCLUDED__
|
||||||
#define __ASSIMPUTILS_UTILS_H_INCLUDED__
|
#define __ASSIMPUTILS_UTILS_H_INCLUDED__
|
||||||
|
|
||||||
#include <assimp.hpp>
|
#include <assimp.hpp>
|
||||||
#include <aiScene.h>
|
#include <aiScene.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
bool IsSceneAnimated(const aiScene *scene);
|
bool IsSceneAnimated(const aiScene *scene);
|
||||||
bool IsSceneSkeletal(const aiScene *scene);
|
bool IsSceneSkeletal(const aiScene *scene);
|
||||||
bool IsSceneStatic(const aiScene *scene);
|
bool IsSceneStatic(const aiScene *scene);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will go through each mesh in the scene, and store all the vertices it
|
* This will go through each mesh in the scene, and store all the vertices it
|
||||||
* finds into one common bucket, building up a mapping as it goes so that,
|
* finds into one common bucket, building up a mapping as it goes so that,
|
||||||
* we can easily determine what mesh index and vertex index as stored by ASSIMP
|
* we can easily determine what mesh index and vertex index as stored by ASSIMP
|
||||||
* corresponds to what vertex in the common bucket. That is, after this, given:
|
* corresponds to what vertex in the common bucket. That is, after this, given:
|
||||||
*
|
*
|
||||||
* aiScene *scene = ...
|
* aiScene *scene = ...
|
||||||
* aiMesh *mesh = scene->mMeshes[meshIndex];
|
* aiMesh *mesh = scene->mMeshes[meshIndex];
|
||||||
* unsigned int bucketIndex = mesh->mVertices[3];
|
* unsigned int bucketIndex = mesh->mVertices[3];
|
||||||
* ... and/or ...
|
* ... and/or ...
|
||||||
* unsigned int bucketIndex = mesh->mFaces[10]->mIndices[0];
|
* unsigned int bucketIndex = mesh->mFaces[10]->mIndices[0];
|
||||||
* aiVector3D vertex = bucket[bucketIndex];
|
* aiVector3D vertex = bucket[bucketIndex];
|
||||||
*
|
*
|
||||||
* where "bucketIndex" is the index into one of the bucket lists
|
* where "bucketIndex" is the index into one of the bucket lists
|
||||||
*/
|
*/
|
||||||
void CollectAllMeshVertices(
|
void CollectAllMeshVertices(
|
||||||
const aiScene *scene,
|
const aiScene *scene,
|
||||||
AssimpVertices &verticesBucket,
|
AssimpVertices &verticesBucket,
|
||||||
AssimpVertices &normalsBucket,
|
AssimpVertices &normalsBucket,
|
||||||
AssimpVertices &texCoordsBucket,
|
AssimpVertices &texCoordsBucket,
|
||||||
AssimpVerticesMap &indexMapping);
|
AssimpVerticesMap &indexMapping);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef __CONVERT_CONVERT_H_INCLUDED__
|
#ifndef __CONVERT_CONVERT_H_INCLUDED__
|
||||||
#define __CONVERT_CONVERT_H_INCLUDED__
|
#define __CONVERT_CONVERT_H_INCLUDED__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <aiScene.h>
|
#include <aiScene.h>
|
||||||
|
|
||||||
void ConvertStatic(const std::string &outfile, const aiScene *scene);
|
void ConvertStatic(const std::string &outfile, const aiScene *scene);
|
||||||
void ConvertSkeletalAnimated(const std::string &outfile, const aiScene *scene);
|
void ConvertSkeletalAnimated(const std::string &outfile, const aiScene *scene);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
#ifndef __CONVERT_MESH_H_INCLUDED__
|
#ifndef __CONVERT_MESH_H_INCLUDED__
|
||||||
#define __CONVERT_MESH_H_INCLUDED__
|
#define __CONVERT_MESH_H_INCLUDED__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <aiTypes.h>
|
#include <aiTypes.h>
|
||||||
#include "../assimputils/types.h"
|
#include "../assimputils/types.h"
|
||||||
#include "meshmaterial.h"
|
#include "meshmaterial.h"
|
||||||
#include "meshtriangle.h"
|
#include "meshtriangle.h"
|
||||||
#include "submesh.h"
|
#include "submesh.h"
|
||||||
#include "meshjoint.h"
|
#include "meshjoint.h"
|
||||||
|
|
||||||
void WriteMeshHeader(FILE *fp);
|
void WriteMeshHeader(FILE *fp);
|
||||||
void WriteVertices(const AssimpVertices &vertices, FILE *fp);
|
void WriteVertices(const AssimpVertices &vertices, FILE *fp);
|
||||||
void WriteNormals(const AssimpVertices &normals, FILE *fp);
|
void WriteNormals(const AssimpVertices &normals, FILE *fp);
|
||||||
void WriteTexCoords(const AssimpVertices &texCoords, FILE *fp);
|
void WriteTexCoords(const AssimpVertices &texCoords, FILE *fp);
|
||||||
void WriteMaterials(const std::vector<MeshMaterial> &materials, FILE *fp);
|
void WriteMaterials(const std::vector<MeshMaterial> &materials, FILE *fp);
|
||||||
void WriteTriangles(const std::vector<MeshTriangle> &triangles, FILE *fp);
|
void WriteTriangles(const std::vector<MeshTriangle> &triangles, FILE *fp);
|
||||||
void WriteSubMeshes(const std::vector<SubMesh> &subMeshes, FILE *fp);
|
void WriteSubMeshes(const std::vector<SubMesh> &subMeshes, FILE *fp);
|
||||||
void WriteJoints(const std::vector<MeshJoint> &joints, FILE *fp);
|
void WriteJoints(const std::vector<MeshJoint> &joints, FILE *fp);
|
||||||
void WriteJointToVertexMap(const std::vector<uint32_t> &vertexToJointMap, FILE *fp);
|
void WriteJointToVertexMap(const std::vector<uint32_t> &vertexToJointMap, FILE *fp);
|
||||||
void WriteJointKeyFrames(const std::vector<JointKeyFrames> &jointKeyFrames, FILE *fp);
|
void WriteJointKeyFrames(const std::vector<JointKeyFrames> &jointKeyFrames, FILE *fp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
#ifndef __CONVERT_MESHJOINT_H_INCLUDED__
|
#ifndef __CONVERT_MESHJOINT_H_INCLUDED__
|
||||||
#define __CONVERT_MESHJOINT_H_INCLUDED__
|
#define __CONVERT_MESHJOINT_H_INCLUDED__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <aiVector3D.h>
|
#include <aiVector3D.h>
|
||||||
#include <aiQuaternion.h>
|
#include <aiQuaternion.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct MeshJoint
|
struct MeshJoint
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string parentName;
|
std::string parentName;
|
||||||
aiVector3D localPosition;
|
aiVector3D localPosition;
|
||||||
aiQuaternion localRotation;
|
aiQuaternion localRotation;
|
||||||
aiVector3D offsetPosition;
|
aiVector3D offsetPosition;
|
||||||
aiQuaternion offsetRotation;
|
aiQuaternion offsetRotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MeshJointKeyFrame
|
struct MeshJointKeyFrame
|
||||||
{
|
{
|
||||||
aiVector3D position;
|
aiVector3D position;
|
||||||
aiQuaternion rotation;
|
aiQuaternion rotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<MeshJointKeyFrame> JointKeyFrames;
|
typedef std::vector<MeshJointKeyFrame> JointKeyFrames;
|
||||||
|
|
||||||
int32_t GetIndexOf(const std::vector<MeshJoint> &joints, const std::string &name);
|
int32_t GetIndexOf(const std::vector<MeshJoint> &joints, const std::string &name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
#ifndef __CONVERT_MESHMATERIAL_H_INCLUDED__
|
#ifndef __CONVERT_MESHMATERIAL_H_INCLUDED__
|
||||||
#define __CONVERT_MESHMATERIAL_H_INCLUDED__
|
#define __CONVERT_MESHMATERIAL_H_INCLUDED__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <aiMaterial.h>
|
#include <aiMaterial.h>
|
||||||
|
|
||||||
struct MeshMaterial
|
struct MeshMaterial
|
||||||
{
|
{
|
||||||
MeshMaterial()
|
MeshMaterial()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshMaterial(const aiMaterial *source)
|
MeshMaterial(const aiMaterial *source)
|
||||||
{
|
{
|
||||||
aiString name;
|
aiString name;
|
||||||
aiString textureFile;
|
aiString textureFile;
|
||||||
aiColor3D ambient;
|
aiColor3D ambient;
|
||||||
aiColor3D diffuse;
|
aiColor3D diffuse;
|
||||||
aiColor3D specular;
|
aiColor3D specular;
|
||||||
aiColor3D emissive;
|
aiColor3D emissive;
|
||||||
float shininess;
|
float shininess;
|
||||||
float opacity;
|
float opacity;
|
||||||
|
|
||||||
source->Get(AI_MATKEY_NAME, name);
|
source->Get(AI_MATKEY_NAME, name);
|
||||||
source->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
|
source->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
|
||||||
source->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
|
source->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
|
||||||
source->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
source->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
||||||
source->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
|
source->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
|
||||||
source->Get(AI_MATKEY_SHININESS, shininess);
|
source->Get(AI_MATKEY_SHININESS, shininess);
|
||||||
source->Get(AI_MATKEY_OPACITY, opacity);
|
source->Get(AI_MATKEY_OPACITY, opacity);
|
||||||
|
|
||||||
// TODO: need something better then this, but based on my (limited) testing
|
// TODO: need something better then this, but based on my (limited) testing
|
||||||
// diffuse texture seems to be the most common
|
// diffuse texture seems to be the most common
|
||||||
source->Get(AI_MATKEY_TEXTURE_DIFFUSE(0), textureFile);
|
source->Get(AI_MATKEY_TEXTURE_DIFFUSE(0), textureFile);
|
||||||
|
|
||||||
this->name = std::string(name.data, name.length);
|
this->name = std::string(name.data, name.length);
|
||||||
|
|
||||||
this->texture = std::string(textureFile.data, textureFile.length);
|
this->texture = std::string(textureFile.data, textureFile.length);
|
||||||
|
|
||||||
this->ambient[0] = ambient.r;
|
this->ambient[0] = ambient.r;
|
||||||
this->ambient[1] = ambient.g;
|
this->ambient[1] = ambient.g;
|
||||||
this->ambient[2] = ambient.b;
|
this->ambient[2] = ambient.b;
|
||||||
|
|
||||||
this->diffuse[0] = diffuse.r;
|
this->diffuse[0] = diffuse.r;
|
||||||
this->diffuse[1] = diffuse.g;
|
this->diffuse[1] = diffuse.g;
|
||||||
this->diffuse[2] = diffuse.b;
|
this->diffuse[2] = diffuse.b;
|
||||||
|
|
||||||
this->specular[0] = specular.r;
|
this->specular[0] = specular.r;
|
||||||
this->specular[1] = specular.g;
|
this->specular[1] = specular.g;
|
||||||
this->specular[2] = specular.b;
|
this->specular[2] = specular.b;
|
||||||
|
|
||||||
this->emissive[0] = emissive.r;
|
this->emissive[0] = emissive.r;
|
||||||
this->emissive[1] = emissive.g;
|
this->emissive[1] = emissive.g;
|
||||||
this->emissive[2] = emissive.b;
|
this->emissive[2] = emissive.b;
|
||||||
|
|
||||||
this->shininess = shininess;
|
this->shininess = shininess;
|
||||||
|
|
||||||
this->opacity = opacity;
|
this->opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string texture;
|
std::string texture;
|
||||||
float ambient[3];
|
float ambient[3];
|
||||||
float diffuse[3];
|
float diffuse[3];
|
||||||
float specular[3];
|
float specular[3];
|
||||||
float emissive[3];
|
float emissive[3];
|
||||||
float shininess;
|
float shininess;
|
||||||
float opacity;
|
float opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#ifndef __CONVERT_MESHTRIANGLE_H_INCLUDED__
|
#ifndef __CONVERT_MESHTRIANGLE_H_INCLUDED__
|
||||||
#define __CONVERT_MESHTRIANGLE_H_INCLUDED__
|
#define __CONVERT_MESHTRIANGLE_H_INCLUDED__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct MeshTriangle
|
struct MeshTriangle
|
||||||
{
|
{
|
||||||
uint32_t vertices[3];
|
uint32_t vertices[3];
|
||||||
uint32_t subMesh;
|
uint32_t subMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,321 +1,321 @@
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void WriteMeshHeader(FILE *fp)
|
void WriteMeshHeader(FILE *fp)
|
||||||
{
|
{
|
||||||
fputs("MESH", fp);
|
fputs("MESH", fp);
|
||||||
uint8_t version = 1;
|
uint8_t version = 1;
|
||||||
fwrite(&version, 1, 1, fp);
|
fwrite(&version, 1, 1, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteVertices(const AssimpVertices &vertices, FILE *fp)
|
void WriteVertices(const AssimpVertices &vertices, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = vertices.size();
|
uint32_t count = vertices.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size =
|
uint32_t size =
|
||||||
(sizeof(float) * 3) * // x y, z
|
(sizeof(float) * 3) * // x y, z
|
||||||
vertices.size()
|
vertices.size()
|
||||||
+ 4; // chunk size
|
+ 4; // chunk size
|
||||||
|
|
||||||
fputs("VTX", fp);
|
fputs("VTX", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
fwrite(&vertices[i].x, sizeof(float), 1, fp);
|
fwrite(&vertices[i].x, sizeof(float), 1, fp);
|
||||||
fwrite(&vertices[i].y, sizeof(float), 1, fp);
|
fwrite(&vertices[i].y, sizeof(float), 1, fp);
|
||||||
fwrite(&vertices[i].z, sizeof(float), 1, fp);
|
fwrite(&vertices[i].z, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteNormals(const AssimpVertices &normals, FILE *fp)
|
void WriteNormals(const AssimpVertices &normals, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = normals.size();
|
uint32_t count = normals.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size =
|
uint32_t size =
|
||||||
(sizeof(float) * 3) * // x y, z
|
(sizeof(float) * 3) * // x y, z
|
||||||
normals.size()
|
normals.size()
|
||||||
+ 4; // chunk size
|
+ 4; // chunk size
|
||||||
|
|
||||||
fputs("NRL", fp);
|
fputs("NRL", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
fwrite(&normals[i].x, sizeof(float), 1, fp);
|
fwrite(&normals[i].x, sizeof(float), 1, fp);
|
||||||
fwrite(&normals[i].y, sizeof(float), 1, fp);
|
fwrite(&normals[i].y, sizeof(float), 1, fp);
|
||||||
fwrite(&normals[i].z, sizeof(float), 1, fp);
|
fwrite(&normals[i].z, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteTexCoords(const AssimpVertices &texCoords, FILE *fp)
|
void WriteTexCoords(const AssimpVertices &texCoords, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = texCoords.size();
|
uint32_t count = texCoords.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size =
|
uint32_t size =
|
||||||
(sizeof(float) * 2) * // u, v
|
(sizeof(float) * 2) * // u, v
|
||||||
texCoords.size()
|
texCoords.size()
|
||||||
+ 4; // count
|
+ 4; // count
|
||||||
|
|
||||||
fputs("TXT", fp);
|
fputs("TXT", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
fwrite(&texCoords[i].x, sizeof(float), 1, fp);
|
fwrite(&texCoords[i].x, sizeof(float), 1, fp);
|
||||||
fwrite(&texCoords[i].y, sizeof(float), 1, fp);
|
fwrite(&texCoords[i].y, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteMaterials(const std::vector<MeshMaterial> &materials, FILE *fp)
|
void WriteMaterials(const std::vector<MeshMaterial> &materials, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = materials.size();
|
uint32_t count = materials.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size = 4 + // count
|
uint32_t size = 4 + // count
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
(sizeof(float) * 3) + // ambient
|
(sizeof(float) * 3) + // ambient
|
||||||
(sizeof(float) * 3) + // diffuse
|
(sizeof(float) * 3) + // diffuse
|
||||||
(sizeof(float) * 3) + // specular
|
(sizeof(float) * 3) + // specular
|
||||||
(sizeof(float) * 3) + // emissive
|
(sizeof(float) * 3) + // emissive
|
||||||
sizeof(float) + // shininess
|
sizeof(float) + // shininess
|
||||||
sizeof(float) // opacity
|
sizeof(float) // opacity
|
||||||
) * count
|
) * count
|
||||||
);
|
);
|
||||||
|
|
||||||
// add up all the variable length string sizes for the material names and texture filenames
|
// add up all the variable length string sizes for the material names and texture filenames
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
size += materials[i].name.length() + 1; // include null terminator
|
size += materials[i].name.length() + 1; // include null terminator
|
||||||
size += materials[i].texture.length() + 1; // ditto
|
size += materials[i].texture.length() + 1; // ditto
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs("MTL", fp);
|
fputs("MTL", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const MeshMaterial *m = &materials[i];
|
const MeshMaterial *m = &materials[i];
|
||||||
|
|
||||||
fwrite(m->name.c_str(), m->name.length(), 1, fp);
|
fwrite(m->name.c_str(), m->name.length(), 1, fp);
|
||||||
char ch = '\0';
|
char ch = '\0';
|
||||||
fwrite(&ch, 1, 1, fp);
|
fwrite(&ch, 1, 1, fp);
|
||||||
|
|
||||||
fwrite(m->texture.c_str(), m->texture.length(), 1, fp);
|
fwrite(m->texture.c_str(), m->texture.length(), 1, fp);
|
||||||
fwrite(&ch, 1, 1, fp);
|
fwrite(&ch, 1, 1, fp);
|
||||||
|
|
||||||
fwrite(&m->ambient[0], sizeof(float), 1, fp);
|
fwrite(&m->ambient[0], sizeof(float), 1, fp);
|
||||||
fwrite(&m->ambient[1], sizeof(float), 1, fp);
|
fwrite(&m->ambient[1], sizeof(float), 1, fp);
|
||||||
fwrite(&m->ambient[2], sizeof(float), 1, fp);
|
fwrite(&m->ambient[2], sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&m->diffuse[0], sizeof(float), 1, fp);
|
fwrite(&m->diffuse[0], sizeof(float), 1, fp);
|
||||||
fwrite(&m->diffuse[1], sizeof(float), 1, fp);
|
fwrite(&m->diffuse[1], sizeof(float), 1, fp);
|
||||||
fwrite(&m->diffuse[2], sizeof(float), 1, fp);
|
fwrite(&m->diffuse[2], sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&m->specular[0], sizeof(float), 1, fp);
|
fwrite(&m->specular[0], sizeof(float), 1, fp);
|
||||||
fwrite(&m->specular[1], sizeof(float), 1, fp);
|
fwrite(&m->specular[1], sizeof(float), 1, fp);
|
||||||
fwrite(&m->specular[2], sizeof(float), 1, fp);
|
fwrite(&m->specular[2], sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&m->emissive[0], sizeof(float), 1, fp);
|
fwrite(&m->emissive[0], sizeof(float), 1, fp);
|
||||||
fwrite(&m->emissive[1], sizeof(float), 1, fp);
|
fwrite(&m->emissive[1], sizeof(float), 1, fp);
|
||||||
fwrite(&m->emissive[2], sizeof(float), 1, fp);
|
fwrite(&m->emissive[2], sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&m->shininess, sizeof(float), 1, fp);
|
fwrite(&m->shininess, sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&m->opacity, sizeof(float), 1, fp);
|
fwrite(&m->opacity, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteTriangles(const std::vector<MeshTriangle> &triangles, FILE *fp)
|
void WriteTriangles(const std::vector<MeshTriangle> &triangles, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = triangles.size();
|
uint32_t count = triangles.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size = 4; // count
|
uint32_t size = 4; // count
|
||||||
size +=
|
size +=
|
||||||
(
|
(
|
||||||
(4 * 3) // vertex indices
|
(4 * 3) // vertex indices
|
||||||
+ 4 // material index
|
+ 4 // material index
|
||||||
) * count;
|
) * count;
|
||||||
|
|
||||||
fputs("TRI", fp);
|
fputs("TRI", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const MeshTriangle *t = &triangles[i];
|
const MeshTriangle *t = &triangles[i];
|
||||||
|
|
||||||
fwrite(&t->vertices[0], 4, 1, fp);
|
fwrite(&t->vertices[0], 4, 1, fp);
|
||||||
fwrite(&t->vertices[1], 4, 1, fp);
|
fwrite(&t->vertices[1], 4, 1, fp);
|
||||||
fwrite(&t->vertices[2], 4, 1, fp);
|
fwrite(&t->vertices[2], 4, 1, fp);
|
||||||
|
|
||||||
fwrite(&t->subMesh, 4, 1, fp);
|
fwrite(&t->subMesh, 4, 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteSubMeshes(const std::vector<SubMesh> &subMeshes, FILE *fp)
|
void WriteSubMeshes(const std::vector<SubMesh> &subMeshes, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = subMeshes.size();
|
uint32_t count = subMeshes.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size = 4 + // count
|
uint32_t size = 4 + // count
|
||||||
4 + // material index
|
4 + // material index
|
||||||
4; // count of triangles
|
4; // count of triangles
|
||||||
|
|
||||||
// add up all the variable length string sizes for the submesh names
|
// add up all the variable length string sizes for the submesh names
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
size += subMeshes[i].name.length() + 1; // include null terminator
|
size += subMeshes[i].name.length() + 1; // include null terminator
|
||||||
|
|
||||||
fputs("GRP", fp);
|
fputs("GRP", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const SubMesh *m = &subMeshes[i];
|
const SubMesh *m = &subMeshes[i];
|
||||||
|
|
||||||
fwrite(m->name.c_str(), m->name.length(), 1, fp);
|
fwrite(m->name.c_str(), m->name.length(), 1, fp);
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
fwrite(&c, 1, 1, fp);
|
fwrite(&c, 1, 1, fp);
|
||||||
|
|
||||||
fwrite(&m->material, 4, 1, fp);
|
fwrite(&m->material, 4, 1, fp);
|
||||||
fwrite(&m->numTriangles, 4, 1, fp);
|
fwrite(&m->numTriangles, 4, 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteJoints(const std::vector<MeshJoint> &joints, FILE *fp)
|
void WriteJoints(const std::vector<MeshJoint> &joints, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = joints.size();
|
uint32_t count = joints.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size = 4 + // count
|
uint32_t size = 4 + // count
|
||||||
(
|
(
|
||||||
4 + // parent joint index
|
4 + // parent joint index
|
||||||
(sizeof(float) * 3) + // local position (x, y, z)
|
(sizeof(float) * 3) + // local position (x, y, z)
|
||||||
(sizeof(float) * 4) + // local rotation (x, y, z, w)
|
(sizeof(float) * 4) + // local rotation (x, y, z, w)
|
||||||
(sizeof(float) * 3) + // offset position (x, y, z)
|
(sizeof(float) * 3) + // offset position (x, y, z)
|
||||||
(sizeof(float) * 4) // offset rotation (x, y, z, w)
|
(sizeof(float) * 4) // offset rotation (x, y, z, w)
|
||||||
) * count;
|
) * count;
|
||||||
|
|
||||||
// add up all the variable length joint names
|
// add up all the variable length joint names
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
size += joints[i].name.length() + 1; // include null terminator
|
size += joints[i].name.length() + 1; // include null terminator
|
||||||
|
|
||||||
fputs("JNT", fp);
|
fputs("JNT", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const MeshJoint *j = &joints[i];
|
const MeshJoint *j = &joints[i];
|
||||||
|
|
||||||
fwrite(j->name.c_str(), j->name.length(), 1, fp);
|
fwrite(j->name.c_str(), j->name.length(), 1, fp);
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
fwrite(&c, 1, 1, fp);
|
fwrite(&c, 1, 1, fp);
|
||||||
|
|
||||||
int32_t parentIndex = GetIndexOf(joints, j->parentName);
|
int32_t parentIndex = GetIndexOf(joints, j->parentName);
|
||||||
fwrite(&parentIndex, 4, 1, fp);
|
fwrite(&parentIndex, 4, 1, fp);
|
||||||
|
|
||||||
fwrite(&j->localPosition.x, sizeof(float), 1, fp);
|
fwrite(&j->localPosition.x, sizeof(float), 1, fp);
|
||||||
fwrite(&j->localPosition.y, sizeof(float), 1, fp);
|
fwrite(&j->localPosition.y, sizeof(float), 1, fp);
|
||||||
fwrite(&j->localPosition.z, sizeof(float), 1, fp);
|
fwrite(&j->localPosition.z, sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&j->localRotation.x, sizeof(float), 1, fp);
|
fwrite(&j->localRotation.x, sizeof(float), 1, fp);
|
||||||
fwrite(&j->localRotation.y, sizeof(float), 1, fp);
|
fwrite(&j->localRotation.y, sizeof(float), 1, fp);
|
||||||
fwrite(&j->localRotation.z, sizeof(float), 1, fp);
|
fwrite(&j->localRotation.z, sizeof(float), 1, fp);
|
||||||
fwrite(&j->localRotation.w, sizeof(float), 1, fp);
|
fwrite(&j->localRotation.w, sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&j->offsetPosition.x, sizeof(float), 1, fp);
|
fwrite(&j->offsetPosition.x, sizeof(float), 1, fp);
|
||||||
fwrite(&j->offsetPosition.y, sizeof(float), 1, fp);
|
fwrite(&j->offsetPosition.y, sizeof(float), 1, fp);
|
||||||
fwrite(&j->offsetPosition.z, sizeof(float), 1, fp);
|
fwrite(&j->offsetPosition.z, sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&j->offsetRotation.x, sizeof(float), 1, fp);
|
fwrite(&j->offsetRotation.x, sizeof(float), 1, fp);
|
||||||
fwrite(&j->offsetRotation.y, sizeof(float), 1, fp);
|
fwrite(&j->offsetRotation.y, sizeof(float), 1, fp);
|
||||||
fwrite(&j->offsetRotation.z, sizeof(float), 1, fp);
|
fwrite(&j->offsetRotation.z, sizeof(float), 1, fp);
|
||||||
fwrite(&j->offsetRotation.w, sizeof(float), 1, fp);
|
fwrite(&j->offsetRotation.w, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteJointToVertexMap(const std::vector<uint32_t> &vertexToJointMap, FILE *fp)
|
void WriteJointToVertexMap(const std::vector<uint32_t> &vertexToJointMap, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t count = vertexToJointMap.size();
|
uint32_t count = vertexToJointMap.size();
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t size = 4 + // count
|
uint32_t size = 4 + // count
|
||||||
(4 * count); // num vertices
|
(4 * count); // num vertices
|
||||||
|
|
||||||
fputs("JTV", fp);
|
fputs("JTV", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&count, 4, 1, fp);
|
fwrite(&count, 4, 1, fp);
|
||||||
for (uint32_t i = 0; i < count; ++i)
|
for (uint32_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
uint32_t jointIndex = vertexToJointMap[i];
|
uint32_t jointIndex = vertexToJointMap[i];
|
||||||
fwrite(&jointIndex, 4, 1, fp);
|
fwrite(&jointIndex, 4, 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteJointKeyFrames(const std::vector<JointKeyFrames> &jointKeyFrames, FILE *fp)
|
void WriteJointKeyFrames(const std::vector<JointKeyFrames> &jointKeyFrames, FILE *fp)
|
||||||
{
|
{
|
||||||
uint32_t numJoints = jointKeyFrames.size();
|
uint32_t numJoints = jointKeyFrames.size();
|
||||||
if (numJoints == 0)
|
if (numJoints == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32_t numFrames = jointKeyFrames[0].size();
|
uint32_t numFrames = jointKeyFrames[0].size();
|
||||||
|
|
||||||
uint32_t size = 4 + // num frames
|
uint32_t size = 4 + // num frames
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
(sizeof(float) * 3) + // position (x, y, z)
|
(sizeof(float) * 3) + // position (x, y, z)
|
||||||
(sizeof(float) * 4) // rotation (x, y, z, w)
|
(sizeof(float) * 4) // rotation (x, y, z, w)
|
||||||
) * numJoints // for each joint
|
) * numJoints // for each joint
|
||||||
) * numFrames; // for each frame
|
) * numFrames; // for each frame
|
||||||
|
|
||||||
fputs("JKF", fp);
|
fputs("JKF", fp);
|
||||||
fwrite(&size, 4, 1, fp);
|
fwrite(&size, 4, 1, fp);
|
||||||
fwrite(&numFrames, 4, 1, fp);
|
fwrite(&numFrames, 4, 1, fp);
|
||||||
for (uint32_t i = 0; i < numJoints; ++i)
|
for (uint32_t i = 0; i < numJoints; ++i)
|
||||||
{
|
{
|
||||||
for (uint32_t j = 0; j < numFrames; ++j)
|
for (uint32_t j = 0; j < numFrames; ++j)
|
||||||
{
|
{
|
||||||
const MeshJointKeyFrame *frame = &jointKeyFrames[i][j];
|
const MeshJointKeyFrame *frame = &jointKeyFrames[i][j];
|
||||||
|
|
||||||
fwrite(&frame->position.x, sizeof(float), 1, fp);
|
fwrite(&frame->position.x, sizeof(float), 1, fp);
|
||||||
fwrite(&frame->position.y, sizeof(float), 1, fp);
|
fwrite(&frame->position.y, sizeof(float), 1, fp);
|
||||||
fwrite(&frame->position.z, sizeof(float), 1, fp);
|
fwrite(&frame->position.z, sizeof(float), 1, fp);
|
||||||
|
|
||||||
fwrite(&frame->rotation.x, sizeof(float), 1, fp);
|
fwrite(&frame->rotation.x, sizeof(float), 1, fp);
|
||||||
fwrite(&frame->rotation.y, sizeof(float), 1, fp);
|
fwrite(&frame->rotation.y, sizeof(float), 1, fp);
|
||||||
fwrite(&frame->rotation.z, sizeof(float), 1, fp);
|
fwrite(&frame->rotation.z, sizeof(float), 1, fp);
|
||||||
fwrite(&frame->rotation.w, sizeof(float), 1, fp);
|
fwrite(&frame->rotation.w, sizeof(float), 1, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t GetIndexOf(const std::vector<MeshJoint> &joints, const std::string &name)
|
int32_t GetIndexOf(const std::vector<MeshJoint> &joints, const std::string &name)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < joints.size(); ++i)
|
for (uint32_t i = 0; i < joints.size(); ++i)
|
||||||
{
|
{
|
||||||
if (joints[i].name == name)
|
if (joints[i].name == name)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,147 +1,147 @@
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "../assimputils/utils.h"
|
#include "../assimputils/utils.h"
|
||||||
|
|
||||||
void ConvertSkeletalAnimated(const std::string &outfile, const aiScene *scene)
|
void ConvertSkeletalAnimated(const std::string &outfile, const aiScene *scene)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(outfile.c_str(), "wb");
|
FILE *fp = fopen(outfile.c_str(), "wb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
throw std::exception("Error creating output file.");
|
throw std::exception("Error creating output file.");
|
||||||
|
|
||||||
WriteMeshHeader(fp);
|
WriteMeshHeader(fp);
|
||||||
|
|
||||||
// basic mesh info
|
// basic mesh info
|
||||||
AssimpVertices vertices;
|
AssimpVertices vertices;
|
||||||
AssimpVertices normals;
|
AssimpVertices normals;
|
||||||
AssimpVertices texCoords;
|
AssimpVertices texCoords;
|
||||||
AssimpVerticesMap vertexIndicesMap;
|
AssimpVerticesMap vertexIndicesMap;
|
||||||
CollectAllMeshVertices(scene, vertices, normals, texCoords, vertexIndicesMap);
|
CollectAllMeshVertices(scene, vertices, normals, texCoords, vertexIndicesMap);
|
||||||
WriteVertices(vertices, fp);
|
WriteVertices(vertices, fp);
|
||||||
WriteNormals(normals, fp);
|
WriteNormals(normals, fp);
|
||||||
WriteTexCoords(texCoords, fp);
|
WriteTexCoords(texCoords, fp);
|
||||||
|
|
||||||
// materials
|
// materials
|
||||||
std::vector<MeshMaterial> materials;
|
std::vector<MeshMaterial> materials;
|
||||||
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
||||||
{
|
{
|
||||||
MeshMaterial material = MeshMaterial(scene->mMaterials[i]);
|
MeshMaterial material = MeshMaterial(scene->mMaterials[i]);
|
||||||
materials.push_back(material);
|
materials.push_back(material);
|
||||||
}
|
}
|
||||||
WriteMaterials(materials, fp);
|
WriteMaterials(materials, fp);
|
||||||
|
|
||||||
// triangles
|
// triangles
|
||||||
std::vector<MeshTriangle> triangles;
|
std::vector<MeshTriangle> triangles;
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
for (unsigned int j = 0; j < mesh->mNumFaces; ++j)
|
for (unsigned int j = 0; j < mesh->mNumFaces; ++j)
|
||||||
{
|
{
|
||||||
aiFace *face = &mesh->mFaces[j];
|
aiFace *face = &mesh->mFaces[j];
|
||||||
|
|
||||||
MeshTriangle triangle;
|
MeshTriangle triangle;
|
||||||
triangle.vertices[0] = vertexIndicesMap[i][face->mIndices[0]];
|
triangle.vertices[0] = vertexIndicesMap[i][face->mIndices[0]];
|
||||||
triangle.vertices[1] = vertexIndicesMap[i][face->mIndices[1]];
|
triangle.vertices[1] = vertexIndicesMap[i][face->mIndices[1]];
|
||||||
triangle.vertices[2] = vertexIndicesMap[i][face->mIndices[2]];
|
triangle.vertices[2] = vertexIndicesMap[i][face->mIndices[2]];
|
||||||
triangle.subMesh = i;
|
triangle.subMesh = i;
|
||||||
|
|
||||||
triangles.push_back(triangle);
|
triangles.push_back(triangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteTriangles(triangles, fp);
|
WriteTriangles(triangles, fp);
|
||||||
|
|
||||||
// sub meshes
|
// sub meshes
|
||||||
std::vector<SubMesh> subMeshes;
|
std::vector<SubMesh> subMeshes;
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
SubMesh subMesh;
|
SubMesh subMesh;
|
||||||
|
|
||||||
subMesh.name = std::string(mesh->mName.data, mesh->mName.length);
|
subMesh.name = std::string(mesh->mName.data, mesh->mName.length);
|
||||||
subMesh.material = mesh->mMaterialIndex;
|
subMesh.material = mesh->mMaterialIndex;
|
||||||
subMesh.numTriangles = mesh->mNumFaces;
|
subMesh.numTriangles = mesh->mNumFaces;
|
||||||
|
|
||||||
subMeshes.push_back(subMesh);
|
subMeshes.push_back(subMesh);
|
||||||
}
|
}
|
||||||
WriteSubMeshes(subMeshes, fp);
|
WriteSubMeshes(subMeshes, fp);
|
||||||
|
|
||||||
// TODO: cheating for now, but according to the ASSIMP doc's, there could be
|
// TODO: cheating for now, but according to the ASSIMP doc's, there could be
|
||||||
// models which have nodes that are not used by any bones, but still
|
// models which have nodes that are not used by any bones, but still
|
||||||
// affect the skeleton pose, because child nodes *are* used by bones
|
// affect the skeleton pose, because child nodes *are* used by bones
|
||||||
// and so, any parent node transformations will apply and need to be
|
// and so, any parent node transformations will apply and need to be
|
||||||
// carried down the chain. None of the test models I'm using have this
|
// carried down the chain. None of the test models I'm using have this
|
||||||
// type of node structure, so I'm ignoring it for now :)
|
// type of node structure, so I'm ignoring it for now :)
|
||||||
|
|
||||||
// collect basic skeleton/joint info
|
// collect basic skeleton/joint info
|
||||||
std::vector<MeshJoint> joints;
|
std::vector<MeshJoint> joints;
|
||||||
std::vector<uint32_t> vertexToJointMap;
|
std::vector<uint32_t> vertexToJointMap;
|
||||||
vertexToJointMap.resize(vertices.size());
|
vertexToJointMap.resize(vertices.size());
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
for (unsigned int j = 0; j < mesh->mNumBones; ++j)
|
for (unsigned int j = 0; j < mesh->mNumBones; ++j)
|
||||||
{
|
{
|
||||||
aiBone *bone = mesh->mBones[j];
|
aiBone *bone = mesh->mBones[j];
|
||||||
aiNode *node = scene->mRootNode->FindNode(bone->mName);
|
aiNode *node = scene->mRootNode->FindNode(bone->mName);
|
||||||
aiNode *parentNode = node->mParent;
|
aiNode *parentNode = node->mParent;
|
||||||
|
|
||||||
MeshJoint joint;
|
MeshJoint joint;
|
||||||
joint.name = std::string(bone->mName.data, bone->mName.length);
|
joint.name = std::string(bone->mName.data, bone->mName.length);
|
||||||
if (strcmp(parentNode->mName.data, "$dummy_root") == 0)
|
if (strcmp(parentNode->mName.data, "$dummy_root") == 0)
|
||||||
joint.parentName = "";
|
joint.parentName = "";
|
||||||
else
|
else
|
||||||
joint.parentName = std::string(parentNode->mName.data, parentNode->mName.length);
|
joint.parentName = std::string(parentNode->mName.data, parentNode->mName.length);
|
||||||
|
|
||||||
aiMatrix4x4 transform = node->mTransformation * bone->mOffsetMatrix;
|
aiMatrix4x4 transform = node->mTransformation * bone->mOffsetMatrix;
|
||||||
node->mTransformation.DecomposeNoScaling(joint.localRotation, joint.localPosition);
|
node->mTransformation.DecomposeNoScaling(joint.localRotation, joint.localPosition);
|
||||||
bone->mOffsetMatrix.DecomposeNoScaling(joint.offsetRotation, joint.offsetPosition);
|
bone->mOffsetMatrix.DecomposeNoScaling(joint.offsetRotation, joint.offsetPosition);
|
||||||
|
|
||||||
// assumption: sum of all bone->mNumWeights is always == vertices.size()
|
// assumption: sum of all bone->mNumWeights is always == vertices.size()
|
||||||
for (unsigned int k = 0; k < bone->mNumWeights; ++k)
|
for (unsigned int k = 0; k < bone->mNumWeights; ++k)
|
||||||
{
|
{
|
||||||
aiVertexWeight *weight = &bone->mWeights[k];
|
aiVertexWeight *weight = &bone->mWeights[k];
|
||||||
unsigned int index = vertexIndicesMap[i][weight->mVertexId];
|
unsigned int index = vertexIndicesMap[i][weight->mVertexId];
|
||||||
vertexToJointMap[index] = j;
|
vertexToJointMap[index] = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
joints.push_back(joint);
|
joints.push_back(joint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteJoints(joints, fp);
|
WriteJoints(joints, fp);
|
||||||
WriteJointToVertexMap(vertexToJointMap, fp);
|
WriteJointToVertexMap(vertexToJointMap, fp);
|
||||||
|
|
||||||
// TODO: this collection process is dumb at the moment. assumes each bone
|
// TODO: this collection process is dumb at the moment. assumes each bone
|
||||||
// has the same number of frames as all the other ones. also, every
|
// has the same number of frames as all the other ones. also, every
|
||||||
// test model i've used so far puts all the frames into a single
|
// test model i've used so far puts all the frames into a single
|
||||||
// animation (usually without a name even). so this is, for now, only
|
// animation (usually without a name even). so this is, for now, only
|
||||||
// looking at the first aiAnimation object. ALSO, because i'm REALLY
|
// looking at the first aiAnimation object. ALSO, because i'm REALLY
|
||||||
// lazy, the animations aiNodeAnim objects are assumed to be in the
|
// lazy, the animations aiNodeAnim objects are assumed to be in the
|
||||||
// same order as the bones were collected in :)
|
// same order as the bones were collected in :)
|
||||||
// collect joint keyframes
|
// collect joint keyframes
|
||||||
std::vector<JointKeyFrames> meshFrames;
|
std::vector<JointKeyFrames> meshFrames;
|
||||||
aiAnimation *animation = scene->mAnimations[0];
|
aiAnimation *animation = scene->mAnimations[0];
|
||||||
for (unsigned int i = 0; i < animation->mNumChannels; ++i)
|
for (unsigned int i = 0; i < animation->mNumChannels; ++i)
|
||||||
{
|
{
|
||||||
aiNodeAnim *nodeAnim = animation->mChannels[i];
|
aiNodeAnim *nodeAnim = animation->mChannels[i];
|
||||||
JointKeyFrames jointFrames;
|
JointKeyFrames jointFrames;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < nodeAnim->mNumPositionKeys; ++j)
|
for (unsigned int j = 0; j < nodeAnim->mNumPositionKeys; ++j)
|
||||||
{
|
{
|
||||||
// TODO: should really get the times too
|
// TODO: should really get the times too
|
||||||
MeshJointKeyFrame frame;
|
MeshJointKeyFrame frame;
|
||||||
frame.position = nodeAnim->mPositionKeys[j].mValue;
|
frame.position = nodeAnim->mPositionKeys[j].mValue;
|
||||||
frame.rotation = nodeAnim->mRotationKeys[j].mValue;
|
frame.rotation = nodeAnim->mRotationKeys[j].mValue;
|
||||||
|
|
||||||
jointFrames.push_back(frame);
|
jointFrames.push_back(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
meshFrames.push_back(jointFrames);
|
meshFrames.push_back(jointFrames);
|
||||||
}
|
}
|
||||||
WriteJointKeyFrames(meshFrames, fp);
|
WriteJointKeyFrames(meshFrames, fp);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
#include "convert.h"
|
#include "convert.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "../assimputils/utils.h"
|
#include "../assimputils/utils.h"
|
||||||
|
|
||||||
void ConvertStatic(const std::string &outfile, const aiScene *scene)
|
void ConvertStatic(const std::string &outfile, const aiScene *scene)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(outfile.c_str(), "wb");
|
FILE *fp = fopen(outfile.c_str(), "wb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
throw std::exception("Error creating output file.");
|
throw std::exception("Error creating output file.");
|
||||||
|
|
||||||
WriteMeshHeader(fp);
|
WriteMeshHeader(fp);
|
||||||
|
|
||||||
// basic mesh info
|
// basic mesh info
|
||||||
AssimpVertices vertices;
|
AssimpVertices vertices;
|
||||||
AssimpVertices normals;
|
AssimpVertices normals;
|
||||||
AssimpVertices texCoords;
|
AssimpVertices texCoords;
|
||||||
AssimpVerticesMap vertexIndicesMap;
|
AssimpVerticesMap vertexIndicesMap;
|
||||||
CollectAllMeshVertices(scene, vertices, normals, texCoords, vertexIndicesMap);
|
CollectAllMeshVertices(scene, vertices, normals, texCoords, vertexIndicesMap);
|
||||||
WriteVertices(vertices, fp);
|
WriteVertices(vertices, fp);
|
||||||
WriteNormals(normals, fp);
|
WriteNormals(normals, fp);
|
||||||
WriteTexCoords(texCoords, fp);
|
WriteTexCoords(texCoords, fp);
|
||||||
|
|
||||||
// materials
|
// materials
|
||||||
std::vector<MeshMaterial> materials;
|
std::vector<MeshMaterial> materials;
|
||||||
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
||||||
{
|
{
|
||||||
MeshMaterial material = MeshMaterial(scene->mMaterials[i]);
|
MeshMaterial material = MeshMaterial(scene->mMaterials[i]);
|
||||||
materials.push_back(material);
|
materials.push_back(material);
|
||||||
}
|
}
|
||||||
WriteMaterials(materials, fp);
|
WriteMaterials(materials, fp);
|
||||||
|
|
||||||
// triangles
|
// triangles
|
||||||
std::vector<MeshTriangle> triangles;
|
std::vector<MeshTriangle> triangles;
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
for (unsigned int j = 0; j < mesh->mNumFaces; ++j)
|
for (unsigned int j = 0; j < mesh->mNumFaces; ++j)
|
||||||
{
|
{
|
||||||
aiFace *face = &mesh->mFaces[j];
|
aiFace *face = &mesh->mFaces[j];
|
||||||
|
|
||||||
MeshTriangle triangle;
|
MeshTriangle triangle;
|
||||||
triangle.vertices[0] = vertexIndicesMap[i][face->mIndices[0]];
|
triangle.vertices[0] = vertexIndicesMap[i][face->mIndices[0]];
|
||||||
triangle.vertices[1] = vertexIndicesMap[i][face->mIndices[1]];
|
triangle.vertices[1] = vertexIndicesMap[i][face->mIndices[1]];
|
||||||
triangle.vertices[2] = vertexIndicesMap[i][face->mIndices[2]];
|
triangle.vertices[2] = vertexIndicesMap[i][face->mIndices[2]];
|
||||||
triangle.subMesh = i;
|
triangle.subMesh = i;
|
||||||
|
|
||||||
triangles.push_back(triangle);
|
triangles.push_back(triangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WriteTriangles(triangles, fp);
|
WriteTriangles(triangles, fp);
|
||||||
|
|
||||||
// sub meshes
|
// sub meshes
|
||||||
std::vector<SubMesh> subMeshes;
|
std::vector<SubMesh> subMeshes;
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
aiMesh *mesh = scene->mMeshes[i];
|
aiMesh *mesh = scene->mMeshes[i];
|
||||||
SubMesh subMesh;
|
SubMesh subMesh;
|
||||||
|
|
||||||
subMesh.name = std::string(mesh->mName.data, mesh->mName.length);
|
subMesh.name = std::string(mesh->mName.data, mesh->mName.length);
|
||||||
subMesh.material = mesh->mMaterialIndex;
|
subMesh.material = mesh->mMaterialIndex;
|
||||||
subMesh.numTriangles = mesh->mNumFaces;
|
subMesh.numTriangles = mesh->mNumFaces;
|
||||||
|
|
||||||
subMeshes.push_back(subMesh);
|
subMeshes.push_back(subMesh);
|
||||||
}
|
}
|
||||||
WriteSubMeshes(subMeshes, fp);
|
WriteSubMeshes(subMeshes, fp);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef __CONVERT_SUBMESH_H_INCLUDED__
|
#ifndef __CONVERT_SUBMESH_H_INCLUDED__
|
||||||
#define __CONVERT_SUBMESH_H_INCLUDED__
|
#define __CONVERT_SUBMESH_H_INCLUDED__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct SubMesh
|
struct SubMesh
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
uint32_t material;
|
uint32_t material;
|
||||||
uint32_t numTriangles;
|
uint32_t numTriangles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,142 +1,142 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#include <assimp.hpp>
|
#include <assimp.hpp>
|
||||||
#include <aiScene.h>
|
#include <aiScene.h>
|
||||||
#include <aiPostProcess.h>
|
#include <aiPostProcess.h>
|
||||||
|
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "assimputils/utils.h"
|
#include "assimputils/utils.h"
|
||||||
#include "convert/convert.h"
|
#include "convert/convert.h"
|
||||||
#include "nodetree/nodetree.h"
|
#include "nodetree/nodetree.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("ASSIMP-to-MESH Converter.\n");
|
printf("ASSIMP-to-MESH Converter.\n");
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
printf("Usage: assimptomesh.exe [--describe=txtfile] [--out=outputfile] inputfile\n\n");
|
printf("Usage: assimptomesh.exe [--describe=txtfile] [--out=outputfile] inputfile\n\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// input file is always the last argument
|
// input file is always the last argument
|
||||||
std::string file = argv[argc - 1];
|
std::string file = argv[argc - 1];
|
||||||
|
|
||||||
std::string outputFile;
|
std::string outputFile;
|
||||||
std::string describeFile;
|
std::string describeFile;
|
||||||
|
|
||||||
// find any options
|
// find any options
|
||||||
for (int i = 1; i < argc - 1; ++i)
|
for (int i = 1; i < argc - 1; ++i)
|
||||||
{
|
{
|
||||||
std::string arg = argv[i];
|
std::string arg = argv[i];
|
||||||
|
|
||||||
if (arg.substr(0, 11) == "--describe=")
|
if (arg.substr(0, 11) == "--describe=")
|
||||||
{
|
{
|
||||||
if (arg.length() == 11)
|
if (arg.length() == 11)
|
||||||
{
|
{
|
||||||
printf("Missing description output filename.\n");
|
printf("Missing description output filename.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
describeFile = arg.substr(11);
|
describeFile = arg.substr(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (arg.substr(0, 6) == "--out=")
|
else if (arg.substr(0, 6) == "--out=")
|
||||||
{
|
{
|
||||||
if (arg.length() == 6)
|
if (arg.length() == 6)
|
||||||
{
|
{
|
||||||
printf("Missing output filename.\n");
|
printf("Missing output filename.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
outputFile = arg.substr(6);
|
outputFile = arg.substr(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt to load the input file
|
// attempt to load the input file
|
||||||
printf("Input file: %s\n", file.c_str());
|
printf("Input file: %s\n", file.c_str());
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(file,
|
const aiScene *scene = importer.ReadFile(file,
|
||||||
aiProcess_JoinIdenticalVertices |
|
aiProcess_JoinIdenticalVertices |
|
||||||
aiProcess_GenSmoothNormals |
|
aiProcess_GenSmoothNormals |
|
||||||
aiProcess_Triangulate |
|
aiProcess_Triangulate |
|
||||||
aiProcess_RemoveRedundantMaterials |
|
aiProcess_RemoveRedundantMaterials |
|
||||||
aiProcess_SortByPType |
|
aiProcess_SortByPType |
|
||||||
aiProcess_OptimizeMeshes |
|
aiProcess_OptimizeMeshes |
|
||||||
aiProcess_OptimizeGraph |
|
aiProcess_OptimizeGraph |
|
||||||
aiProcess_GenUVCoords |
|
aiProcess_GenUVCoords |
|
||||||
aiProcess_TransformUVCoords |
|
aiProcess_TransformUVCoords |
|
||||||
aiProcess_FlipUVs |
|
aiProcess_FlipUVs |
|
||||||
aiProcess_FindInvalidData
|
aiProcess_FindInvalidData
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!scene)
|
if (!scene)
|
||||||
{
|
{
|
||||||
printf("Failed to load input file: %s\n\n", importer.GetErrorString());
|
printf("Failed to load input file: %s\n\n", importer.GetErrorString());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Scene loaded.\n");
|
printf("Scene loaded.\n");
|
||||||
|
|
||||||
// input file loaded, now get the output filename (if not provided via command line)
|
// input file loaded, now get the output filename (if not provided via command line)
|
||||||
if (outputFile.length() == 0)
|
if (outputFile.length() == 0)
|
||||||
{
|
{
|
||||||
outputFile = GetMeshFilenameFromInput(file);
|
outputFile = GetMeshFilenameFromInput(file);
|
||||||
if (outputFile.length() == 0)
|
if (outputFile.length() == 0)
|
||||||
{
|
{
|
||||||
printf("Unable to determine output mesh filename from the input file name.\n\n");
|
printf("Unable to determine output mesh filename from the input file name.\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Output file: %s\n", outputFile.c_str());
|
printf("Output file: %s\n", outputFile.c_str());
|
||||||
|
|
||||||
// optionally show info about the entire scene before doing the conversion
|
// optionally show info about the entire scene before doing the conversion
|
||||||
if (describeFile.length() > 0)
|
if (describeFile.length() > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Walk(scene, describeFile);
|
Walk(scene, describeFile);
|
||||||
}
|
}
|
||||||
catch (std::exception &ex)
|
catch (std::exception &ex)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", ex.what());
|
printf("Error: %s\n", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt conversion using an appropriate converter based on what kind of scene it is
|
// attempt conversion using an appropriate converter based on what kind of scene it is
|
||||||
if (IsSceneStatic(scene))
|
if (IsSceneStatic(scene))
|
||||||
{
|
{
|
||||||
printf("Using static converter.\n");
|
printf("Using static converter.\n");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConvertStatic(outputFile, scene);
|
ConvertStatic(outputFile, scene);
|
||||||
}
|
}
|
||||||
catch (std::exception &ex)
|
catch (std::exception &ex)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", ex.what());
|
printf("Error: %s\n", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Convert complete.\n");
|
printf("Convert complete.\n");
|
||||||
}
|
}
|
||||||
else if (IsSceneAnimated(scene) && IsSceneSkeletal(scene))
|
else if (IsSceneAnimated(scene) && IsSceneSkeletal(scene))
|
||||||
{
|
{
|
||||||
printf("Using skeletal animation converter.\n");
|
printf("Using skeletal animation converter.\n");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConvertSkeletalAnimated(outputFile, scene);
|
ConvertSkeletalAnimated(outputFile, scene);
|
||||||
}
|
}
|
||||||
catch (std::exception &ex)
|
catch (std::exception &ex)
|
||||||
{
|
{
|
||||||
printf("Error: %s\n", ex.what());
|
printf("Error: %s\n", ex.what());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Convert complete.\n");
|
printf("Convert complete.\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Unknown scene format.\n");
|
printf("Unknown scene format.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,266 +1,266 @@
|
||||||
#include "nodetree.h"
|
#include "nodetree.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void WalkNode(const aiNode *node);
|
void WalkNode(const aiNode *node);
|
||||||
void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene);
|
void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene);
|
||||||
void ShowMaterialInfo(const aiMaterial *material);
|
void ShowMaterialInfo(const aiMaterial *material);
|
||||||
void ShowMaterialTextureInfo(const aiMaterial *material, aiTextureType type, const std::string &typeText);
|
void ShowMaterialTextureInfo(const aiMaterial *material, aiTextureType type, const std::string &typeText);
|
||||||
void ShowAnimationInfo(const aiAnimation *animation);
|
void ShowAnimationInfo(const aiAnimation *animation);
|
||||||
|
|
||||||
unsigned int g_level;
|
unsigned int g_level;
|
||||||
FILE *g_fp = NULL;
|
FILE *g_fp = NULL;
|
||||||
|
|
||||||
std::string GetIndentString()
|
std::string GetIndentString()
|
||||||
{
|
{
|
||||||
std::string indent;
|
std::string indent;
|
||||||
for (unsigned int i = 0; i < g_level; ++i)
|
for (unsigned int i = 0; i < g_level; ++i)
|
||||||
indent += " ";
|
indent += " ";
|
||||||
return indent;
|
return indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Walk(const aiScene *scene, const std::string &filename)
|
void Walk(const aiScene *scene, const std::string &filename)
|
||||||
{
|
{
|
||||||
g_level = 0;
|
g_level = 0;
|
||||||
|
|
||||||
g_fp = fopen(filename.c_str(), "w");
|
g_fp = fopen(filename.c_str(), "w");
|
||||||
if (g_fp == NULL)
|
if (g_fp == NULL)
|
||||||
throw std::exception("Error creating description output file.");
|
throw std::exception("Error creating description output file.");
|
||||||
|
|
||||||
fprintf(g_fp, "\n*** GENERAL SCENE INFO ***\n\n");
|
fprintf(g_fp, "\n*** GENERAL SCENE INFO ***\n\n");
|
||||||
fprintf(g_fp, "HasAnimations: %s\n", scene->HasAnimations() ? "yes" : "no");
|
fprintf(g_fp, "HasAnimations: %s\n", scene->HasAnimations() ? "yes" : "no");
|
||||||
fprintf(g_fp, "HasMaterials: %s\n", scene->HasMaterials() ? "yes" : "no");
|
fprintf(g_fp, "HasMaterials: %s\n", scene->HasMaterials() ? "yes" : "no");
|
||||||
fprintf(g_fp, "HasMeshes: %s\n", scene->HasMeshes() ? "yes" : "no");
|
fprintf(g_fp, "HasMeshes: %s\n", scene->HasMeshes() ? "yes" : "no");
|
||||||
fprintf(g_fp, "mNumAnimations: %d\n", scene->mNumAnimations);
|
fprintf(g_fp, "mNumAnimations: %d\n", scene->mNumAnimations);
|
||||||
fprintf(g_fp, "mNumMaterials: %d\n", scene->mNumMaterials);
|
fprintf(g_fp, "mNumMaterials: %d\n", scene->mNumMaterials);
|
||||||
fprintf(g_fp, "mNumMeshes: %d\n", scene->mNumMeshes);
|
fprintf(g_fp, "mNumMeshes: %d\n", scene->mNumMeshes);
|
||||||
fprintf(g_fp, "\n");
|
fprintf(g_fp, "\n");
|
||||||
|
|
||||||
if (scene->mNumMaterials > 0)
|
if (scene->mNumMaterials > 0)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, "\n*** MATERIALS ***\n\n");
|
fprintf(g_fp, "\n*** MATERIALS ***\n\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, "[%d]:\n", i);
|
fprintf(g_fp, "[%d]:\n", i);
|
||||||
ShowMaterialInfo(scene->mMaterials[i]);
|
ShowMaterialInfo(scene->mMaterials[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(g_fp, "\n*** MESHES ***\n\n");
|
fprintf(g_fp, "\n*** MESHES ***\n\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, "[%d]\n", i);
|
fprintf(g_fp, "[%d]\n", i);
|
||||||
ShowMeshInfo(scene->mMeshes[i], scene);
|
ShowMeshInfo(scene->mMeshes[i], scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(g_fp, "\n*** NODES ***\n");
|
fprintf(g_fp, "\n*** NODES ***\n");
|
||||||
WalkNode(scene->mRootNode);
|
WalkNode(scene->mRootNode);
|
||||||
|
|
||||||
if (scene->mNumAnimations > 0)
|
if (scene->mNumAnimations > 0)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, "\n*** ANIMATIONS ***\n\n");
|
fprintf(g_fp, "\n*** ANIMATIONS ***\n\n");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < scene->mNumAnimations; ++i)
|
for (unsigned int i = 0; i < scene->mNumAnimations; ++i)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, "[%d]:\n", i);
|
fprintf(g_fp, "[%d]:\n", i);
|
||||||
ShowAnimationInfo(scene->mAnimations[i]);
|
ShowAnimationInfo(scene->mAnimations[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(g_fp);
|
fclose(g_fp);
|
||||||
g_fp = NULL;
|
g_fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalkNode(const aiNode *node)
|
void WalkNode(const aiNode *node)
|
||||||
{
|
{
|
||||||
++g_level;
|
++g_level;
|
||||||
fprintf(g_fp, "\n");
|
fprintf(g_fp, "\n");
|
||||||
|
|
||||||
std::string indent = GetIndentString();
|
std::string indent = GetIndentString();
|
||||||
|
|
||||||
aiQuaternion rotation;
|
aiQuaternion rotation;
|
||||||
aiVector3D scaling;
|
aiVector3D scaling;
|
||||||
aiVector3D position;
|
aiVector3D position;
|
||||||
node->mTransformation.Decompose(scaling, rotation, position);
|
node->mTransformation.Decompose(scaling, rotation, position);
|
||||||
|
|
||||||
fprintf(g_fp, "%sName: %s\n", indent.c_str(), node->mName.data);
|
fprintf(g_fp, "%sName: %s\n", indent.c_str(), node->mName.data);
|
||||||
fprintf(g_fp, "%smNumChildren: %d\n", indent.c_str(), node->mNumChildren);
|
fprintf(g_fp, "%smNumChildren: %d\n", indent.c_str(), node->mNumChildren);
|
||||||
fprintf(g_fp, "%smNumMeshes: %d", indent.c_str(), node->mNumMeshes);
|
fprintf(g_fp, "%smNumMeshes: %d", indent.c_str(), node->mNumMeshes);
|
||||||
if (node->mNumMeshes > 0)
|
if (node->mNumMeshes > 0)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, " [");
|
fprintf(g_fp, " [");
|
||||||
for (unsigned int i = 0; i < node->mNumMeshes; ++i)
|
for (unsigned int i = 0; i < node->mNumMeshes; ++i)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
fprintf(g_fp, ", ");
|
fprintf(g_fp, ", ");
|
||||||
fprintf(g_fp, "%d", node->mMeshes[i]);
|
fprintf(g_fp, "%d", node->mMeshes[i]);
|
||||||
}
|
}
|
||||||
fprintf(g_fp, "]");
|
fprintf(g_fp, "]");
|
||||||
}
|
}
|
||||||
fprintf(g_fp, "\n");
|
fprintf(g_fp, "\n");
|
||||||
fprintf(g_fp, "%smTransformation:\n", indent.c_str());
|
fprintf(g_fp, "%smTransformation:\n", indent.c_str());
|
||||||
fprintf(g_fp, "%s - Rotation: %f, %f, %f, %f\n", indent.c_str(), rotation.x, rotation.y, rotation.z, rotation.w);
|
fprintf(g_fp, "%s - Rotation: %f, %f, %f, %f\n", indent.c_str(), rotation.x, rotation.y, rotation.z, rotation.w);
|
||||||
fprintf(g_fp, "%s - Scaling: %f, %f, %f\n", indent.c_str(), scaling.x, scaling.y, scaling.z);
|
fprintf(g_fp, "%s - Scaling: %f, %f, %f\n", indent.c_str(), scaling.x, scaling.y, scaling.z);
|
||||||
fprintf(g_fp, "%s - Position: %f, %f, %f\n", indent.c_str(), position.x, position.y, position.z);
|
fprintf(g_fp, "%s - Position: %f, %f, %f\n", indent.c_str(), position.x, position.y, position.z);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < node->mNumChildren; ++i)
|
for (unsigned int i = 0; i < node->mNumChildren; ++i)
|
||||||
WalkNode(node->mChildren[i]);
|
WalkNode(node->mChildren[i]);
|
||||||
|
|
||||||
--g_level;
|
--g_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene)
|
void ShowMeshInfo(const aiMesh *mesh, const aiScene *scene)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, " Name: %s\n", mesh->mName.data);
|
fprintf(g_fp, " Name: %s\n", mesh->mName.data);
|
||||||
fprintf(g_fp, " HasBones: %s\n", mesh->HasBones() ? "yes" : "no");
|
fprintf(g_fp, " HasBones: %s\n", mesh->HasBones() ? "yes" : "no");
|
||||||
fprintf(g_fp, " HasFaces: %s\n", mesh->HasFaces() ? "yes" : "no");
|
fprintf(g_fp, " HasFaces: %s\n", mesh->HasFaces() ? "yes" : "no");
|
||||||
fprintf(g_fp, " HasNormals: %s\n", mesh->HasNormals() ? "yes" : "no");
|
fprintf(g_fp, " HasNormals: %s\n", mesh->HasNormals() ? "yes" : "no");
|
||||||
fprintf(g_fp, " HasPositions: %s\n", mesh->HasPositions() ? "yes" : "no");
|
fprintf(g_fp, " HasPositions: %s\n", mesh->HasPositions() ? "yes" : "no");
|
||||||
fprintf(g_fp, " HasTangentsAndBitangents: %s\n", mesh->HasTangentsAndBitangents() ? "yes" : "no");
|
fprintf(g_fp, " HasTangentsAndBitangents: %s\n", mesh->HasTangentsAndBitangents() ? "yes" : "no");
|
||||||
fprintf(g_fp, " HasTextureCoords: %s, %s, %s, %s\n",
|
fprintf(g_fp, " HasTextureCoords: %s, %s, %s, %s\n",
|
||||||
(mesh->HasTextureCoords(0) ? "yes" : "no"),
|
(mesh->HasTextureCoords(0) ? "yes" : "no"),
|
||||||
(mesh->HasTextureCoords(1) ? "yes" : "no"),
|
(mesh->HasTextureCoords(1) ? "yes" : "no"),
|
||||||
(mesh->HasTextureCoords(2) ? "yes" : "no"),
|
(mesh->HasTextureCoords(2) ? "yes" : "no"),
|
||||||
(mesh->HasTextureCoords(3) ? "yes" : "no")
|
(mesh->HasTextureCoords(3) ? "yes" : "no")
|
||||||
);
|
);
|
||||||
fprintf(g_fp, " HasVertexColors: %s, %s, %s, %s\n",
|
fprintf(g_fp, " HasVertexColors: %s, %s, %s, %s\n",
|
||||||
(mesh->HasVertexColors(0) ? "yes" : "no"),
|
(mesh->HasVertexColors(0) ? "yes" : "no"),
|
||||||
(mesh->HasVertexColors(1) ? "yes" : "no"),
|
(mesh->HasVertexColors(1) ? "yes" : "no"),
|
||||||
(mesh->HasVertexColors(2) ? "yes" : "no"),
|
(mesh->HasVertexColors(2) ? "yes" : "no"),
|
||||||
(mesh->HasVertexColors(3) ? "yes" : "no")
|
(mesh->HasVertexColors(3) ? "yes" : "no")
|
||||||
);
|
);
|
||||||
fprintf(g_fp, " mMaterialIndex: %d\n", mesh->mMaterialIndex);
|
fprintf(g_fp, " mMaterialIndex: %d\n", mesh->mMaterialIndex);
|
||||||
fprintf(g_fp, " mNumFaces: %d\n", mesh->mNumFaces);
|
fprintf(g_fp, " mNumFaces: %d\n", mesh->mNumFaces);
|
||||||
fprintf(g_fp, " mPrimitiveTypes: %d - (All Triangles? %s)\n", mesh->mPrimitiveTypes, mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE ? "yes" : "no");
|
fprintf(g_fp, " mPrimitiveTypes: %d - (All Triangles? %s)\n", mesh->mPrimitiveTypes, mesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE ? "yes" : "no");
|
||||||
fprintf(g_fp, " mNumVertices: %d\n", mesh->mNumVertices);
|
fprintf(g_fp, " mNumVertices: %d\n", mesh->mNumVertices);
|
||||||
fprintf(g_fp, " mNumUVComponents: %d, %d, %d, %d\n", mesh->mNumUVComponents[0], mesh->mNumUVComponents[1], mesh->mNumUVComponents[2], mesh->mNumUVComponents[3]);
|
fprintf(g_fp, " mNumUVComponents: %d, %d, %d, %d\n", mesh->mNumUVComponents[0], mesh->mNumUVComponents[1], mesh->mNumUVComponents[2], mesh->mNumUVComponents[3]);
|
||||||
fprintf(g_fp, " mNumBones: %d\n", mesh->mNumBones);
|
fprintf(g_fp, " mNumBones: %d\n", mesh->mNumBones);
|
||||||
fprintf(g_fp, " mNumAnimMeshes: %d\n", mesh->mNumAnimMeshes);
|
fprintf(g_fp, " mNumAnimMeshes: %d\n", mesh->mNumAnimMeshes);
|
||||||
fprintf(g_fp, " mBones:\n");
|
fprintf(g_fp, " mBones:\n");
|
||||||
for (unsigned int i = 0; i < mesh->mNumBones; ++i)
|
for (unsigned int i = 0; i < mesh->mNumBones; ++i)
|
||||||
{
|
{
|
||||||
aiBone *bone = mesh->mBones[i];
|
aiBone *bone = mesh->mBones[i];
|
||||||
|
|
||||||
aiQuaternion rotation;
|
aiQuaternion rotation;
|
||||||
aiVector3D scaling;
|
aiVector3D scaling;
|
||||||
aiVector3D position;
|
aiVector3D position;
|
||||||
bone->mOffsetMatrix.Decompose(scaling, rotation, position);
|
bone->mOffsetMatrix.Decompose(scaling, rotation, position);
|
||||||
|
|
||||||
aiString parentName = "[null]";
|
aiString parentName = "[null]";
|
||||||
aiNode *boneNode = scene->mRootNode->FindNode(bone->mName);
|
aiNode *boneNode = scene->mRootNode->FindNode(bone->mName);
|
||||||
if (boneNode != NULL)
|
if (boneNode != NULL)
|
||||||
{
|
{
|
||||||
aiNode *parent = boneNode->mParent;
|
aiNode *parent = boneNode->mParent;
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
parentName = parent->mName;
|
parentName = parent->mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(g_fp, " [%d]\n", i);
|
fprintf(g_fp, " [%d]\n", i);
|
||||||
fprintf(g_fp, " Name: %s\n", bone->mName.data);
|
fprintf(g_fp, " Name: %s\n", bone->mName.data);
|
||||||
fprintf(g_fp, " Parent Name: %s\n", parentName.data);
|
fprintf(g_fp, " Parent Name: %s\n", parentName.data);
|
||||||
fprintf(g_fp, " mNumWeights: %d\n", bone->mNumWeights);
|
fprintf(g_fp, " mNumWeights: %d\n", bone->mNumWeights);
|
||||||
fprintf(g_fp, " mOffsetMatrix:\n");
|
fprintf(g_fp, " mOffsetMatrix:\n");
|
||||||
fprintf(g_fp, " - Rotation: %f, %f, %f, %f\n", rotation.x, rotation.y, rotation.z, rotation.w);
|
fprintf(g_fp, " - Rotation: %f, %f, %f, %f\n", rotation.x, rotation.y, rotation.z, rotation.w);
|
||||||
fprintf(g_fp, " - Scaling: %f, %f, %f\n", scaling.x, scaling.y, scaling.z);
|
fprintf(g_fp, " - Scaling: %f, %f, %f\n", scaling.x, scaling.y, scaling.z);
|
||||||
fprintf(g_fp, " - Position: %f, %f, %f\n", position.x, position.y, position.z);
|
fprintf(g_fp, " - Position: %f, %f, %f\n", position.x, position.y, position.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowMaterialInfo(const aiMaterial *material)
|
void ShowMaterialInfo(const aiMaterial *material)
|
||||||
{
|
{
|
||||||
aiString name;
|
aiString name;
|
||||||
aiString textureFile;
|
aiString textureFile;
|
||||||
aiColor3D ambient;
|
aiColor3D ambient;
|
||||||
aiColor3D diffuse;
|
aiColor3D diffuse;
|
||||||
aiColor3D specular;
|
aiColor3D specular;
|
||||||
aiColor3D emissive;
|
aiColor3D emissive;
|
||||||
float shininess;
|
float shininess;
|
||||||
float opacity;
|
float opacity;
|
||||||
|
|
||||||
material->Get(AI_MATKEY_NAME, name);
|
material->Get(AI_MATKEY_NAME, name);
|
||||||
material->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
|
material->Get(AI_MATKEY_COLOR_AMBIENT, ambient);
|
||||||
material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
|
material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
|
||||||
material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
||||||
material->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
|
material->Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
|
||||||
material->Get(AI_MATKEY_SHININESS, shininess);
|
material->Get(AI_MATKEY_SHININESS, shininess);
|
||||||
material->Get(AI_MATKEY_OPACITY, opacity);
|
material->Get(AI_MATKEY_OPACITY, opacity);
|
||||||
|
|
||||||
fprintf(g_fp, " Name: %s\n", name.data);
|
fprintf(g_fp, " Name: %s\n", name.data);
|
||||||
fprintf(g_fp, " Ambient: %f, %f, %f\n", ambient.r, ambient.g, ambient.b);
|
fprintf(g_fp, " Ambient: %f, %f, %f\n", ambient.r, ambient.g, ambient.b);
|
||||||
fprintf(g_fp, " Diffuse: %f, %f, %f\n", diffuse.r, diffuse.g, diffuse.b);
|
fprintf(g_fp, " Diffuse: %f, %f, %f\n", diffuse.r, diffuse.g, diffuse.b);
|
||||||
fprintf(g_fp, " Specular: %f, %f, %f\n", specular.r, specular.g, specular.b);
|
fprintf(g_fp, " Specular: %f, %f, %f\n", specular.r, specular.g, specular.b);
|
||||||
fprintf(g_fp, " Emissive: %f, %f, %f\n", emissive.r, emissive.g, emissive.b);
|
fprintf(g_fp, " Emissive: %f, %f, %f\n", emissive.r, emissive.g, emissive.b);
|
||||||
fprintf(g_fp, " Shininess: %f\n", shininess);
|
fprintf(g_fp, " Shininess: %f\n", shininess);
|
||||||
fprintf(g_fp, " Opacity: %f\n", opacity);
|
fprintf(g_fp, " Opacity: %f\n", opacity);
|
||||||
|
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_NONE, "aiTextureType_NONE");
|
ShowMaterialTextureInfo(material, aiTextureType_NONE, "aiTextureType_NONE");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_DIFFUSE, "aiTextureType_DIFFUSE");
|
ShowMaterialTextureInfo(material, aiTextureType_DIFFUSE, "aiTextureType_DIFFUSE");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_SPECULAR, "aiTextureType_SPECULAR");
|
ShowMaterialTextureInfo(material, aiTextureType_SPECULAR, "aiTextureType_SPECULAR");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_AMBIENT, "aiTextureType_AMBIENT");
|
ShowMaterialTextureInfo(material, aiTextureType_AMBIENT, "aiTextureType_AMBIENT");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_EMISSIVE, "aiTextureType_EMISSIVE");
|
ShowMaterialTextureInfo(material, aiTextureType_EMISSIVE, "aiTextureType_EMISSIVE");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_HEIGHT, "aiTextureType_HEIGHT");
|
ShowMaterialTextureInfo(material, aiTextureType_HEIGHT, "aiTextureType_HEIGHT");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_NORMALS, "aiTextureType_NORMALS");
|
ShowMaterialTextureInfo(material, aiTextureType_NORMALS, "aiTextureType_NORMALS");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_SHININESS, "aiTextureType_SHININESS");
|
ShowMaterialTextureInfo(material, aiTextureType_SHININESS, "aiTextureType_SHININESS");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_OPACITY, "aiTextureType_OPACITY");
|
ShowMaterialTextureInfo(material, aiTextureType_OPACITY, "aiTextureType_OPACITY");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_DISPLACEMENT, "aiTextureType_DISPLACEMENT");
|
ShowMaterialTextureInfo(material, aiTextureType_DISPLACEMENT, "aiTextureType_DISPLACEMENT");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_LIGHTMAP, "aiTextureType_LIGHTMAP");
|
ShowMaterialTextureInfo(material, aiTextureType_LIGHTMAP, "aiTextureType_LIGHTMAP");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_REFLECTION, "aiTextureType_REFLECTION");
|
ShowMaterialTextureInfo(material, aiTextureType_REFLECTION, "aiTextureType_REFLECTION");
|
||||||
ShowMaterialTextureInfo(material, aiTextureType_UNKNOWN, "aiTextureType_UNKNOWN");
|
ShowMaterialTextureInfo(material, aiTextureType_UNKNOWN, "aiTextureType_UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowMaterialTextureInfo(const aiMaterial *material, aiTextureType type, const std::string &typeText)
|
void ShowMaterialTextureInfo(const aiMaterial *material, aiTextureType type, const std::string &typeText)
|
||||||
{
|
{
|
||||||
aiString textureFile;
|
aiString textureFile;
|
||||||
|
|
||||||
unsigned int count = material->GetTextureCount(type);
|
unsigned int count = material->GetTextureCount(type);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, " %s: %d\n", typeText.c_str(), count);
|
fprintf(g_fp, " %s: %d\n", typeText.c_str(), count);
|
||||||
for (unsigned int i = 0; i < count; ++i)
|
for (unsigned int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
material->Get(AI_MATKEY_TEXTURE(type, i), textureFile);
|
material->Get(AI_MATKEY_TEXTURE(type, i), textureFile);
|
||||||
fprintf(g_fp, " %s\n", textureFile.data);
|
fprintf(g_fp, " %s\n", textureFile.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowAnimationInfo(const aiAnimation *animation)
|
void ShowAnimationInfo(const aiAnimation *animation)
|
||||||
{
|
{
|
||||||
fprintf(g_fp, " Name: %s\n", animation->mName.data);
|
fprintf(g_fp, " Name: %s\n", animation->mName.data);
|
||||||
fprintf(g_fp, " mDuration: %f\n", animation->mDuration);
|
fprintf(g_fp, " mDuration: %f\n", animation->mDuration);
|
||||||
fprintf(g_fp, " mTicksPerSecond: %f\n", animation->mTicksPerSecond);
|
fprintf(g_fp, " mTicksPerSecond: %f\n", animation->mTicksPerSecond);
|
||||||
fprintf(g_fp, " mNumChannels: %d\n", animation->mNumChannels);
|
fprintf(g_fp, " mNumChannels: %d\n", animation->mNumChannels);
|
||||||
fprintf(g_fp, " mChannels:\n");
|
fprintf(g_fp, " mChannels:\n");
|
||||||
for (unsigned int i = 0; i < animation->mNumChannels; ++i)
|
for (unsigned int i = 0; i < animation->mNumChannels; ++i)
|
||||||
{
|
{
|
||||||
aiNodeAnim *channel = animation->mChannels[i];
|
aiNodeAnim *channel = animation->mChannels[i];
|
||||||
|
|
||||||
fprintf(g_fp, " [%d]:\n", i);
|
fprintf(g_fp, " [%d]:\n", i);
|
||||||
fprintf(g_fp, " Name: %s\n", channel->mNodeName.data);
|
fprintf(g_fp, " Name: %s\n", channel->mNodeName.data);
|
||||||
fprintf(g_fp, " mNumPositionKeys: %d\n", channel->mNumPositionKeys);
|
fprintf(g_fp, " mNumPositionKeys: %d\n", channel->mNumPositionKeys);
|
||||||
fprintf(g_fp, " mNumRotationKeys: %d\n", channel->mNumRotationKeys);
|
fprintf(g_fp, " mNumRotationKeys: %d\n", channel->mNumRotationKeys);
|
||||||
fprintf(g_fp, " mNumScalingKeys: %d\n", channel->mNumScalingKeys);
|
fprintf(g_fp, " mNumScalingKeys: %d\n", channel->mNumScalingKeys);
|
||||||
fprintf(g_fp, " mPositionKeys:\n");
|
fprintf(g_fp, " mPositionKeys:\n");
|
||||||
for (unsigned int i = 0; i < channel->mNumPositionKeys; ++i)
|
for (unsigned int i = 0; i < channel->mNumPositionKeys; ++i)
|
||||||
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mPositionKeys[i].mValue.x, channel->mPositionKeys[i].mValue.y, channel->mPositionKeys[i].mValue.z);
|
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mPositionKeys[i].mValue.x, channel->mPositionKeys[i].mValue.y, channel->mPositionKeys[i].mValue.z);
|
||||||
fprintf(g_fp, " mRotationKeys:\n");
|
fprintf(g_fp, " mRotationKeys:\n");
|
||||||
for (unsigned int i = 0; i < channel->mNumPositionKeys; ++i)
|
for (unsigned int i = 0; i < channel->mNumPositionKeys; ++i)
|
||||||
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mRotationKeys[i].mValue.x, channel->mRotationKeys[i].mValue.y, channel->mRotationKeys[i].mValue.z, channel->mRotationKeys[i].mValue.w);
|
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mRotationKeys[i].mValue.x, channel->mRotationKeys[i].mValue.y, channel->mRotationKeys[i].mValue.z, channel->mRotationKeys[i].mValue.w);
|
||||||
fprintf(g_fp, " mScalingKeys:\n");
|
fprintf(g_fp, " mScalingKeys:\n");
|
||||||
for (unsigned int i = 0; i < channel->mNumScalingKeys; ++i)
|
for (unsigned int i = 0; i < channel->mNumScalingKeys; ++i)
|
||||||
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mScalingKeys[i].mValue.x, channel->mScalingKeys[i].mValue.y, channel->mScalingKeys[i].mValue.z);
|
fprintf(g_fp, " [%d] %f, %f, %f\n", i, channel->mScalingKeys[i].mValue.x, channel->mScalingKeys[i].mValue.y, channel->mScalingKeys[i].mValue.z);
|
||||||
}
|
}
|
||||||
fprintf(g_fp, " mNumMeshChannels: %d\n", animation->mNumMeshChannels);
|
fprintf(g_fp, " mNumMeshChannels: %d\n", animation->mNumMeshChannels);
|
||||||
fprintf(g_fp, " mMeshChannels:\n");
|
fprintf(g_fp, " mMeshChannels:\n");
|
||||||
for (unsigned int i = 0; i < animation->mNumMeshChannels; ++i)
|
for (unsigned int i = 0; i < animation->mNumMeshChannels; ++i)
|
||||||
{
|
{
|
||||||
aiMeshAnim *channel = animation->mMeshChannels[i];
|
aiMeshAnim *channel = animation->mMeshChannels[i];
|
||||||
|
|
||||||
fprintf(g_fp, " [%d]:\n", i);
|
fprintf(g_fp, " [%d]:\n", i);
|
||||||
fprintf(g_fp, " Name: %s\n", channel->mName.data);
|
fprintf(g_fp, " Name: %s\n", channel->mName.data);
|
||||||
fprintf(g_fp, " mNumKeys: %d\n", channel->mNumKeys);
|
fprintf(g_fp, " mNumKeys: %d\n", channel->mNumKeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef __NODETREE_NODETREE_H_INCLUDED__
|
#ifndef __NODETREE_NODETREE_H_INCLUDED__
|
||||||
#define __NODETREE_NODETREE_H_INCLUDED__
|
#define __NODETREE_NODETREE_H_INCLUDED__
|
||||||
|
|
||||||
#include <aiScene.h>
|
#include <aiScene.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void Walk(const aiScene *scene, const std::string &filename);
|
void Walk(const aiScene *scene, const std::string &filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
std::string GetMeshFilenameFromInput(const std::string &filename)
|
std::string GetMeshFilenameFromInput(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string meshFilename = "";
|
std::string meshFilename = "";
|
||||||
|
|
||||||
// strip off the existing extension, and replace it with ".mesh"
|
// strip off the existing extension, and replace it with ".mesh"
|
||||||
size_t extStart = filename.find_last_of('.');
|
size_t extStart = filename.find_last_of('.');
|
||||||
if (extStart != std::string::npos)
|
if (extStart != std::string::npos)
|
||||||
{
|
{
|
||||||
meshFilename = filename.substr(0, extStart);
|
meshFilename = filename.substr(0, extStart);
|
||||||
meshFilename += ".mesh";
|
meshFilename += ".mesh";
|
||||||
}
|
}
|
||||||
|
|
||||||
return meshFilename;
|
return meshFilename;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef __UTILS_UTILS_H_INCLUDED__
|
#ifndef __UTILS_UTILS_H_INCLUDED__
|
||||||
#define __UTILS_UTILS_H_INCLUDED__
|
#define __UTILS_UTILS_H_INCLUDED__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string GetMeshFilenameFromInput(const std::string &filename);
|
std::string GetMeshFilenameFromInput(const std::string &filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue