diff --git a/ContentExporter_2019.sln b/ContentExporter_2019.sln index 2f7408e..d628443 100644 --- a/ContentExporter_2019.sln +++ b/ContentExporter_2019.sln @@ -10,6 +10,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XATGFileWriter", "XATGFileW EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDKMeshFileWriter", "SDKMeshFileWriter\SDKMeshFileWriter2019.vcxproj", "{85495119-FC0E-4F85-8357-8823B6164F9E}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMOFileWriter", "cmofilewriter\CMOFileWriter2019.vcxproj", "{4D1B88DF-35BF-4771-ABA2-45559F4A9078}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -32,6 +34,10 @@ Global {85495119-FC0E-4F85-8357-8823B6164F9E}.Debug|x64.Build.0 = Debug|x64 {85495119-FC0E-4F85-8357-8823B6164F9E}.Release|x64.ActiveCfg = Release|x64 {85495119-FC0E-4F85-8357-8823B6164F9E}.Release|x64.Build.0 = Release|x64 + {4D1B88DF-35BF-4771-ABA2-45559F4A9078}.Debug|x64.ActiveCfg = Debug|x64 + {4D1B88DF-35BF-4771-ABA2-45559F4A9078}.Debug|x64.Build.0 = Debug|x64 + {4D1B88DF-35BF-4771-ABA2-45559F4A9078}.Release|x64.ActiveCfg = Release|x64 + {4D1B88DF-35BF-4771-ABA2-45559F4A9078}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/cmofilewriter/CMO.h b/cmofilewriter/CMO.h new file mode 100644 index 0000000..c40151a --- /dev/null +++ b/cmofilewriter/CMO.h @@ -0,0 +1,181 @@ +//-------------------------------------------------------------------------------------- +// File: CMO.h +// +// .CMO files are built by Visual Studio's MeshContentTask and an example renderer was +// provided in the VS Direct3D Starter Kit +// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-1-of-3/ +// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-2-of-3/ +// https://devblogs.microsoft.com/cppblog/developing-an-app-with-the-visual-studio-3d-starter-kit-part-3-of-3/ +// +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// http://go.microsoft.com/fwlink/?LinkId=248929 +// http://go.microsoft.com/fwlink/?LinkID=615561 +//-------------------------------------------------------------------------------------- + +#pragma once + +#include + +#include + + +namespace VSD3DStarter +{ + // .CMO files + + // UINT - Mesh count + // { [Mesh count] + // UINT - Length of name + // wchar_t[] - Name of mesh (if length > 0) + // UINT - Material count + // { [Material count] + // UINT - Length of material name + // wchar_t[] - Name of material (if length > 0) + // Material structure + // UINT - Length of pixel shader name + // wchar_t[] - Name of pixel shader (if length > 0) + // { [8] + // UINT - Length of texture name + // wchar_t[] - Name of texture (if length > 0) + // } + // } + // BYTE - 1 if there is skeletal animation data present + // UINT - SubMesh count + // { [SubMesh count] + // SubMesh structure + // } + // UINT - IB Count + // { [IB Count] + // UINT - Number of USHORTs in IB + // USHORT[] - Array of indices + // } + // UINT - VB Count + // { [VB Count] + // UINT - Number of verts in VB + // Vertex[] - Array of vertices + // } + // UINT - Skinning VB Count + // { [Skinning VB Count] + // UINT - Number of verts in Skinning VB + // SkinningVertex[] - Array of skinning verts + // } + // MeshExtents structure + // [If skeleton animation data is not present, file ends here] + // UINT - Bone count + // { [Bone count] + // UINT - Length of bone name + // wchar_t[] - Bone name (if length > 0) + // Bone structure + // } + // UINT - Animation clip count + // { [Animation clip count] + // UINT - Length of clip name + // wchar_t[] - Clip name (if length > 0) + // float - Start time + // float - End time + // UINT - Keyframe count + // { [Keyframe count] + // Keyframe structure + // } + // } + // } + +#pragma pack(push,1) + + struct Material + { + DirectX::XMFLOAT4 Ambient; + DirectX::XMFLOAT4 Diffuse; + DirectX::XMFLOAT4 Specular; + float SpecularPower; + DirectX::XMFLOAT4 Emissive; + DirectX::XMFLOAT4X4 UVTransform; + }; + + constexpr uint32_t MAX_TEXTURE = 8; + + struct SubMesh + { + uint32_t MaterialIndex; + uint32_t IndexBufferIndex; + uint32_t VertexBufferIndex; + uint32_t StartIndex; + uint32_t PrimCount; + }; + + constexpr uint32_t NUM_BONE_INFLUENCES = 4; + + // Vertex struct for Visual Studio Shader Designer (DGSL) holding position, normal, + // tangent, color (RGBA), and texture mapping information + struct VertexPositionNormalTangentColorTexture + { + DirectX::XMFLOAT3 position; + DirectX::XMFLOAT3 normal; + DirectX::XMFLOAT4 tangent; + uint32_t color; + DirectX::XMFLOAT2 textureCoordinate; + }; + + struct SkinningVertex + { + uint32_t boneIndex[NUM_BONE_INFLUENCES]; + float boneWeight[NUM_BONE_INFLUENCES]; + }; + + struct MeshExtents + { + float CenterX, CenterY, CenterZ; + float Radius; + + float MinX, MinY, MinZ; + float MaxX, MaxY, MaxZ; + }; + + struct Bone + { + int32_t ParentIndex; + DirectX::XMFLOAT4X4 InvBindPos; + DirectX::XMFLOAT4X4 BindPos; + DirectX::XMFLOAT4X4 LocalTransform; + }; + + struct Clip + { + float StartTime; + float EndTime; + uint32_t keys; + }; + + struct Keyframe + { + uint32_t BoneIndex; + float Time; + DirectX::XMFLOAT4X4 Transform; + }; + +#pragma pack(pop) + + const Material s_defMaterial = + { + { 0.2f, 0.2f, 0.2f, 1.f }, + { 0.8f, 0.8f, 0.8f, 1.f }, + { 0.0f, 0.0f, 0.0f, 1.f }, + 1.f, + { 0.0f, 0.0f, 0.0f, 1.0f }, + { 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f }, + }; +} // namespace + +static_assert(sizeof(VSD3DStarter::Material) == 132, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::SubMesh) == 20, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::VertexPositionNormalTangentColorTexture) == 52, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::SkinningVertex) == 32, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::MeshExtents) == 40, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::Bone) == 196, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::Clip) == 12, "CMO Mesh structure size incorrect"); +static_assert(sizeof(VSD3DStarter::Keyframe) == 72, "CMO Mesh structure size incorrect"); diff --git a/cmofilewriter/CMOFileWriter2019.vcxproj b/cmofilewriter/CMOFileWriter2019.vcxproj new file mode 100644 index 0000000..ee9d09b --- /dev/null +++ b/cmofilewriter/CMOFileWriter2019.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug + x64 + + + Release + x64 + + + + CMOFileWriter + {4D1B88DF-35BF-4771-ABA2-45559F4A9078} + CMOFileWriter + Win32Proj + 10.0 + + + + StaticLibrary + Unicode + false + v142 + + + StaticLibrary + Unicode + v142 + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(Platform)\$(Configuration)_2019\ + $(Platform)\$(Configuration)_2019\ + $(Platform)\$(Configuration)_2019\ + $(Platform)\$(Configuration)_2019\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + %(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + Sync + EnableFastChecks + MultiThreadedDebugDLL + Use + Level4 + ProgramDatabase + true + /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) + Level4 + + + + + false + %(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + Sync + MultiThreadedDLL + Use + Level4 + ProgramDatabase + Guard + true + /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) + Level4 + + + MachineX64 + + + + + + Create + Create + + + + + + + + + + + \ No newline at end of file diff --git a/cmofilewriter/CMOFileWriter2019.vcxproj.filters b/cmofilewriter/CMOFileWriter2019.vcxproj.filters new file mode 100644 index 0000000..f76b539 --- /dev/null +++ b/cmofilewriter/CMOFileWriter2019.vcxproj.filters @@ -0,0 +1,32 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/cmofilewriter/cmofilewriter.cpp b/cmofilewriter/cmofilewriter.cpp new file mode 100644 index 0000000..5522732 --- /dev/null +++ b/cmofilewriter/cmofilewriter.cpp @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------------- +// CMOFileWriter.cpp +// +// Advanced Technology Group (ATG) +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// http://go.microsoft.com/fwlink/?LinkId=226208 +//------------------------------------------------------------------------------------- +#include "stdafx.h" + +extern ATG::ExportScene* g_pScene; + +#include "CMO.h" + +using namespace DirectX; + + +namespace ATG +{ + bool WriteCMOFile(const CHAR* strFileName, ExportManifest* pManifest) + { + if (!g_pScene) + return false; + + // TODO: + return false; + } +} diff --git a/cmofilewriter/cmofilewriter.h b/cmofilewriter/cmofilewriter.h new file mode 100644 index 0000000..7f8559b --- /dev/null +++ b/cmofilewriter/cmofilewriter.h @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------------- +// CMOFileWriter.h +// +// Entry point for writing SDKMESH files. This file writer takes data from the +// ExportScene stored in a global variable (g_pScene). +// +// Advanced Technology Group (ATG) +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// http://go.microsoft.com/fwlink/?LinkId=226208 +//------------------------------------------------------------------------------------- +#pragma once + +namespace ATG +{ + + class ExportManifest; + + bool WriteCMOFile(const CHAR* strFileName, ExportManifest* pManifest); + +} diff --git a/cmofilewriter/stdafx.cpp b/cmofilewriter/stdafx.cpp new file mode 100644 index 0000000..ebdc06e --- /dev/null +++ b/cmofilewriter/stdafx.cpp @@ -0,0 +1,11 @@ +//------------------------------------------------------------------------------------- +// stdafx.cpp +// +// Advanced Technology Group (ATG) +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// http://go.microsoft.com/fwlink/?LinkId=226208 +//------------------------------------------------------------------------------------- + +#include "stdafx.h" diff --git a/cmofilewriter/stdafx.h b/cmofilewriter/stdafx.h new file mode 100644 index 0000000..13e5d25 --- /dev/null +++ b/cmofilewriter/stdafx.h @@ -0,0 +1,55 @@ +//------------------------------------------------------------------------------------- +// stdafx.h +// +// Precompiled header for the SDKMeshFileWriter project. +// +// Advanced Technology Group (ATG) +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +// +// http://go.microsoft.com/fwlink/?LinkId=226208 +//------------------------------------------------------------------------------------- +#pragma once + +#pragma warning( disable : 4100 4481 ) + +#pragma warning (disable : 26400 26401 26409 26426 26429 26432 26440 26446 26447 26451 26455 26462 26472 26475 26476 26481 26482 26485 26486 26487 26489 26490 26492 26493 26812 26814) + +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#define NOMCX +#define NOSERVICE +#define NOHELP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "..\ExportObjects\ExportXmlParser.h" +#include "..\ExportObjects\ExportPath.h" +#include "..\ExportObjects\ExportMaterial.h" +#include "..\ExportObjects\ExportObjects.h" diff --git a/exporterglobals.h b/exporterglobals.h index 7a6250e..800d5c2 100644 --- a/exporterglobals.h +++ b/exporterglobals.h @@ -30,6 +30,9 @@ #define CONTENT_EXPORTER_BINARYFILE_FILTER "*." CONTENT_EXPORTER_BINARYFILE_EXTENSION #define CONTENT_EXPORTER_BINARYFILE_FILTER_DESCRIPTION "DirectX SDK SDKMesh Binary File" #define CONTENT_EXPORTER_BINARYFILE_FILTER_DESCRIPTION_V2 "SDKMesh Binary File Version 2 (PBR Materials)" +#define CONTENT_EXPORTER_CMO_EXTENSION "cmo" +#define CONTENT_EXPORTER_CMO_FILTER "*." CONTENT_EXPORTER_CMO_EXTENSION +#define CONTENT_EXPORTER_CMO_FILTER_DESCRIPTION "Visual Studio Starter Kit Compiled Mesh Object" #ifdef _DEBUG #define BUILD_FLAVOR "Debug" diff --git a/exportobjects/exportconsoledialog.cpp b/exportobjects/exportconsoledialog.cpp index 10a6356..ce49ea5 100644 --- a/exportobjects/exportconsoledialog.cpp +++ b/exportobjects/exportconsoledialog.cpp @@ -61,8 +61,14 @@ LRESULT ExportConsoleDialog::OnCommand(WORD wNotifyCode, WORD idCtrl, HWND hwndC case BN_CLICKED: Hide(); return true; + + default: + break; } break; + + default: + break; } return false; } @@ -79,23 +85,25 @@ LRESULT ExportConsoleDialog::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) KillTimer(m_hwnd, wParam); return false; case WM_SIZE: - { - GridLayout Layout(3, 2); - Layout.SetRowSpec(0, 1.0f); - Layout.SetRowSpec(1, 30); - Layout.SetRowSpec(2, 30); - Layout.SetColumnSpec(0, 1); - Layout.SetColumnSpec(1, 100); - - constexpr DWORD dwOuterBorder = 4; - constexpr DWORD dwInnerBorder = 4; - Layout.SetClientRect(m_hwnd, dwOuterBorder); - Layout.PlaceWindow(m_hRichTextBox, 0, 0, 1, 2, dwInnerBorder); - Layout.PlaceWindow(m_hProgressText, 1, 0, 1, 2, dwInnerBorder); - Layout.PlaceWindow(m_hProgressBar, 2, 0, 1, 1, dwInnerBorder); - Layout.PlaceWindow(m_hOKButton, 2, 1, 1, 1, dwInnerBorder); - return false; - } + { + GridLayout Layout(3, 2); + Layout.SetRowSpec(0, 1.0f); + Layout.SetRowSpec(1, 30); + Layout.SetRowSpec(2, 30); + Layout.SetColumnSpec(0, 1); + Layout.SetColumnSpec(1, 100); + + constexpr DWORD dwOuterBorder = 4; + constexpr DWORD dwInnerBorder = 4; + Layout.SetClientRect(m_hwnd, dwOuterBorder); + Layout.PlaceWindow(m_hRichTextBox, 0, 0, 1, 2, dwInnerBorder); + Layout.PlaceWindow(m_hProgressText, 1, 0, 1, 2, dwInnerBorder); + Layout.PlaceWindow(m_hProgressBar, 2, 0, 1, 1, dwInnerBorder); + Layout.PlaceWindow(m_hOKButton, 2, 1, 1, 1, dwInnerBorder); + return false; + } + default: + break; } return false; } @@ -151,6 +159,8 @@ void ExportConsoleDialog::LogCommand(DWORD dwCommand, void* pData) case ExportLog::ELC_ENDEXPORT: Show(); break; + default: + break; } } diff --git a/exportobjects/exportdialogutils.cpp b/exportobjects/exportdialogutils.cpp index a4d951c..69341e4 100644 --- a/exportobjects/exportdialogutils.cpp +++ b/exportobjects/exportdialogutils.cpp @@ -40,6 +40,8 @@ LRESULT CALLBACK ThinDialog::DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA LRESULT lrt = FALSE; auto pDlg = GetInstance(hwndDlg); + if(!pDlg) + return 0; switch (uMsg) { diff --git a/exportobjects/exportlog.cpp b/exportobjects/exportlog.cpp index 6717e43..9c9b1e3 100644 --- a/exportobjects/exportlog.cpp +++ b/exportobjects/exportlog.cpp @@ -108,7 +108,7 @@ void ExportLog::ResetCounters() void ATG::BroadcastMessage(UINT uMessageType, const CHAR* strMsg) { LogListenerList::iterator iter = g_Listeners.begin(); - LogListenerList::iterator end = g_Listeners.end(); + const LogListenerList::iterator end = g_Listeners.end(); while (iter != end) { @@ -132,7 +132,7 @@ void ATG::BroadcastMessage(UINT uMessageType, const CHAR* strMsg) void ExportLog::LogCommand(DWORD dwCommand, void* pData) { LogListenerList::iterator iter = g_Listeners.begin(); - LogListenerList::iterator end = g_Listeners.end(); + const LogListenerList::iterator end = g_Listeners.end(); while (iter != end) { diff --git a/exportobjects/exportmanifest.cpp b/exportobjects/exportmanifest.cpp index c46b712..8571079 100644 --- a/exportobjects/exportmanifest.cpp +++ b/exportobjects/exportmanifest.cpp @@ -87,7 +87,7 @@ void ExportTextureConverter::ProcessMaterial(ExportMaterial* pMaterial, ExportMa { MaterialParameterList* pParameters = pMaterial->GetParameterList(); MaterialParameterList::iterator iter = pParameters->begin(); - MaterialParameterList::iterator end = pParameters->end(); + const MaterialParameterList::iterator end = pParameters->end(); while (iter != end) { ExportMaterialParameter* pParameter = &(*iter); @@ -285,7 +285,7 @@ void ConvertImageFormat(const CHAR* strSourceFileName, const CHAR* strDestFileNa if (_stricmp(ext, ".dds") == 0) { isdds = true; - HRESULT hr = LoadFromDDSFile(wSource, DDS_FLAGS_NONE, &info, *image); + const HRESULT hr = LoadFromDDSFile(wSource, DDS_FLAGS_NONE, &info, *image); if (FAILED(hr)) { ExportLog::LogError("Could not load texture \"%s\" (DDS: %08X).", strSourceFileName, static_cast(hr)); diff --git a/exportobjects/exportmaterial.cpp b/exportobjects/exportmaterial.cpp index 6ad19fa..139d3ca 100644 --- a/exportobjects/exportmaterial.cpp +++ b/exportobjects/exportmaterial.cpp @@ -34,7 +34,7 @@ ExportMaterial::~ExportMaterial() ExportMaterialParameter* ExportMaterial::FindParameter(const ExportString strName) { MaterialParameterList::iterator iter = m_Parameters.begin(); - MaterialParameterList::iterator end = m_Parameters.end(); + const MaterialParameterList::iterator end = m_Parameters.end(); while (iter != end) { ExportMaterialParameter& param = *iter; diff --git a/exportobjects/exportmesh.cpp b/exportobjects/exportmesh.cpp index 0ee4295..a1fafc3 100644 --- a/exportobjects/exportmesh.cpp +++ b/exportobjects/exportmesh.cpp @@ -343,6 +343,9 @@ void ExportVB::ByteSwap(const D3DVERTEXELEMENT9* pVertexElements, const size_t d pElement++; break; } + + default: + break; } } } @@ -387,7 +390,7 @@ void ExportIB::Allocate() void ExportMeshTriangleAllocator::Terminate() { AllocationBlockList::iterator iter = m_AllocationBlocks.begin(); - AllocationBlockList::iterator end = m_AllocationBlocks.end(); + const AllocationBlockList::iterator end = m_AllocationBlocks.end(); while (iter != end) { AllocationBlock& block = *iter; @@ -418,7 +421,7 @@ ExportMeshTriangle* ExportMeshTriangleAllocator::GetNewTriangle() UINT uIndex = m_uAllocatedCount; m_uAllocatedCount++; AllocationBlockList::iterator iter = m_AllocationBlocks.begin(); - AllocationBlockList::iterator end = m_AllocationBlocks.end(); + const AllocationBlockList::iterator end = m_AllocationBlocks.end(); while (iter != end) { AllocationBlock& block = *iter; @@ -939,6 +942,8 @@ void ExportMesh::ComputeVertexTangentSpaces() } } + tan1.reset(); + if (m_VertexFormat.m_bBinormal) { hr = writer->Write(tan2.get(), "BINORMAL", 0, nVerts, m_x2Bias); @@ -947,6 +952,10 @@ void ExportMesh::ComputeVertexTangentSpaces() ExportLog::LogError("Mesh \"%s\" failed to write bi-normals (%08X).", GetName().SafeString(), static_cast(hr)); } } + + tan2.reset(); + + writer.reset(); } void ExportMesh::ComputeAdjacency() @@ -1636,10 +1645,10 @@ void ExportMesh::BuildVertexBuffer(ExportMeshVertexArray& VertexArray, DWORD dwF { BYTE* pDest = pDestVertex + iSkinDataOffset; BYTE* pBoneWeights = pDest; - *pDest++ = static_cast(pSrcVertex->BoneWeights.x * 255.0f); - *pDest++ = static_cast(pSrcVertex->BoneWeights.y * 255.0f); - *pDest++ = static_cast(pSrcVertex->BoneWeights.z * 255.0f); - *pDest++ = static_cast(pSrcVertex->BoneWeights.w * 255.0f); + *pDest++ = static_cast(static_cast(pSrcVertex->BoneWeights.x * 255.0f)); + *pDest++ = static_cast(static_cast(pSrcVertex->BoneWeights.y * 255.0f)); + *pDest++ = static_cast(static_cast(pSrcVertex->BoneWeights.z * 255.0f)); + *pDest++ = static_cast(static_cast(pSrcVertex->BoneWeights.w * 255.0f)); NormalizeBoneWeights(pBoneWeights); *pDest++ = pSrcVertex->BoneIndices.x; *pDest++ = pSrcVertex->BoneIndices.y; diff --git a/exportobjects/exportscene.cpp b/exportobjects/exportscene.cpp index f284122..a1b0377 100644 --- a/exportobjects/exportscene.cpp +++ b/exportobjects/exportscene.cpp @@ -58,7 +58,7 @@ ExportScene::~ExportScene() { { ExportAnimationList::iterator iter = m_vAnimations.begin(); - ExportAnimationList::iterator end = m_vAnimations.end(); + const ExportAnimationList::iterator end = m_vAnimations.end(); while (iter != end) { delete* iter; @@ -68,7 +68,7 @@ ExportScene::~ExportScene() } { ExportMeshBaseList::iterator iter = m_vMeshes.begin(); - ExportMeshBaseList::iterator end = m_vMeshes.end(); + const ExportMeshBaseList::iterator end = m_vMeshes.end(); while (iter != end) { delete* iter; @@ -78,7 +78,7 @@ ExportScene::~ExportScene() } { ExportMaterialList::iterator iter = m_vMaterials.begin(); - ExportMaterialList::iterator end = m_vMaterials.end(); + const ExportMaterialList::iterator end = m_vMaterials.end(); while (iter != end) { delete* iter; diff --git a/exportobjects/exportsettings.cpp b/exportobjects/exportsettings.cpp index 55d3ba6..ad01cf8 100644 --- a/exportobjects/exportsettings.cpp +++ b/exportobjects/exportsettings.cpp @@ -445,6 +445,8 @@ bool ExportSettingsManager::UnMarshalAllSettings(const CHAR* strSrcBuffer) pToken = strtok_s(nullptr, strDelimiters, &strNextToken); } + strSrcTokenized.reset(); + return true; } @@ -532,6 +534,7 @@ bool ExportSettingsManager::SaveSettings(const CHAR* strFileName) { fputs(strBuffer.get(), fp); fclose(fp); + strBuffer.reset(); return true; } else @@ -565,6 +568,7 @@ bool ExportSettingsManager::LoadSettings(const CHAR* strFileName) assert(dwReadBytes < dwBufferSize); strBuffer[dwReadBytes] = '\0'; const bool bSuccess = UnMarshalAllSettings(strBuffer.get()); + strBuffer.reset(); return bSuccess; } } diff --git a/exportobjects/exportsettingsdialog.cpp b/exportobjects/exportsettingsdialog.cpp index 6edbe8e..6743f5f 100644 --- a/exportobjects/exportsettingsdialog.cpp +++ b/exportobjects/exportsettingsdialog.cpp @@ -433,6 +433,9 @@ LRESULT ExportSettingsDialog::OnCommand(WORD wNotifyCode, WORD idCtrl, HWND hwnd else m_DialogState = DS_HIDDEN_CANCELED; return 0; + + default: + break; } break; case IDC_DYNAMICCONTROL: @@ -470,6 +473,9 @@ LRESULT ExportSettingsDialog::OnCommand(WORD wNotifyCode, WORD idCtrl, HWND hwnd } return true; } + + default: + break; } return false; } @@ -600,6 +606,9 @@ LRESULT ExportSettingsDialog::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) pEntry->SetValue(GetFloatFromNormalizedInt(pEntry, iPos)); return false; } + + default: + break; } return false; } @@ -623,8 +632,14 @@ LRESULT ExportSettingsDialog::OnNotify(INT idCtrl, LPNMHDR pnmh) PopulateControls(); return true; } + + default: + break; } return true; + + default: + break; } return false; } diff --git a/exportobjects/exportstring.h b/exportobjects/exportstring.h index dbba757..7112f4f 100644 --- a/exportobjects/exportstring.h +++ b/exportobjects/exportstring.h @@ -95,7 +95,7 @@ namespace ATG StringList& CurrentList = s_StringLists[uBucketIndex]; StringList::iterator iter = CurrentList.begin(); - StringList::iterator end = CurrentList.end(); + const StringList::iterator end = CurrentList.end(); while (iter != end) { diff --git a/exportobjects/exportsubd.cpp b/exportobjects/exportsubd.cpp index 9614058..403adc3 100644 --- a/exportobjects/exportsubd.cpp +++ b/exportobjects/exportsubd.cpp @@ -354,7 +354,7 @@ void ExportSubDProcessMesh::BuildBoundaryEdgeTable() m_IncidentBoundaryEdgesPerPosition.resize(dwPositionCount, 0); EdgeMap::iterator iter = m_BoundaryEdges.begin(); - EdgeMap::iterator end = m_BoundaryEdges.end(); + const EdgeMap::iterator end = m_BoundaryEdges.end(); while (iter != end) { const Edge& BoundaryEdge = (*iter).second; @@ -416,7 +416,7 @@ INT ExportSubDProcessMesh::AddOrRemoveEdge(INT iPositionIndexA, INT iPositionInd } // search for the edge in the table - EdgeMap::iterator iter = m_BoundaryEdges.find(EdgeHashKey); + const EdgeMap::iterator iter = m_BoundaryEdges.find(EdgeHashKey); if (iter == m_BoundaryEdges.end()) { @@ -452,7 +452,7 @@ void ExportSubDProcessMesh::CreateDegenerateGeometry() // walk through the boundary edges EdgeMap::iterator iter = m_BoundaryEdges.begin(); - EdgeMap::iterator end = m_BoundaryEdges.end(); + const EdgeMap::iterator end = m_BoundaryEdges.end(); while (iter != end) { const Edge& BoundaryEdge = (*iter).second; diff --git a/importfbx/ImportFBX2019.vcxproj b/importfbx/ImportFBX2019.vcxproj index 8c69eda..3189eaf 100644 --- a/importfbx/ImportFBX2019.vcxproj +++ b/importfbx/ImportFBX2019.vcxproj @@ -64,6 +64,12 @@ ContentExporter ContentExporter + + BuildLink + + + BuildLink + Disabled @@ -94,6 +100,12 @@ MultiplyDefinedSymbolOnly /IGNORE:4075 /IGNORE:4099 %(AdditionalOptions) + + copy "%25FBX_SDK%25\lib\x64\debug\*.dll" $(OutDir) + Copying Autodesk DLL + true + $(OutDir)\libfbxsdk.dll + @@ -129,6 +141,12 @@ MultiplyDefinedSymbolOnly /IGNORE:4075 /IGNORE:4099 %(AdditionalOptions) + + copy "%25FBX_SDK%25\lib\x64\debug\*.dll" $(OutDir) + Copying Autodesk DLL + $(OutDir)\libfbxsdk.dll + true + @@ -157,6 +175,9 @@ + + {4d1b88df-35bf-4771-aba2-45559f4a9078} + {6afa24fb-37b3-49d3-9832-f7ea3de3ca2e} diff --git a/importfbx/consolemain.cpp b/importfbx/consolemain.cpp index 16d3216..1088cf9 100644 --- a/importfbx/consolemain.cpp +++ b/importfbx/consolemain.cpp @@ -86,6 +86,7 @@ enum ExportFileFormat FILEFORMAT_XATG = 0, FILEFORMAT_SDKMESH = 1, FILEFORMAT_SDKMESH_V2 = 2, + FILEFORMAT_CMO = 3, }; INT g_ExportFileFormat = FILEFORMAT_SDKMESH; @@ -269,6 +270,12 @@ bool MacroXboxOne(const CHAR* /*strArgument*/, bool& /*bUsedArgument*/) return true; } +bool MacroCMO(const CHAR* /*strArgument*/, bool& /*bUsedArgument*/) +{ + g_ExportFileFormat = FILEFORMAT_CMO; + return true; +} + bool MacroSDKMesh(const CHAR* /*strArgument*/, bool& /*bUsedArgument*/) { g_ExportFileFormat = FILEFORMAT_SDKMESH; @@ -429,9 +436,10 @@ MacroCommand g_MacroCommands[] = { { "?", "", "Display help", MacroDisplayHelp }, { "outputpath", " ", "Sets the output root path; files will appear in scenes/ and textures/ subdirectories", MacroSetOutputPath }, { "verbose", "", "Displays more detailed output, equivalent to -loglevel 4", MacroSetVerbose }, - { "xatg", "", "Use the XATG output file format, equivalent to -fileformat xatg", MacroXATG }, + { "cmo", "", "Use the CMO output file format, equivalent to -fileformat cmo", MacroCMO }, { "sdkmesh", "", "Use the SDKMESH output file format, equivalent to -fileformat sdkmesh", MacroSDKMesh }, { "sdkmesh2", "", "Use the SDKMESH (version 2) output file format, equivalent to -fileformat sdkmesh2", MacroSDKMesh2 }, + { "xatg", "", "Use the XATG output file format, equivalent to -fileformat xatg", MacroXATG }, { "xbox360", "", "Sets export options for an Xbox 360 target", MacroXbox360 }, { "xboxone", "", "Sets export options for an Xbox One target", MacroXboxOne }, { "windowsd3d9", "", "Sets export options for a Windows Direct3D 9 target", MacroWindowsD3D9 }, @@ -763,13 +771,20 @@ void BuildOutputFileName(const ExportPath& InputFileName) g_CurrentOutputFileName.ChangeFileName(InputFileName); - if (g_ExportFileFormat == FILEFORMAT_SDKMESH || g_ExportFileFormat == FILEFORMAT_SDKMESH_V2) + switch (g_ExportFileFormat) { + case FILEFORMAT_SDKMESH: + case FILEFORMAT_SDKMESH_V2: g_CurrentOutputFileName.ChangeExtension(CONTENT_EXPORTER_BINARYFILE_EXTENSION); - } - else - { + break; + + case FILEFORMAT_CMO: + g_CurrentOutputFileName.ChangeExtension(CONTENT_EXPORTER_CMO_EXTENSION); + break; + + default: g_CurrentOutputFileName.ChangeExtension(CONTENT_EXPORTER_FILE_EXTENSION); + break; } } @@ -805,6 +820,7 @@ int __cdecl main(_In_ int argc, _In_z_count_(argc) char* argv[]) { CONTENT_EXPORTER_FILE_FILTER_DESCRIPTION, CONTENT_EXPORTER_FILE_EXTENSION, FILEFORMAT_XATG }, { CONTENT_EXPORTER_BINARYFILE_FILTER_DESCRIPTION, CONTENT_EXPORTER_BINARYFILE_EXTENSION, FILEFORMAT_SDKMESH }, { CONTENT_EXPORTER_BINARYFILE_FILTER_DESCRIPTION_V2, "sdkmesh2", FILEFORMAT_SDKMESH_V2 }, + { CONTENT_EXPORTER_CMO_FILTER_DESCRIPTION, "cmo", FILEFORMAT_CMO }, }; g_SettingsManager.AddEnum(g_SettingsManager.GetRootCategory(0), "Output File Format", "fileformat", FILEFORMAT_SDKMESH, FileFormatEnums, ARRAYSIZE(FileFormatEnums), &g_ExportFileFormat); @@ -907,33 +923,56 @@ int __cdecl main(_In_ int argc, _In_z_count_(argc) char* argv[]) if (SUCCEEDED(hr)) { - if (g_ExportFileFormat == FILEFORMAT_SDKMESH || g_ExportFileFormat == FILEFORMAT_SDKMESH_V2) + switch (g_ExportFileFormat) { + case FILEFORMAT_SDKMESH: + case FILEFORMAT_SDKMESH_V2: ExportTextureConverter::ProcessScene(g_pScene, &g_Manifest, "", true); - WriteSDKMeshFile(g_CurrentOutputFileName, &g_Manifest, (g_ExportFileFormat == FILEFORMAT_SDKMESH_V2) ? true : false); + if (!WriteSDKMeshFile(g_CurrentOutputFileName, &g_Manifest, (g_ExportFileFormat == FILEFORMAT_SDKMESH_V2) ? true : false)) + { + ExportLog::LogError("Could not write SDKMESH \"%s\".", (const CHAR*)g_CurrentOutputFileName); + return 1; + } if (bExportMaterials) { ExportTextureConverter::PerformTextureFileOperations(&g_Manifest); } - } - else - { + break; + + case FILEFORMAT_CMO: + if (!WriteCMOFile(g_CurrentOutputFileName, &g_Manifest)) + { + ExportLog::LogError("Could not write CMO \"%s\".", (const CHAR*)g_CurrentOutputFileName); + return 1; + } + break; + + default: if (g_XATGSettings.bBundleTextures && bExportMaterials) { ExportTextureConverter::ProcessScene(g_pScene, &g_Manifest, "textures\\", false); - WriteXATGFile(g_CurrentOutputFileName, &g_Manifest); + if (!WriteXATGFile(g_CurrentOutputFileName, &g_Manifest)) + { + ExportLog::LogError("Could not write XATG \"%s\".", (const CHAR*)g_CurrentOutputFileName); + return 1; + } ExportTextureConverter::PerformTextureFileOperations(&g_Manifest); BundleTextures(); } else { ExportTextureConverter::ProcessScene(g_pScene, &g_Manifest, "textures\\", true); - WriteXATGFile(g_CurrentOutputFileName, &g_Manifest); + if (!WriteXATGFile(g_CurrentOutputFileName, &g_Manifest)) + { + ExportLog::LogError("Could not write XATG \"%s\".", (const CHAR*)g_CurrentOutputFileName); + return 1; + } if (bExportMaterials) { ExportTextureConverter::PerformTextureFileOperations(&g_Manifest); } } + break; } } diff --git a/importfbx/stdafx.h b/importfbx/stdafx.h index 47aad60..749b284 100644 --- a/importfbx/stdafx.h +++ b/importfbx/stdafx.h @@ -63,8 +63,9 @@ #include #pragma warning(pop) -#include "..\XATGFileWriter\XATGFileWriter.h" +#include "..\cmofilewriter\CMOFileWriter.h" #include "..\SDKMeshFileWriter\SDKMeshFileWriter.h" +#include "..\XATGFileWriter\XATGFileWriter.h" #define CONTENT_EXPORTER_TITLE CONTENT_EXPORTER_GLOBAL_TITLE " for FBX" extern CHAR g_strExporterName[100]; diff --git a/sdkmeshfilewriter/sdkmeshfilewriter.cpp b/sdkmeshfilewriter/sdkmeshfilewriter.cpp index 95c5b45..b0a8a69 100644 --- a/sdkmeshfilewriter/sdkmeshfilewriter.cpp +++ b/sdkmeshfilewriter/sdkmeshfilewriter.cpp @@ -75,7 +75,7 @@ namespace ATG DWORD CaptureMaterial(ExportMaterial* pMaterial, bool version2) { - MaterialLookupMap::iterator iter = g_ExportMaterialToSDKMeshMaterialMap.find(pMaterial); + const MaterialLookupMap::iterator iter = g_ExportMaterialToSDKMeshMaterialMap.find(pMaterial); if (iter != g_ExportMaterialToSDKMeshMaterialMap.end()) { return iter->second; @@ -931,7 +931,7 @@ namespace ATG SDKANIMATION_FILE_HEADER AnimHeader = {}; - const size_t dwKeyCount = size_t(pAnim->GetDuration() / pAnim->fSourceFrameInterval); + const size_t dwKeyCount = size_t(static_cast(pAnim->GetDuration() / pAnim->fSourceFrameInterval)); const size_t dwTrackHeadersDataSize = dwTrackCount * sizeof(SDKANIMATION_FRAME_DATA); const size_t dwSingleTrackDataSize = dwKeyCount * sizeof(SDKANIMATION_DATA); @@ -939,7 +939,7 @@ namespace ATG AnimHeader.IsBigEndian = !g_pScene->Settings().bLittleEndian; AnimHeader.FrameTransformType = FTT_RELATIVE; AnimHeader.NumAnimationKeys = static_cast(dwKeyCount); - AnimHeader.AnimationFPS = static_cast(1.001f / pAnim->fSourceFrameInterval); + AnimHeader.AnimationFPS = static_cast(static_cast(1.001f / pAnim->fSourceFrameInterval)); AnimHeader.NumFrames = static_cast(dwTrackCount); AnimHeader.AnimationDataSize = dwTrackHeadersDataSize + dwTrackCount * dwSingleTrackDataSize; AnimHeader.AnimationDataOffset = sizeof(SDKANIMATION_FILE_HEADER); diff --git a/xatgfilewriter/xatgfilewriter.cpp b/xatgfilewriter/xatgfilewriter.cpp index 37f394c..e689d76 100644 --- a/xatgfilewriter/xatgfilewriter.cpp +++ b/xatgfilewriter/xatgfilewriter.cpp @@ -387,7 +387,7 @@ namespace ATG // serialize effect parameters const MaterialParameterList* pParameters = pMaterial->GetParameterList(); MaterialParameterList::const_iterator iter = pParameters->begin(); - MaterialParameterList::const_iterator end = pParameters->end(); + const MaterialParameterList::const_iterator end = pParameters->end(); while (iter != end) { const ExportMaterialParameter& ParamDesc = *iter;