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