aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-x[-rw-r--r--]tools/ApexImporter/src/ApexDestructibleObjExporter.cpp230
-rwxr-xr-x[-rw-r--r--]tools/ApexImporter/src/ApexDestructibleObjExporter.h154
-rwxr-xr-x[-rw-r--r--]tools/ApexImporter/src/Main.cpp683
-rwxr-xr-x[-rw-r--r--]tools/AuthoringTool/src/AuthoringTool.cpp1489
-rwxr-xr-x[-rw-r--r--]tools/AuthoringTool/src/SimpleRandomGenerator.h52
-rwxr-xr-x[-rw-r--r--]tools/CMakeLists.txt190
-rwxr-xr-x[-rw-r--r--]tools/LegacyConverter/src/Main.cpp658
-rwxr-xr-x[-rw-r--r--]tools/common/BlastDataExporter.cpp282
-rwxr-xr-x[-rw-r--r--]tools/common/BlastDataExporter.h198
-rwxr-xr-x[-rw-r--r--]tools/common/Log.cpp174
-rwxr-xr-x[-rw-r--r--]tools/common/Log.h300
-rwxr-xr-x[-rw-r--r--]tools/common/Utils.cpp388
-rwxr-xr-x[-rw-r--r--]tools/common/Utils.h282
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/ApexImporter.cmake162
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/AuthoringTool.cmake170
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/LegacyConverter.cmake126
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/Windows/ApexImporter.cmake40
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/Windows/AuthoringTool.cmake42
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/Windows/CMakeLists.txt102
-rwxr-xr-x[-rw-r--r--]tools/compiler/cmake/Windows/LegacyConverter.cmake40
20 files changed, 2911 insertions, 2851 deletions
diff --git a/tools/ApexImporter/src/ApexDestructibleObjExporter.cpp b/tools/ApexImporter/src/ApexDestructibleObjExporter.cpp
index 3de7418..0dff785 100644..100755
--- a/tools/ApexImporter/src/ApexDestructibleObjExporter.cpp
+++ b/tools/ApexImporter/src/ApexDestructibleObjExporter.cpp
@@ -1,115 +1,115 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "ApexDestructibleObjExporter.h"
-
-#include "Log.h"
-
-#include "PsFastXml.h"
-#include "PsFileBuffer.h"
-#include <PxVec2.h>
-#include <PxVec3.h>
-#include <map>
-#include <NvBlastExtExporter.h>
-#include <NvBlastExtAuthoringTypes.h>
-
-
-
-using namespace nvidia;
-using namespace Nv::Blast;
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Material Parser
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-bool ApexDestructibleGeometryExporter::exportToFile(NvBlastAsset* asset, const NvParameterized::Interface* dmeshIfs, ApexImporter::ApexImportTool& tool, const std::string& name,
- const std::vector<uint32_t>& chunkReorderInvMap, bool toFbx, bool toObj, bool fbxascii, bool nonSkinned, const std::vector<std::vector<CollisionHull*> >& hulls)
-{
-
- Nv::Blast::ExporterMeshData meshData;
- meshData.asset = asset;
- tool.importRendermesh(chunkReorderInvMap, dmeshIfs, &meshData, m_materialsDir.c_str());
-
- if (!hulls.empty())
- {
- meshData.hullsOffsets = new uint32_t[hulls.size() + 1]{ 0 };
- for (uint32_t i = 0; i < hulls.size(); i++)
- {
- meshData.hullsOffsets[i + 1] = meshData.hullsOffsets[i] + (uint32_t)hulls[i].size();
- }
- meshData.hulls = new CollisionHull*[meshData.hullsOffsets[hulls.size()]];
- for (uint32_t i = 0; i < hulls.size(); i++)
- {
- for (uint32_t j = 0; j < hulls[i].size(); j++)
- {
- meshData.hulls[meshData.hullsOffsets[i] + j] = hulls[i][j];
- }
- }
- }
- else
- {
- meshData.hulls = nullptr;
- meshData.hullsOffsets = nullptr;
- }
- if (toObj)
- {
- IMeshFileWriter* fileWriter = NvBlastExtExporterCreateObjFileWriter();
- fileWriter->appendMesh(meshData, name.c_str());
- fileWriter->saveToFile(name.c_str(), m_exportDir.c_str());
- fileWriter->release();
- //writer.saveToFile(asset, name, m_exportDir, compressedPositions, compressedNormals, compressedTextures, pInd, nInd, tInd, materialPathes, submeshCount);
- }
- if (toFbx)
- {
- IMeshFileWriter* fileWriter = NvBlastExtExporterCreateFbxFileWriter(fbxascii);
- fileWriter->appendMesh(meshData, name.c_str(), nonSkinned);
- fileWriter->saveToFile(name.c_str(), m_exportDir.c_str());
- fileWriter->release();
- }
-
- delete[] meshData.hulls;
- delete[] meshData.hullsOffsets;
- delete[] meshData.normals;
- delete[] meshData.normIndex;
- delete[] meshData.posIndex;
- delete[] meshData.positions;
- delete[] meshData.submeshOffsets;
- delete[] meshData.texIndex;
-
- delete[] meshData.uvs;
-
- for (uint32_t i = 0; i < meshData.submeshCount; ++i)
- {
- delete[] meshData.submeshMats[i].diffuse_tex;
- delete[] meshData.submeshMats[i].name;
- }
- delete[] meshData.submeshMats;
-
- return true;
-}
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "ApexDestructibleObjExporter.h"
+
+#include "Log.h"
+
+#include "PsFastXml.h"
+#include "PsFileBuffer.h"
+#include <PxVec2.h>
+#include <PxVec3.h>
+#include <map>
+#include <NvBlastExtExporter.h>
+#include <NvBlastExtAuthoringTypes.h>
+
+
+
+using namespace nvidia;
+using namespace Nv::Blast;
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Material Parser
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool ApexDestructibleGeometryExporter::exportToFile(NvBlastAsset* asset, const NvParameterized::Interface* dmeshIfs, ApexImporter::ApexImportTool& tool, const std::string& name,
+ const std::vector<uint32_t>& chunkReorderInvMap, bool toFbx, bool toObj, bool fbxascii, bool nonSkinned, const std::vector<std::vector<CollisionHull*> >& hulls)
+{
+
+ Nv::Blast::ExporterMeshData meshData;
+ meshData.asset = asset;
+ tool.importRendermesh(chunkReorderInvMap, dmeshIfs, &meshData, m_materialsDir.c_str());
+
+ if (!hulls.empty())
+ {
+ meshData.hullsOffsets = new uint32_t[hulls.size() + 1]{ 0 };
+ for (uint32_t i = 0; i < hulls.size(); i++)
+ {
+ meshData.hullsOffsets[i + 1] = meshData.hullsOffsets[i] + (uint32_t)hulls[i].size();
+ }
+ meshData.hulls = new CollisionHull*[meshData.hullsOffsets[hulls.size()]];
+ for (uint32_t i = 0; i < hulls.size(); i++)
+ {
+ for (uint32_t j = 0; j < hulls[i].size(); j++)
+ {
+ meshData.hulls[meshData.hullsOffsets[i] + j] = hulls[i][j];
+ }
+ }
+ }
+ else
+ {
+ meshData.hulls = nullptr;
+ meshData.hullsOffsets = nullptr;
+ }
+ if (toObj)
+ {
+ IMeshFileWriter* fileWriter = NvBlastExtExporterCreateObjFileWriter();
+ fileWriter->appendMesh(meshData, name.c_str());
+ fileWriter->saveToFile(name.c_str(), m_exportDir.c_str());
+ fileWriter->release();
+ //writer.saveToFile(asset, name, m_exportDir, compressedPositions, compressedNormals, compressedTextures, pInd, nInd, tInd, materialPathes, submeshCount);
+ }
+ if (toFbx)
+ {
+ IMeshFileWriter* fileWriter = NvBlastExtExporterCreateFbxFileWriter(fbxascii);
+ fileWriter->appendMesh(meshData, name.c_str(), nonSkinned);
+ fileWriter->saveToFile(name.c_str(), m_exportDir.c_str());
+ fileWriter->release();
+ }
+
+ delete[] meshData.hulls;
+ delete[] meshData.hullsOffsets;
+ delete[] meshData.normals;
+ delete[] meshData.normIndex;
+ delete[] meshData.posIndex;
+ delete[] meshData.positions;
+ delete[] meshData.submeshOffsets;
+ delete[] meshData.texIndex;
+
+ delete[] meshData.uvs;
+
+ for (uint32_t i = 0; i < meshData.submeshCount; ++i)
+ {
+ delete[] meshData.submeshMats[i].diffuse_tex;
+ delete[] meshData.submeshMats[i].name;
+ }
+ delete[] meshData.submeshMats;
+
+ return true;
+}
diff --git a/tools/ApexImporter/src/ApexDestructibleObjExporter.h b/tools/ApexImporter/src/ApexDestructibleObjExporter.h
index 26077e5..c4cf859 100644..100755
--- a/tools/ApexImporter/src/ApexDestructibleObjExporter.h
+++ b/tools/ApexImporter/src/ApexDestructibleObjExporter.h
@@ -1,77 +1,77 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#ifndef OBJ_APEX_EXPORTER_H
-#define OBJ_APEX_EXPORTER_H
-
-#include <string>
-#include <vector>
-#include <NvBlastExtAuthoringCollisionBuilder.h>
-#include <NvBlastExtApexImportTool.h>
-
-
-
-namespace physx
-{
- class PxVec3;
- class PxVec2;
-}
-
-struct NvBlastAsset;
-
-namespace Nv
-{
-namespace Blast
-{
-
-class ApexDestructibleGeometryExporter
-{
-public:
- ApexDestructibleGeometryExporter(std::string materialsDir, std::string exportDir) : m_materialsDir(materialsDir), m_exportDir(exportDir)
- {}
-
- bool exportToFile(NvBlastAsset* asset, const NvParameterized::Interface* dmeshIfs, ApexImporter::ApexImportTool& tool, const std::string& name,
- const std::vector<uint32_t>& chunkReorderInvMap, bool toFbx, bool toObj, bool fbxascii, bool nonSkinned,
- const std::vector<std::vector<CollisionHull*> >& hulls = std::vector<std::vector<CollisionHull*> >());
-
-private:
- ApexDestructibleGeometryExporter& operator=(const ApexDestructibleGeometryExporter&)
- {
- return *this;
- }
- const std::string m_materialsDir;
- const std::string m_exportDir;
-
-};
-
-
-} // namespace Blast
-} // namespace Nv
-
-
-#endif //OBJ_EXPORTER_H
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef OBJ_APEX_EXPORTER_H
+#define OBJ_APEX_EXPORTER_H
+
+#include <string>
+#include <vector>
+#include <NvBlastExtAuthoringCollisionBuilder.h>
+#include <NvBlastExtApexImportTool.h>
+
+
+
+namespace physx
+{
+ class PxVec3;
+ class PxVec2;
+}
+
+struct NvBlastAsset;
+
+namespace Nv
+{
+namespace Blast
+{
+
+class ApexDestructibleGeometryExporter
+{
+public:
+ ApexDestructibleGeometryExporter(std::string materialsDir, std::string exportDir) : m_materialsDir(materialsDir), m_exportDir(exportDir)
+ {}
+
+ bool exportToFile(NvBlastAsset* asset, const NvParameterized::Interface* dmeshIfs, ApexImporter::ApexImportTool& tool, const std::string& name,
+ const std::vector<uint32_t>& chunkReorderInvMap, bool toFbx, bool toObj, bool fbxascii, bool nonSkinned,
+ const std::vector<std::vector<CollisionHull*> >& hulls = std::vector<std::vector<CollisionHull*> >());
+
+private:
+ ApexDestructibleGeometryExporter& operator=(const ApexDestructibleGeometryExporter&)
+ {
+ return *this;
+ }
+ const std::string m_materialsDir;
+ const std::string m_exportDir;
+
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif //OBJ_EXPORTER_H
diff --git a/tools/ApexImporter/src/Main.cpp b/tools/ApexImporter/src/Main.cpp
index 02839b1..c7b5897 100644..100755
--- a/tools/ApexImporter/src/Main.cpp
+++ b/tools/ApexImporter/src/Main.cpp
@@ -1,323 +1,360 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#if NV_VC
-#pragma warning(push)
-#pragma warning(disable: 4996) // 'fopen' unsafe warning, from NxFileBuffer.h
-#endif
-
-#include "PxPhysicsAPI.h"
-#include "NvBlastExtApexImportTool.h"
-#include "Log.h"
-#include <string>
-#include <iostream>
-#include <fstream>
-#include "tclap/CmdLine.h"
-#include "ApexDestructibleObjExporter.h"
-#include "NvBlastTkFramework.h"
-#include "NvBlastGlobals.h"
-#include "NvBlastExtPxAsset.h"
-#include "NvBlastExtPxManager.h"
-#include "BlastDataExporter.h"
-#include "windows.h"
-#include <NvBlastTkAsset.h>
-#include "NvBlastExtLlSerialization.h"
-#include "NvBlastExtTkSerialization.h"
-#include "NvBlastExtPxSerialization.h"
-#include <nvparameterized\NvSerializer.h>
-#include <PsFileBuffer.h>
-#define DEFAULT_INPUT_FILE "../../../tools/ApexImporter/resources/assets/table.apb"
-#define DEFAULT_OUTPUT_DIR "C:/TestFracturer/"
-#define DEFAULT_ASSET_NAME "table"
-
-using namespace Nv::Blast;
-using namespace Nv::Blast::ApexImporter;
-
-void loggingCallback(int type, const char* msg, const char* file, int line)
-{
- if (type == NvBlastMessage::Info)
- lout() << Log::TYPE_INFO << msg << " FILE:" << file << " Line: " << line << "\n";
- else
- lout() << Log::TYPE_ERROR << msg << " FILE:" << file << " Line: " << line << "\n";
-}
-
-bool isDirectoryExist(std::string path)
-{
- DWORD attributes = GetFileAttributesA(path.c_str());
- if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- return true;
- }
- return false;
-}
-
-bool mkDirRecursively(std::string path)
-{
- if (isDirectoryExist(path))
- {
- return true;
- }
- auto indx = path.find_first_of("\\/");
- while (indx != std::string::npos)
- {
- std::string subfolder = path.substr(0, indx);
- CreateDirectory(subfolder.c_str(), NULL);
- indx = path.find_first_of("\\/", indx + 1);
- }
- return isDirectoryExist(path);
-}
-
-// Create an Asset from the APEX destructible asset
-void run(const std::string& inFilepath, const std::string& outDir, const std::string& assetName, uint32_t mode, bool llFlag, bool tkFlag, bool extPxFlag, bool obj, bool fbx, bool fbxascii, bool fbxCollision, bool nonSkinned)
-{
- std::string inputDir = inFilepath.substr(0, inFilepath.find_last_of("/\\"));
-
- // load APEX
- ApexImportTool blast;
-
- lout() << Log::TYPE_INFO << "ApexImportTool initialization" << std::endl;
- if (!blast.isValid())
- {
- lout() << Log::TYPE_ERROR << "Failed to create BlastSDK" << std::endl;
- return;
- }
-
-
- // load asset
- lout() << Log::TYPE_INFO << "Loading asset: " << inFilepath << std::endl;
- physx::PxFileBuf* apexAssetStream = PX_NEW(physx::general_PxIOStream::PsFileBuffer)(inFilepath.c_str(), physx::PxFileBuf::OPEN_READ_ONLY);
-
- NvParameterized::Serializer::DeserializedData data;
- blast.loadAssetFromFile(apexAssetStream, data);
- if (data.size() == 0)
- {
- return;
- }
- apexAssetStream->release();
-
- ApexImporterConfig config;
- config.infSearchMode = static_cast<ApexImporterConfig::InterfaceSearchMode>(mode);
-
- std::vector<uint32_t> chunkReorderInvMap;
- TkFramework* framework = NvBlastTkFrameworkCreate();
- if (framework == nullptr)
- {
- lout() << Log::TYPE_ERROR << "Failed to create TkFramework" << std::endl;
- return;
- }
-
- std::vector<NvBlastChunkDesc> chunkDesc;
- std::vector<NvBlastBondDesc> bondDescs;
- std::vector<uint32_t> flags;
-
- std::vector<ExtPxAssetDesc::ChunkDesc> physicsChunks;
- std::vector<ExtPxAssetDesc::SubchunkDesc> physicsSubchunks;
-
- bool result = blast.importApexAsset(chunkReorderInvMap, data[0], chunkDesc, bondDescs, flags, config);
- if (!result)
- {
- lout() << Log::TYPE_ERROR << "Failed to build Blast asset data" << std::endl;
- return;
- };
- std::vector<std::vector<CollisionHull*>> hulls;
- result = blast.getCollisionGeometry(data[0], static_cast<uint32_t>(chunkDesc.size()), chunkReorderInvMap, flags, physicsChunks, physicsSubchunks, hulls);
- if (!result)
- {
- lout() << Log::TYPE_ERROR << "Failed to build physics data" << std::endl;
- return;
- };
-
-
- // save asset
- lout() << Log::TYPE_INFO << "Saving blast asset: " << outDir << std::endl;
- BlastDataExporter blExpr(framework, blast.getPxSdk(), blast.getCooking());
- NvBlastAsset* llAsset = blExpr.createLlBlastAsset(bondDescs, chunkDesc);
-
- std::cout <<"Chunk count: " << NvBlastAssetGetChunkCount(llAsset, NULL) << std::endl;
-
- if (llAsset == nullptr && (llFlag || fbx))
- {
- lout() << Log::TYPE_ERROR << "Failed to build low-level asset" << std::endl;
- return;
- }
-
- if (llFlag)
- {
- blExpr.saveBlastObject(outDir, assetName, llAsset, LlObjectTypeID::Asset);
- }
- if (tkFlag)
- {
- TkAsset* tkAsset = blExpr.createTkBlastAsset(bondDescs, chunkDesc);
- blExpr.saveBlastObject(outDir, assetName, tkAsset, TkObjectTypeID::Asset);
- tkAsset->release();
- }
- if (extPxFlag)
- {
- ExtPxAsset* pxAsset = blExpr.createExtBlastAsset(bondDescs, chunkDesc, physicsChunks);
- blExpr.saveBlastObject(outDir, assetName, pxAsset, ExtPxObjectTypeID::Asset);
- pxAsset->release();
- }
-
- lout() << Log::TYPE_INFO << "Saving model file: " << outDir << std::endl;
- ApexDestructibleGeometryExporter objSaver(inputDir, outDir);
- if (fbxCollision)
- {
- objSaver.exportToFile(llAsset, data[0], blast, assetName, chunkReorderInvMap, fbx, obj, fbxascii, nonSkinned, hulls);
- }
- else
- {
- objSaver.exportToFile(llAsset, data[0], blast, assetName, chunkReorderInvMap, fbx, obj, fbxascii, nonSkinned);
- }
- NVBLAST_FREE(llAsset);
-}
-
-
-int main(int argc, const char* const* argv)
-{
- try
- {
- // setup cmd line
- TCLAP::CmdLine cmd("Blast SDK: APEX Importer", ' ', "0.1");
-
- TCLAP::ValueArg<std::string> infileArg("f", "file", "File to load", true, DEFAULT_INPUT_FILE, "infile");
- cmd.add(infileArg);
-
- TCLAP::ValueArg<std::string> outDirArg("o", "outputDir", "Output directory", false, DEFAULT_OUTPUT_DIR, "output directory");
- cmd.add(outDirArg);
-
- TCLAP::ValueArg<std::string> outAssetName("n", "outAssetName", "Output asset name", true, DEFAULT_ASSET_NAME, "output asset name");
- cmd.add(outAssetName);
-
-
- TCLAP::ValueArg<uint32_t> interfaceSearchMode("m", "mode", "Interface search mode", false, 0, "0 - EXACT, 1 - FORCED, for detailed description see docs.");
- cmd.add(interfaceSearchMode);
-
- TCLAP::SwitchArg debugSwitch("d", "debug", "Print debug output", cmd, false);
-
- TCLAP::SwitchArg pxOutputArg("", "px", "Output ExtPxAsset to the output directory", false);
- cmd.add(pxOutputArg);
-
- TCLAP::SwitchArg tkOutputArg("", "tk", "Output TkAsset to the output directory", false);
- cmd.add(tkOutputArg);
-
- TCLAP::SwitchArg llOutputArg("", "ll", "Output LL Blast asset to the output directory", false);
- cmd.add(llOutputArg);
-
- TCLAP::SwitchArg fbxAsciiArg("", "fbxascii", "Output FBX as an ascii file (defaults to binary output)", false);
- cmd.add(fbxAsciiArg);
-
- TCLAP::SwitchArg objOutputArg("", "obj", "Output a OBJ mesh to the output directory", false);
- cmd.add(objOutputArg);
-
- TCLAP::SwitchArg fbxOutputArg("", "fbx", "Output a FBX mesh to the output directory", false);
- cmd.add(fbxOutputArg);
-
- TCLAP::SwitchArg fbxcollision("", "fbxcollision", "Append collision geometry to FBX file", false);
- cmd.add(fbxcollision);
-
- TCLAP::SwitchArg nonSkinnedFBX("", "nonskinned", "Output a non-skinned FBX file", false);
- cmd.add(nonSkinnedFBX);
-
- // parse cmd input
- cmd.parse(argc, argv);
-
- bool bOutputPX = pxOutputArg.getValue();
- bool bOutputTK = tkOutputArg.getValue();
- bool bOutputLL = llOutputArg.getValue();
-
- bool bOutputFBXAscii = fbxAsciiArg.isSet();
-
- bool bOutputObjFile = objOutputArg.isSet();
- bool bOutputFbxFile = fbxOutputArg.isSet();
-
- bool bFbxCollision = fbxcollision.isSet();
- bool bNonSkinned = nonSkinnedFBX.isSet();
-
- // Did we specify no output formats?
- if (!pxOutputArg.isSet() && !tkOutputArg.isSet() && !llOutputArg.isSet())
- {
- std::cout << "Didn't specify an output format on the command line, so defaulting to outputting an ExtPxAsset" << std::endl;
- bOutputPX = true;
- }
- // Did we specify no geometry output formats?
- if (!bOutputObjFile && !bOutputFbxFile)
- {
- std::cout << "Didn't specify an output geometry format on the command line, so defaulting to outputting .OBJ" << std::endl;
- bOutputObjFile = true;
- }
-
- // get cmd parse results
- std::string infile = infileArg.getValue();
- std::string outDir;
- std::string assetName = outAssetName.getValue();
-
- /**
- Set output dir, make sure that it exist.
- */
- if (outDirArg.isSet())
- {
- outDir = outDirArg.getValue();
- std::string temp = outDir + '/';
- if (!isDirectoryExist(outDir.data()))
- {
- std::cout << "Output directory doesn't exist. It will be created." << std::endl;
- if (!mkDirRecursively(temp.data()))
- {
- std::cout << "Directory creation failed!" << std::endl;
- return -1;
- }
- }
- }
- else
- {
- auto idx = infile.find_last_of("/\\");
- if (idx == 0 || idx == std::string::npos)
- {
- outDir = ".";
- }
- else
- {
- outDir = infile.substr(0, idx);
- }
- }
-
- bool debug = debugSwitch.getValue();
- int mode = interfaceSearchMode.getValue();
- // do stuff
- if (debug)
- lout().setMinVerbosity(Log::MOST_VERBOSE);
-
- run(infile, outDir, assetName, mode, bOutputLL, bOutputTK, bOutputPX, bOutputObjFile, bOutputFbxFile, bOutputFBXAscii, bFbxCollision, bNonSkinned);
- }
- catch (TCLAP::ArgException &e) // catch any exceptions
- {
- lout() << Log::TYPE_ERROR << "error: " << e.error() << " for arg " << e.argId() << std::endl;
- }
-
- return 0;
-}
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#if NV_VC
+#pragma warning(push)
+#pragma warning(disable: 4996) // 'fopen' unsafe warning, from NxFileBuffer.h
+#endif
+
+#include "PxPhysicsAPI.h"
+#include "NvBlastExtApexImportTool.h"
+#include "Log.h"
+#include <string>
+#include <iostream>
+#include <fstream>
+#include "tclap/CmdLine.h"
+#include "ApexDestructibleObjExporter.h"
+#include "NvBlastTkFramework.h"
+#include "NvBlastGlobals.h"
+#include "NvBlastExtPxAsset.h"
+#include "NvBlastExtPxManager.h"
+#include "BlastDataExporter.h"
+#include "windows.h"
+#include <NvBlastTkAsset.h>
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
+#include "NvBlastExtExporterJsonCollision.h"
+#include <nvparameterized\NvSerializer.h>
+#include <PsFileBuffer.h>
+#define DEFAULT_INPUT_FILE "../../../tools/ApexImporter/resources/assets/table.apb"
+#define DEFAULT_OUTPUT_DIR "C:/TestFracturer/"
+#define DEFAULT_ASSET_NAME "table"
+
+using namespace Nv::Blast;
+using namespace Nv::Blast::ApexImporter;
+
+void loggingCallback(int type, const char* msg, const char* file, int line)
+{
+ if (type == NvBlastMessage::Info)
+ lout() << Log::TYPE_INFO << msg << " FILE:" << file << " Line: " << line << "\n";
+ else
+ lout() << Log::TYPE_ERROR << msg << " FILE:" << file << " Line: " << line << "\n";
+}
+
+bool isDirectoryExist(std::string path)
+{
+ DWORD attributes = GetFileAttributesA(path.c_str());
+ if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool mkDirRecursively(std::string path)
+{
+ if (isDirectoryExist(path))
+ {
+ return true;
+ }
+ auto indx = path.find_first_of("\\/");
+ while (indx != std::string::npos)
+ {
+ std::string subfolder = path.substr(0, indx);
+ CreateDirectory(subfolder.c_str(), NULL);
+ indx = path.find_first_of("\\/", indx + 1);
+ }
+ return isDirectoryExist(path);
+}
+
+// Create an Asset from the APEX destructible asset
+void run(const std::string& inFilepath, const std::string& outDir, const std::string& assetName, uint32_t mode, bool llFlag, bool tkFlag, bool extPxFlag,
+ bool obj, bool fbx, bool fbxascii, bool fbxCollision, bool jsonCollision, bool nonSkinned)
+{
+ std::string inputDir = inFilepath.substr(0, inFilepath.find_last_of("/\\"));
+
+ // load APEX
+ ApexImportTool blast;
+
+ lout() << Log::TYPE_INFO << "ApexImportTool initialization" << std::endl;
+ if (!blast.isValid())
+ {
+ lout() << Log::TYPE_ERROR << "Failed to create BlastSDK" << std::endl;
+ return;
+ }
+
+
+ // load asset
+ lout() << Log::TYPE_INFO << "Loading asset: " << inFilepath << std::endl;
+ physx::PxFileBuf* apexAssetStream = PX_NEW(physx::general_PxIOStream::PsFileBuffer)(inFilepath.c_str(), physx::PxFileBuf::OPEN_READ_ONLY);
+
+ NvParameterized::Serializer::DeserializedData data;
+ blast.loadAssetFromFile(apexAssetStream, data);
+ if (data.size() == 0)
+ {
+ return;
+ }
+ apexAssetStream->release();
+
+ ApexImporterConfig config;
+ config.infSearchMode = static_cast<ApexImporterConfig::InterfaceSearchMode>(mode);
+
+ std::vector<uint32_t> chunkReorderInvMap;
+ TkFramework* framework = NvBlastTkFrameworkCreate();
+ if (framework == nullptr)
+ {
+ lout() << Log::TYPE_ERROR << "Failed to create TkFramework" << std::endl;
+ return;
+ }
+
+ std::vector<NvBlastChunkDesc> chunkDesc;
+ std::vector<NvBlastBondDesc> bondDescs;
+ std::vector<uint32_t> flags;
+
+ std::vector<ExtPxAssetDesc::ChunkDesc> physicsChunks;
+ std::vector<ExtPxAssetDesc::SubchunkDesc> physicsSubchunks;
+
+ bool result = blast.importApexAsset(chunkReorderInvMap, data[0], chunkDesc, bondDescs, flags, config);
+ if (!result)
+ {
+ lout() << Log::TYPE_ERROR << "Failed to build Blast asset data" << std::endl;
+ return;
+ };
+ std::vector<std::vector<CollisionHull*>> hulls;
+ result = blast.getCollisionGeometry(data[0], static_cast<uint32_t>(chunkDesc.size()), chunkReorderInvMap, flags, physicsChunks, physicsSubchunks, hulls);
+ if (!result)
+ {
+ lout() << Log::TYPE_ERROR << "Failed to build physics data" << std::endl;
+ return;
+ };
+
+
+ // save asset
+ lout() << Log::TYPE_INFO << "Saving blast asset: " << outDir << std::endl;
+ BlastDataExporter blExpr(framework, blast.getPxSdk(), blast.getCooking());
+ NvBlastAsset* llAsset = blExpr.createLlBlastAsset(bondDescs, chunkDesc);
+
+ std::cout <<"Chunk count: " << NvBlastAssetGetChunkCount(llAsset, NULL) << std::endl;
+
+ if (llAsset == nullptr && (llFlag || fbx))
+ {
+ lout() << Log::TYPE_ERROR << "Failed to build low-level asset" << std::endl;
+ return;
+ }
+
+ if (llFlag)
+ {
+ blExpr.saveBlastObject(outDir, assetName, llAsset, LlObjectTypeID::Asset);
+ }
+ if (tkFlag)
+ {
+ TkAsset* tkAsset = blExpr.createTkBlastAsset(bondDescs, chunkDesc);
+ blExpr.saveBlastObject(outDir, assetName, tkAsset, TkObjectTypeID::Asset);
+ tkAsset->release();
+ }
+ if (extPxFlag)
+ {
+ ExtPxAsset* pxAsset = blExpr.createExtBlastAsset(bondDescs, chunkDesc, physicsChunks);
+ blExpr.saveBlastObject(outDir, assetName, pxAsset, ExtPxObjectTypeID::Asset);
+ pxAsset->release();
+ }
+
+ lout() << Log::TYPE_INFO << "Saving model file: " << outDir << std::endl;
+ ApexDestructibleGeometryExporter objSaver(inputDir, outDir);
+ if (fbxCollision)
+ {
+ objSaver.exportToFile(llAsset, data[0], blast, assetName, chunkReorderInvMap, fbx, obj, fbxascii, nonSkinned, hulls);
+ }
+ else
+ {
+ objSaver.exportToFile(llAsset, data[0], blast, assetName, chunkReorderInvMap, fbx, obj, fbxascii, nonSkinned);
+ }
+
+ if (jsonCollision)
+ {
+ std::vector<CollisionHull*> flattenedHulls;
+ std::vector<uint32_t> hullOffsets;
+ for (std::vector<CollisionHull*>& chunkHulls : hulls)
+ {
+ hullOffsets.push_back(static_cast<uint32_t>(flattenedHulls.size()));
+ for (CollisionHull* hull : chunkHulls)
+ {
+ flattenedHulls.push_back(hull);
+ }
+ }
+ hullOffsets.push_back(static_cast<uint32_t>(flattenedHulls.size()));
+ const std::string fullJsonFilename = outDir + ((outDir.back() == '/' || outDir.back() == '\\') ? "" : "/") + assetName + ".json";
+ IJsonCollisionExporter* collisionExporter = NvBlastExtExporterCreateJsonCollisionExporter();
+ if (collisionExporter != nullptr)
+ {
+ if (collisionExporter->writeCollision(fullJsonFilename.c_str(), static_cast<uint32_t>(hulls.size()), hullOffsets.data(), flattenedHulls.data()))
+ {
+ std::cout << "Exported collision geometry: " << fullJsonFilename << std::endl;
+ }
+ else
+ {
+ std::cerr << "Can't write collision geometry to json file." << std::endl;
+ }
+ collisionExporter->release();
+ }
+ }
+
+ NVBLAST_FREE(llAsset);
+}
+
+
+int main(int argc, const char* const* argv)
+{
+ try
+ {
+ // setup cmd line
+ TCLAP::CmdLine cmd("Blast SDK: APEX Importer", ' ', "0.1");
+
+ TCLAP::ValueArg<std::string> infileArg("f", "file", "File to load", true, DEFAULT_INPUT_FILE, "infile");
+ cmd.add(infileArg);
+
+ TCLAP::ValueArg<std::string> outDirArg("o", "outputDir", "Output directory", false, DEFAULT_OUTPUT_DIR, "output directory");
+ cmd.add(outDirArg);
+
+ TCLAP::ValueArg<std::string> outAssetName("n", "outAssetName", "Output asset name", true, DEFAULT_ASSET_NAME, "output asset name");
+ cmd.add(outAssetName);
+
+
+ TCLAP::ValueArg<uint32_t> interfaceSearchMode("m", "mode", "Interface search mode", false, 0, "0 - EXACT, 1 - FORCED, for detailed description see docs.");
+ cmd.add(interfaceSearchMode);
+
+ TCLAP::SwitchArg debugSwitch("d", "debug", "Print debug output", cmd, false);
+
+ TCLAP::SwitchArg pxOutputArg("", "px", "Output ExtPxAsset to the output directory", false);
+ cmd.add(pxOutputArg);
+
+ TCLAP::SwitchArg tkOutputArg("", "tk", "Output TkAsset to the output directory", false);
+ cmd.add(tkOutputArg);
+
+ TCLAP::SwitchArg llOutputArg("", "ll", "Output LL Blast asset to the output directory", false);
+ cmd.add(llOutputArg);
+
+ TCLAP::SwitchArg fbxAsciiArg("", "fbxascii", "Output FBX as an ascii file (defaults to binary output)", false);
+ cmd.add(fbxAsciiArg);
+
+ TCLAP::SwitchArg objOutputArg("", "obj", "Output a OBJ mesh to the output directory", false);
+ cmd.add(objOutputArg);
+
+ TCLAP::SwitchArg fbxOutputArg("", "fbx", "Output a FBX mesh to the output directory", false);
+ cmd.add(fbxOutputArg);
+
+ TCLAP::SwitchArg jsonCollision("", "jsoncollision", "Save collision geometry to a json file", false);
+ cmd.add(jsonCollision);
+
+ TCLAP::SwitchArg fbxcollision("", "fbxcollision", "Append collision geometry to FBX file", false);
+ cmd.add(fbxcollision);
+
+ TCLAP::SwitchArg nonSkinnedFBX("", "nonskinned", "Output a non-skinned FBX file", false);
+ cmd.add(nonSkinnedFBX);
+
+ // parse cmd input
+ cmd.parse(argc, argv);
+
+ bool bOutputPX = pxOutputArg.getValue();
+ bool bOutputTK = tkOutputArg.getValue();
+ bool bOutputLL = llOutputArg.getValue();
+
+ bool bOutputFBXAscii = fbxAsciiArg.isSet();
+
+ bool bOutputObjFile = objOutputArg.isSet();
+ bool bOutputFbxFile = fbxOutputArg.isSet();
+
+ bool bFbxCollision = fbxcollision.isSet();
+ bool bJsonCollision = jsonCollision.isSet();
+
+ bool bNonSkinned = nonSkinnedFBX.isSet();
+
+ // Did we specify no output formats?
+ if (!pxOutputArg.isSet() && !tkOutputArg.isSet() && !llOutputArg.isSet())
+ {
+ std::cout << "Didn't specify an output format on the command line, so defaulting to outputting an ExtPxAsset" << std::endl;
+ bOutputPX = true;
+ }
+ // Did we specify no geometry output formats?
+ if (!bOutputObjFile && !bOutputFbxFile)
+ {
+ std::cout << "Didn't specify an output geometry format on the command line, so defaulting to outputting .OBJ" << std::endl;
+ bOutputObjFile = true;
+ }
+
+ // get cmd parse results
+ std::string infile = infileArg.getValue();
+ std::string outDir;
+ std::string assetName = outAssetName.getValue();
+
+ /**
+ Set output dir, make sure that it exist.
+ */
+ if (outDirArg.isSet())
+ {
+ outDir = outDirArg.getValue();
+ std::string temp = outDir + '/';
+ if (!isDirectoryExist(outDir.data()))
+ {
+ std::cout << "Output directory doesn't exist. It will be created." << std::endl;
+ if (!mkDirRecursively(temp.data()))
+ {
+ std::cout << "Directory creation failed!" << std::endl;
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ auto idx = infile.find_last_of("/\\");
+ if (idx == 0 || idx == std::string::npos)
+ {
+ outDir = ".";
+ }
+ else
+ {
+ outDir = infile.substr(0, idx);
+ }
+ }
+
+ bool debug = debugSwitch.getValue();
+ int mode = interfaceSearchMode.getValue();
+ // do stuff
+ if (debug)
+ lout().setMinVerbosity(Log::MOST_VERBOSE);
+
+ run(infile, outDir, assetName, mode, bOutputLL, bOutputTK, bOutputPX, bOutputObjFile, bOutputFbxFile, bOutputFBXAscii, bFbxCollision, bJsonCollision, bNonSkinned);
+ }
+ catch (TCLAP::ArgException &e) // catch any exceptions
+ {
+ lout() << Log::TYPE_ERROR << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ }
+
+ return 0;
+}
diff --git a/tools/AuthoringTool/src/AuthoringTool.cpp b/tools/AuthoringTool/src/AuthoringTool.cpp
index 09e66bb..c7b664f 100644..100755
--- a/tools/AuthoringTool/src/AuthoringTool.cpp
+++ b/tools/AuthoringTool/src/AuthoringTool.cpp
@@ -1,734 +1,755 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "PxPhysicsAPI.h"
-#include "PsFileBuffer.h"
-#include "NvBlast.h"
-#include "NvBlastAssert.h"
-#include "NvBlastGlobals.h"
-#include "NvBlastExtExporter.h"
-#include "NvBlastPxCallbacks.h"
-#include "NvBlastTkAsset.h"
-#include "NvBlastExtLlSerialization.h"
-#include "NvBlastExtTkSerialization.h"
-#include "NvBlastExtPxSerialization.h"
-#include "NvBlastExtAuthoring.h"
-#include "NvBlastExtAuthoringMesh.h"
-#include "NvBlastExtAuthoringBondGenerator.h"
-#include "NvBlastExtAuthoringCollisionBuilder.h"
-#include "NvBlastExtAuthoringCutout.h"
-#include "NvBlastExtAuthoringFractureTool.h"
-#include "BlastDataExporter.h"
-#include "SimpleRandomGenerator.h"
-#include "NvBlastExtAuthoringMeshCleaner.h"
-
-#include <string>
-#include <memory>
-#include <iostream>
-#include <vector>
-#include <cctype>
-#include <fstream>
-#include <iosfwd>
-#include <Windows.h>
-#include "tclap/CmdLine.h"
-
-using physx::PxVec3;
-using physx::PxVec2;
-
-#define DEFAULT_ASSET_NAME "AuthoringTest"
-
-using namespace Nv::Blast;
-
-physx::PxFoundation* gFoundation = nullptr;
-physx::PxPhysics* gPhysics = nullptr;
-physx::PxCooking* gCooking = nullptr;
-
-struct TCLAPint3
-{
- int32_t x, y, z;
- TCLAPint3(int32_t x, int32_t y, int32_t z) :x(x), y(y), z(z){};
- TCLAPint3() :x(0), y(0), z(0){};
- TCLAPint3& operator=(const std::string &inp)
- {
- std::istringstream stream(inp);
- if (!(stream >> x >> y >> z))
- throw TCLAP::ArgParseException(inp + " is not int3");
- return *this;
- }
-};
-
-struct TCLAPfloat3
-{
- float x, y, z;
- TCLAPfloat3(float x, float y, float z) :x(x), y(y), z(z) {};
- TCLAPfloat3() :x(0), y(0), z(0) {};
- TCLAPfloat3& operator=(const std::string &inp)
- {
- std::istringstream stream(inp);
- if (!(stream >> x >> y >> z))
- throw TCLAP::ArgParseException(inp + " is not float3");
- return *this;
- }
-
- operator physx::PxVec3()
- {
- return physx::PxVec3(x, y, z);
- }
-};
-
-namespace TCLAP {
- template<>
- struct ArgTraits<TCLAPint3> {
- typedef StringLike ValueCategory;
- };
-
- template<>
- struct ArgTraits<TCLAPfloat3> {
- typedef StringLike ValueCategory;
- };
-}
-
-bool isDirectoryExist(const std::string& path)
-{
- DWORD attributes = GetFileAttributesA(path.c_str());
- if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- return true;
- }
- return false;
-}
-
-bool isFileExist(const std::string& path)
-{
- DWORD attributes = GetFileAttributesA(path.c_str());
- if ((attributes != INVALID_FILE_ATTRIBUTES) && !(attributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- return true;
- }
- return false;
-}
-
-bool mkDirRecursively(const std::string& path)
-{
- if (isDirectoryExist(path))
- {
- return true;
- }
- auto indx = path.find_first_of("\\/");
- while (indx != std::string::npos)
- {
- std::string subfolder = path.substr(0, indx);
- CreateDirectory(subfolder.c_str(), NULL);
- indx = path.find_first_of("\\/", indx + 1);
- }
- return isDirectoryExist(path);
-}
-
-unsigned char *LoadBitmapFile(const char *filename, BITMAPINFOHEADER *bitmapInfoHeader)
-{
- FILE *filePtr; //our file pointer
- BITMAPFILEHEADER bitmapFileHeader; //our bitmap file header
- unsigned char *bitmapImage; //store image data
- //int imageIdx = 0; //image index counter
- unsigned char tempRGB; //our swap variable
-
- //open filename in read binary mode
- filePtr = fopen(filename, "rb");
- if (filePtr == NULL)
- return NULL;
-
- //read the bitmap file header
- fread(&bitmapFileHeader, sizeof(BITMAPFILEHEADER), 1, filePtr);
-
- //verify that this is a bmp file by check bitmap id
- if (bitmapFileHeader.bfType != 0x4D42)
- {
- fclose(filePtr);
- return NULL;
- }
-
- //read the bitmap info header
- fread(bitmapInfoHeader, sizeof(BITMAPINFOHEADER), 1, filePtr); // small edit. forgot to add the closing bracket at sizeof
-
- //move file point to the begging of bitmap data
- fseek(filePtr, bitmapFileHeader.bfOffBits, SEEK_SET);
-
- //Only incompressed 24 byte RGB is supported
- if (bitmapInfoHeader->biCompression != BI_RGB || bitmapInfoHeader->biBitCount != 24)
- {
- return nullptr;
- }
- else
- {
- bitmapInfoHeader->biSizeImage = 3 * bitmapInfoHeader->biHeight * bitmapInfoHeader->biHeight;
- }
-
- //allocate enough memory for the bitmap image data
- bitmapImage = (unsigned char*)malloc(bitmapInfoHeader->biSizeImage);
-
- //verify memory allocation
- if (!bitmapImage)
- {
- free(bitmapImage);
- fclose(filePtr);
- return NULL;
- }
-
- //read in the bitmap image data
- fread(bitmapImage, sizeof(uint8_t), bitmapInfoHeader->biSizeImage, filePtr);
-
- //make sure bitmap image data was read
- if (bitmapImage == NULL)
- {
- fclose(filePtr);
- return NULL;
- }
-
- //swap the r and b values to get RGB (bitmap is BGR)
- if (bitmapInfoHeader->biBitCount > 1)
- {
- for (uint32_t imageIdx = 0; imageIdx < bitmapInfoHeader->biSizeImage; imageIdx += 3) // fixed semicolon
- {
- tempRGB = bitmapImage[imageIdx];
- bitmapImage[imageIdx] = bitmapImage[imageIdx + 2];
- bitmapImage[imageIdx + 2] = tempRGB;
- }
- }
-
- //close file and return bitmap iamge data
- fclose(filePtr);
- return bitmapImage;
-}
-
-bool initPhysX()
-{
- gFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
- if (!gFoundation)
- {
- std::cerr << "Can't init PhysX foundation" << std::endl;
- return false;
- }
- physx::PxTolerancesScale scale;
- gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true);
- if (!gPhysics)
- {
- std::cerr << "Can't create Physics" << std::endl;
- return false;
- }
- physx::PxCookingParams cookingParams(scale);
- cookingParams.buildGPUData = true;
- gCooking = PxCreateCooking(PX_PHYSICS_VERSION, gPhysics->getFoundation(), cookingParams);
- if (!gCooking)
- {
- std::cerr << "Can't create Cooking" << std::endl;
- return false;
- }
- return true;
-}
-
-int main(int argc, const char* const* argv)
-{
- // set blast global error callback
- // overriding default one in order to exit tool in profile/release configuration too (and write to stderr)
- class CustomErrorCallback : public ErrorCallback
- {
- virtual void reportError(ErrorCode::Enum code, const char* msg, const char* file, int line) override
- {
- std::stringstream str;
- bool critical = false;
- switch (code)
- {
- case ErrorCode::eNO_ERROR: str << "[Info]"; critical = false; break;
- case ErrorCode::eDEBUG_INFO: str << "[Debug Info]"; critical = false; break;
- case ErrorCode::eDEBUG_WARNING: str << "[Debug Warning]"; critical = false; break;
- case ErrorCode::eINVALID_PARAMETER: str << "[Invalid Parameter]"; critical = true; break;
- case ErrorCode::eINVALID_OPERATION: str << "[Invalid Operation]"; critical = true; break;
- case ErrorCode::eOUT_OF_MEMORY: str << "[Out of] Memory"; critical = true; break;
- case ErrorCode::eINTERNAL_ERROR: str << "[Internal Error]"; critical = true; break;
- case ErrorCode::eABORT: str << "[Abort]"; critical = true; break;
- case ErrorCode::ePERF_WARNING: str << "[Perf Warning]"; critical = false; break;
- default: NVBLAST_ASSERT(false);
- }
-#if NV_DEBUG || NV_CHECKED
- str << file << "(" << line << "): ";
-#else
- NV_UNUSED(file);
- NV_UNUSED(line);
-#endif
- str << " " << msg << "\n";
- std::cerr << str.str();
-
- if (critical)
- {
- std::cerr << "Authoring failed. Exiting.\n";
- exit(-1);
- }
- }
- };
- CustomErrorCallback errorCallback;
- NvBlastGlobalSetErrorCallback(&errorCallback);
-
- // setup cmd line
- TCLAP::CmdLine cmd("Blast SDK: Authoring Tool", ' ', "1.1");
-
- TCLAP::UnlabeledValueArg<std::string> infileArg("file", "File to load", true, "", "infile");
- cmd.add(infileArg);
-
- TCLAP::UnlabeledValueArg<std::string> outAssetName("outAssetName", "Output asset name", true, DEFAULT_ASSET_NAME, "output asset name");
- cmd.add(outAssetName);
-
- TCLAP::ValueArg<std::string> outDirArg("", "outputDir", "Output directory", false, ".", "by default directory of the input file");
- cmd.add(outDirArg);
-
- TCLAP::SwitchArg cleanArg("", "clean", "Try cleaning mesh before fracturing", false);
- cmd.add(cleanArg);
-
- // The output modes
- //NOTE: Fun TCLAP quirk here - if you set the default to true and specify this switch on the command line, the value will be false!
- TCLAP::SwitchArg pxOutputArg("", "px", "Output ExtPxAsset to the .blast file in the output directory.", false);
- cmd.add(pxOutputArg);
-
- TCLAP::SwitchArg tkOutputArg("", "tk", "Output TkAsset to the .blast file in the output directory.", false);
- cmd.add(tkOutputArg);
-
- TCLAP::SwitchArg llOutputArg("", "ll", "Output LL Blast (NvBlastAsset) to the .blast file in the output directory.", false);
- cmd.add(llOutputArg);
-
- TCLAP::SwitchArg fbxAsciiArg("", "fbxascii", "Output FBX as an ascii file (defaults to binary output)", false);
- cmd.add(fbxAsciiArg);
-
- TCLAP::SwitchArg objOutputArg("", "obj", "Output a OBJ mesh to the output directory", false);
- cmd.add(objOutputArg);
-
- TCLAP::SwitchArg fbxOutputArg("", "fbx", "Output a FBX mesh to the output directory", false);
- cmd.add(fbxOutputArg);
-
- TCLAP::SwitchArg fbxCollision("", "fbxcollision", "Add collision geometry to FBX file", false);
- cmd.add(fbxCollision);
-
- TCLAP::SwitchArg nonSkinnedFBX("", "nonskinned", "Output a non-skinned FBX file", false);
- cmd.add(nonSkinnedFBX);
-
- TCLAP::ValueArg<int32_t> interiorMatId("", "interiorMat", "Use to setup interior material id, by default new material for internal surface will be created.", false, -1, "by default -1");
- cmd.add(interiorMatId);
-
- TCLAP::ValueArg<unsigned char> fracturingMode("", "mode", "Fracturing mode", false, 'v',
- "v - voronoi, c - clustered voronoi, s - slicing, p - plane cut, u - cutout.");
- cmd.add(fracturingMode);
- TCLAP::ValueArg<uint32_t> cellsCount("", "cells", "Voronoi cells count", false, 5, "by default 5");
- cmd.add(cellsCount);
- TCLAP::ValueArg<uint32_t> clusterCount("", "clusters", "Uniform Voronoi cluster count", false, 5, "by default 5");
- cmd.add(clusterCount);
- TCLAP::ValueArg<float> clusterRad("", "radius", "Clustered Voronoi cluster radius", false, 1.0f, "by default 1.0");
- cmd.add(clusterRad);
-
- TCLAP::ValueArg<TCLAPint3> slicingNumber("", "slices", "Number of slices per direction", false, TCLAPint3(1, 1, 1), "by default 1 1 1");
- cmd.add(slicingNumber);
-
- TCLAP::ValueArg<float> angleVariation("", "avar", "Slicing angle variation", false, 0.0, "by default 0.0");
- cmd.add(angleVariation);
-
- TCLAP::ValueArg<float> offsetVariation("", "ovar", "Slicing offset variation", false, 0.0, "by default 0.0");
- cmd.add(offsetVariation);
-
- TCLAP::ValueArg<TCLAPfloat3> point("", "point", "Plane surface point", false, TCLAPfloat3(0, 0, 0), "by default 0 0 0");
- cmd.add(point);
-
- TCLAP::ValueArg<TCLAPfloat3> normal("", "normal", "Plane surface normal", false, TCLAPfloat3(1, 0, 0), "by default 1 0 0");
- cmd.add(normal);
-
- TCLAP::ValueArg<std::string> cutoutBitmapPath("", "cutoutBitmap", "Path to *.bmp file with cutout bitmap", false, ".", "by defualt empty");
- cmd.add(cutoutBitmapPath);
-
- try
- {
- // parse cmd input
- cmd.parse(argc, argv);
- }
- catch (TCLAP::ArgException &e) // catch any exceptions
- {
- std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
- return -1;
- }
-
- // get cmd parse results
- std::string infile = infileArg.getValue();
- if (!isFileExist(infile))
- {
- std::cerr << "[Error] Can't find input file: " << infile << std::endl;
- return -1;
- }
-
- std::string outDir;
-
- std::cout << "Input file: " << infile << std::endl;
-
- if (outDirArg.isSet())
- {
- outDir = outDirArg.getValue();
- std::string temp = outDir + '/';
- if (!isDirectoryExist(outDir.data()))
- {
- std::cout << "Output directory doesn't exist. It will be created." << std::endl;
- if (!mkDirRecursively(temp.data()))
- {
- std::cerr << "Directory creation failed!" << std::endl;
- return -1;
- }
- }
- }
- else
- {
- auto idx = infile.find_last_of("/\\");
- if (idx == 0 || idx == std::string::npos)
- {
- outDir = ".";
- }
- else
- {
- outDir = infile.substr(0, idx);
- }
- }
- std::cout << "Output directory: " << outDir << std::endl;
- std::string assetName = outAssetName.getValue();
-
- // Determine whether to use the obj or fbx loader
-
- auto idx = infile.rfind('.');
- std::string extension;
-
-
- if (idx != std::string::npos)
- {
- extension = infile.substr(idx + 1);
- std::transform(extension.begin(), extension.end(), extension.begin(), std::toupper);
- }
- else
- {
- std::cerr << "Can't determine extension (and thus, loader) of input file. " << infile << std::endl;
- return -1;
- }
-
- bool bOutputPX = pxOutputArg.getValue();
- bool bOutputTK = tkOutputArg.getValue();
- bool bOutputLL = llOutputArg.getValue();
-
- bool bOutputFBXAscii = fbxAsciiArg.getValue();
-
- bool bOutputObjFile = objOutputArg.isSet();
- bool bOutputFbxFile = fbxOutputArg.isSet();
-
- // Did we specify no output formats?
- if (!bOutputPX && !bOutputTK && !bOutputLL)
- {
- std::cout << "Didn't specify an output format on the command line. Use default: LL Blast asset (NvBlastAsset)." << std::endl;
- bOutputLL = true;
- }
- else if ((int)bOutputPX + (int)bOutputTK + (int)bOutputLL > 1)
- {
- std::cerr << "More than one of the --ll, --tk, and --px options are set. Choose one. " << std::endl;
- return -1;
- }
-
- // Did we specify no geometry output formats?
- if (!bOutputObjFile && !bOutputFbxFile)
- {
- std::cout << "Didn't specify an output geometry format on the command line. Use default: .FBX" << std::endl;
- bOutputFbxFile = true;
- }
-
- std::shared_ptr<IMeshFileReader> fileReader;
-
- if (extension.compare("FBX")==0)
- {
- fileReader = std::shared_ptr<IMeshFileReader>(NvBlastExtExporterCreateFbxFileReader(), [](IMeshFileReader* p) {p->release(); });
- }
- else if (extension.compare("OBJ")==0)
- {
- fileReader = std::shared_ptr<IMeshFileReader>(NvBlastExtExporterCreateObjFileReader(), [](IMeshFileReader* p) {p->release(); });
- }
- else
- {
- std::cout << "Unsupported file extension " << extension << std::endl;
- return -1;
- }
-
- // Load the asset
- fileReader->loadFromFile(infile.c_str());
-
- uint32_t vcount = fileReader->getVerticesCount();
-
- if (!initPhysX())
- {
- std::cerr << "Failed to initialize PhysX" << std::endl;
- return -1;
- }
- Nv::Blast::FractureTool* fTool = NvBlastExtAuthoringCreateFractureTool();
-
- PxVec3* pos = fileReader->getPositionArray();
- PxVec3* norm = fileReader->getNormalsArray();
- PxVec2* uv = fileReader->getUvArray();
-
- Nv::Blast::Mesh* mesh = NvBlastExtAuthoringCreateMesh(pos, norm, uv, vcount, fileReader->getIndexArray(), fileReader->getIndicesCount());
-
- if (cleanArg.isSet())
- {
- MeshCleaner* clr = NvBlastExtAuthoringCreateMeshCleaner();
- Nv::Blast::Mesh* nmesh;
- nmesh = clr->cleanMesh(mesh);
- clr->release();
- mesh->release();
- mesh = nmesh;
- }
- mesh->setMaterialId(fileReader->getMaterialIds());
- mesh->setSmoothingGroup(fileReader->getSmoothingGroups());
-
- fTool->setSourceMesh(mesh);
-
-
- SimpleRandomGenerator rng;
- Nv::Blast::VoronoiSitesGenerator* voronoiSitesGenerator = NvBlastExtAuthoringCreateVoronoiSitesGenerator(mesh, &rng);
- if (voronoiSitesGenerator == nullptr)
- {
- std::cerr << "Failed to create Voronoi sites generator" << std::endl;
- return -1;
- }
-
- // Send it to the fracture processor
-
- switch (fracturingMode.getValue())
- {
- case 'v':
- {
- std::cout << "Fracturing with Voronoi..." << std::endl;
- voronoiSitesGenerator->uniformlyGenerateSitesInMesh(cellsCount.getValue());
- const physx::PxVec3* sites = nullptr;
- uint32_t sitesCount = voronoiSitesGenerator->getVoronoiSites(sites);
- if (fTool->voronoiFracturing(0, sitesCount, sites, false) != 0)
- {
- std::cerr << "Failed to fracture with Voronoi" << std::endl;
- return -1;
- }
- break;
- }
- case 'c':
- {
- std::cout << "Fracturing with Clustered Voronoi..." << std::endl;
- voronoiSitesGenerator->clusteredSitesGeneration(cellsCount.getValue(), clusterCount.getValue(), clusterRad.getValue());
- const physx::PxVec3* sites = nullptr;
- uint32_t sitesCount = voronoiSitesGenerator->getVoronoiSites(sites);
- if (fTool->voronoiFracturing(0, sitesCount, sites, false) != 0)
- {
- std::cerr << "Failed to fracture with Clustered Voronoi" << std::endl;
- return -1;
- }
- break;
- }
- case 's':
- {
- std::cout << "Fracturing with Slicing..." << std::endl;
- SlicingConfiguration slConfig;
- slConfig.x_slices = slicingNumber.getValue().x;
- slConfig.y_slices = slicingNumber.getValue().y;
- slConfig.z_slices = slicingNumber.getValue().z;
- slConfig.angle_variations = angleVariation.getValue();
- slConfig.offset_variations = offsetVariation.getValue();
- if (fTool->slicing(0, slConfig, false, &rng) != 0)
- {
- std::cerr << "Failed to fracture with Slicing" << std::endl;
- return -1;
- }
- break;
- }
- case 'p':
- {
- std::cout << "Plane cut fracturing..." << std::endl;
- NoiseConfiguration noise;
- if (fTool->cut(0, normal.getValue(), point.getValue(), noise, false, &rng) != 0)
- {
- std::cerr << "Failed to fracture with Cutout (in half-space, plane cut)" << std::endl;
- return -1;
- }
- break;
- }
- case 'u':
- {
- std::cout << "Cutout fracturing..." << std::endl;
- CutoutConfiguration cutoutConfig;
- physx::PxVec3 axis = normal.getValue();
- if (axis.isZero())
- {
- axis = PxVec3(0.f, 0.f, 1.f);
- }
- axis.normalize();
- float d = axis.dot(physx::PxVec3(0.f, 0.f, 1.f));
- if (d < (1e-6f - 1.0f))
- {
- cutoutConfig.transform.q = physx::PxQuat(physx::PxPi, PxVec3(1.f, 0.f, 0.f));
- }
- else if (d < 1.f)
- {
- float s = physx::PxSqrt((1 + d) * 2);
- float invs = 1 / s;
- auto c = axis.cross(PxVec3(0.f, 0.f, 1.f));
- cutoutConfig.transform.q = physx::PxQuat(c.x * invs, c.y * invs, c.z * invs, s * 0.5f);
- cutoutConfig.transform.q.normalize();
- }
- cutoutConfig.transform.p = point.getValue();
- if (cutoutBitmapPath.isSet())
- {
- BITMAPINFOHEADER header;
- uint8_t* bitmap = LoadBitmapFile(cutoutBitmapPath.getValue().c_str(), &header);
- if (bitmap != nullptr)
- {
- cutoutConfig.cutoutSet = NvBlastExtAuthoringCreateCutoutSet();
- NvBlastExtAuthoringBuildCutoutSet(*cutoutConfig.cutoutSet, bitmap, header.biWidth, header.biHeight, 0.001f, 1.f, false, true);
- }
- }
- if (fTool->cutout(0, cutoutConfig, false, &rng) != 0)
- {
- std::cerr << "Failed to fracture with Cutout" << std::endl;
- return -1;
- }
- break;
- }
- default:
- std::cerr << "Unknown mode" << std::endl;
- return -1;
- }
- voronoiSitesGenerator->release();
- mesh->release();
-
- Nv::Blast::BlastBondGenerator* bondGenerator = NvBlastExtAuthoringCreateBondGenerator(gCooking, &gPhysics->getPhysicsInsertionCallback());
- Nv::Blast::ConvexMeshBuilder* collisionBuilder = NvBlastExtAuthoringCreateConvexMeshBuilder(gCooking, &gPhysics->getPhysicsInsertionCallback());
- Nv::Blast::CollisionParams collisionParameter;
- collisionParameter.maximumNumberOfHulls = 1;
- collisionParameter.voxelGridResolution = 0;
- Nv::Blast::AuthoringResult* result = NvBlastExtAuthoringProcessFracture(*fTool, *bondGenerator, *collisionBuilder, collisionParameter);
- NvBlastTkFrameworkCreate();
-
- collisionBuilder->release();
- bondGenerator->release();
- fTool->release();
-
- // Output the results
- // NOTE: Writing to FBX by default.
-
- std::vector<const char*> matNames;
- for (int32_t i = 0; i < fileReader->getMaterialCount(); ++i)
- {
- matNames.push_back(fileReader->getMaterialName(i));
- }
- result->materialNames = matNames.data();
- result->materialCount = static_cast<uint32_t>(matNames.size());
-
-
- if (!fbxCollision.isSet())
- {
- result->releaseCollisionHulls();
- }
-
- const std::string assetNameFull = outDir + "\\" + assetName;
-
- if (bOutputObjFile)
- {
- std::shared_ptr<IMeshFileWriter> fileWriter(NvBlastExtExporterCreateObjFileWriter(), [](IMeshFileWriter* p) {p->release(); });
- if (interiorMatId.isSet() && interiorMatId.getValue() >= 0)
- {
- fileWriter->setInteriorIndex(interiorMatId.getValue());
- }
- fileWriter->appendMesh(*result, assetName.c_str());
- if (!fileWriter->saveToFile(assetName.c_str(), outDir.c_str()))
- {
- std::cerr << "Can't write geometry to OBJ file." << std::endl;
- return -1;
- }
- std::cout << "Exported render mesh geometry: " << assetNameFull << ".obj" << std::endl;
- }
- if (bOutputFbxFile)
- {
- std::shared_ptr<IMeshFileWriter> fileWriter(NvBlastExtExporterCreateFbxFileWriter(bOutputFBXAscii), [](IMeshFileWriter* p) {p->release(); });
- if (interiorMatId.isSet() && interiorMatId.getValue() >= 0)
- {
- fileWriter->setInteriorIndex(interiorMatId.getValue());
- }
- fileWriter->appendMesh(*result, assetName.c_str(), nonSkinnedFBX.isSet());
- if (!fileWriter->saveToFile(assetName.c_str(), outDir.c_str()))
- {
- std::cerr << "Can't write geometry to FBX file." << std::endl;
- return -1;
- }
- if (fbxCollision.isSet())
- {
- std::cout << "Exported render mesh and collision geometry: " << assetNameFull << ".fbx" << std::endl;
- }
- else
- {
- std::cout << "Exported render mesh geometry: " << assetNameFull << ".fbx" << std::endl;
- }
- }
-
- auto saveBlastData = [&](BlastDataExporter& blExpr)
- {
- if (bOutputLL)
- {
- blExpr.saveBlastObject(outDir, assetName, result->asset, LlObjectTypeID::Asset);
- std::cout << "Exported NvBlastAsset: " << assetNameFull << ".blast" << std::endl;
- }
- else
- {
- Nv::Blast::TkAssetDesc descriptor;
- descriptor.bondCount = result->bondCount;
- descriptor.bondDescs = result->bondDescs;
- descriptor.bondFlags = nullptr;
- descriptor.chunkCount = result->chunkCount;
- descriptor.chunkDescs = result->chunkDescs;
- Nv::Blast::ExtPxAsset* physicsAsset = Nv::Blast::ExtPxAsset::create(descriptor, result->physicsChunks, result->physicsSubchunks, *NvBlastTkFrameworkGet());
- if (bOutputTK)
- {
- blExpr.saveBlastObject(outDir, assetName, &physicsAsset->getTkAsset(), TkObjectTypeID::Asset);
- std::cout << "Exported TkAsset: " << assetNameFull << ".blast" << std::endl;
- }
- else if (bOutputPX)
- {
- blExpr.saveBlastObject(outDir, assetName, physicsAsset, ExtPxObjectTypeID::Asset);
- std::cout << "Exported ExtPxAsset: " << assetNameFull << ".blast" << std::endl;
- }
- physicsAsset->release();
- }
- };
-
- BlastDataExporter blExpr(NvBlastTkFrameworkGet(), gPhysics, gCooking);
- saveBlastData(blExpr);
-
- result->release();
-
- std::cout << "Success!" << std::endl;
-
- return 0;
-}
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "PxPhysicsAPI.h"
+#include "PsFileBuffer.h"
+#include "NvBlast.h"
+#include "NvBlastAssert.h"
+#include "NvBlastGlobals.h"
+#include "NvBlastExtExporter.h"
+#include "NvBlastPxCallbacks.h"
+#include "NvBlastTkAsset.h"
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
+#include "NvBlastExtAuthoring.h"
+#include "NvBlastExtAuthoringMesh.h"
+#include "NvBlastExtAuthoringBondGenerator.h"
+#include "NvBlastExtAuthoringCollisionBuilder.h"
+#include "NvBlastExtAuthoringCutout.h"
+#include "NvBlastExtAuthoringFractureTool.h"
+#include "BlastDataExporter.h"
+#include "SimpleRandomGenerator.h"
+#include "NvBlastExtAuthoringMeshCleaner.h"
+#include "NvBlastExtExporterJsonCollision.h"
+
+#include <string>
+#include <memory>
+#include <iostream>
+#include <vector>
+#include <cctype>
+#include <fstream>
+#include <iosfwd>
+#include <Windows.h>
+#include "tclap/CmdLine.h"
+
+using physx::PxVec3;
+using physx::PxVec2;
+
+#define DEFAULT_ASSET_NAME "AuthoringTest"
+
+using namespace Nv::Blast;
+
+physx::PxFoundation* gFoundation = nullptr;
+physx::PxPhysics* gPhysics = nullptr;
+physx::PxCooking* gCooking = nullptr;
+
+struct TCLAPint3
+{
+ int32_t x, y, z;
+ TCLAPint3(int32_t x, int32_t y, int32_t z) :x(x), y(y), z(z){};
+ TCLAPint3() :x(0), y(0), z(0){};
+ TCLAPint3& operator=(const std::string &inp)
+ {
+ std::istringstream stream(inp);
+ if (!(stream >> x >> y >> z))
+ throw TCLAP::ArgParseException(inp + " is not int3");
+ return *this;
+ }
+};
+
+struct TCLAPfloat3
+{
+ float x, y, z;
+ TCLAPfloat3(float x, float y, float z) :x(x), y(y), z(z) {};
+ TCLAPfloat3() :x(0), y(0), z(0) {};
+ TCLAPfloat3& operator=(const std::string &inp)
+ {
+ std::istringstream stream(inp);
+ if (!(stream >> x >> y >> z))
+ throw TCLAP::ArgParseException(inp + " is not float3");
+ return *this;
+ }
+
+ operator physx::PxVec3()
+ {
+ return physx::PxVec3(x, y, z);
+ }
+};
+
+namespace TCLAP {
+ template<>
+ struct ArgTraits<TCLAPint3> {
+ typedef StringLike ValueCategory;
+ };
+
+ template<>
+ struct ArgTraits<TCLAPfloat3> {
+ typedef StringLike ValueCategory;
+ };
+}
+
+bool isDirectoryExist(const std::string& path)
+{
+ DWORD attributes = GetFileAttributesA(path.c_str());
+ if ((attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool isFileExist(const std::string& path)
+{
+ DWORD attributes = GetFileAttributesA(path.c_str());
+ if ((attributes != INVALID_FILE_ATTRIBUTES) && !(attributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool mkDirRecursively(const std::string& path)
+{
+ if (isDirectoryExist(path))
+ {
+ return true;
+ }
+ auto indx = path.find_first_of("\\/");
+ while (indx != std::string::npos)
+ {
+ std::string subfolder = path.substr(0, indx);
+ CreateDirectory(subfolder.c_str(), NULL);
+ indx = path.find_first_of("\\/", indx + 1);
+ }
+ return isDirectoryExist(path);
+}
+
+unsigned char *LoadBitmapFile(const char *filename, BITMAPINFOHEADER *bitmapInfoHeader)
+{
+ FILE *filePtr; //our file pointer
+ BITMAPFILEHEADER bitmapFileHeader; //our bitmap file header
+ unsigned char *bitmapImage; //store image data
+ //int imageIdx = 0; //image index counter
+ unsigned char tempRGB; //our swap variable
+
+ //open filename in read binary mode
+ filePtr = fopen(filename, "rb");
+ if (filePtr == NULL)
+ return NULL;
+
+ //read the bitmap file header
+ fread(&bitmapFileHeader, sizeof(BITMAPFILEHEADER), 1, filePtr);
+
+ //verify that this is a bmp file by check bitmap id
+ if (bitmapFileHeader.bfType != 0x4D42)
+ {
+ fclose(filePtr);
+ return NULL;
+ }
+
+ //read the bitmap info header
+ fread(bitmapInfoHeader, sizeof(BITMAPINFOHEADER), 1, filePtr); // small edit. forgot to add the closing bracket at sizeof
+
+ //move file point to the begging of bitmap data
+ fseek(filePtr, bitmapFileHeader.bfOffBits, SEEK_SET);
+
+ //Only incompressed 24 byte RGB is supported
+ if (bitmapInfoHeader->biCompression != BI_RGB || bitmapInfoHeader->biBitCount != 24)
+ {
+ return nullptr;
+ }
+ else
+ {
+ bitmapInfoHeader->biSizeImage = 3 * bitmapInfoHeader->biHeight * bitmapInfoHeader->biHeight;
+ }
+
+ //allocate enough memory for the bitmap image data
+ bitmapImage = (unsigned char*)malloc(bitmapInfoHeader->biSizeImage);
+
+ //verify memory allocation
+ if (!bitmapImage)
+ {
+ free(bitmapImage);
+ fclose(filePtr);
+ return NULL;
+ }
+
+ //read in the bitmap image data
+ fread(bitmapImage, sizeof(uint8_t), bitmapInfoHeader->biSizeImage, filePtr);
+
+ //make sure bitmap image data was read
+ if (bitmapImage == NULL)
+ {
+ fclose(filePtr);
+ return NULL;
+ }
+
+ //swap the r and b values to get RGB (bitmap is BGR)
+ if (bitmapInfoHeader->biBitCount > 1)
+ {
+ for (uint32_t imageIdx = 0; imageIdx < bitmapInfoHeader->biSizeImage; imageIdx += 3) // fixed semicolon
+ {
+ tempRGB = bitmapImage[imageIdx];
+ bitmapImage[imageIdx] = bitmapImage[imageIdx + 2];
+ bitmapImage[imageIdx + 2] = tempRGB;
+ }
+ }
+
+ //close file and return bitmap iamge data
+ fclose(filePtr);
+ return bitmapImage;
+}
+
+bool initPhysX()
+{
+ gFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
+ if (!gFoundation)
+ {
+ std::cerr << "Can't init PhysX foundation" << std::endl;
+ return false;
+ }
+ physx::PxTolerancesScale scale;
+ gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, scale, true);
+ if (!gPhysics)
+ {
+ std::cerr << "Can't create Physics" << std::endl;
+ return false;
+ }
+ physx::PxCookingParams cookingParams(scale);
+ cookingParams.buildGPUData = true;
+ gCooking = PxCreateCooking(PX_PHYSICS_VERSION, gPhysics->getFoundation(), cookingParams);
+ if (!gCooking)
+ {
+ std::cerr << "Can't create Cooking" << std::endl;
+ return false;
+ }
+ return true;
+}
+
+int main(int argc, const char* const* argv)
+{
+ // set blast global error callback
+ // overriding default one in order to exit tool in profile/release configuration too (and write to stderr)
+ class CustomErrorCallback : public ErrorCallback
+ {
+ virtual void reportError(ErrorCode::Enum code, const char* msg, const char* file, int line) override
+ {
+ std::stringstream str;
+ bool critical = false;
+ switch (code)
+ {
+ case ErrorCode::eNO_ERROR: str << "[Info]"; critical = false; break;
+ case ErrorCode::eDEBUG_INFO: str << "[Debug Info]"; critical = false; break;
+ case ErrorCode::eDEBUG_WARNING: str << "[Debug Warning]"; critical = false; break;
+ case ErrorCode::eINVALID_PARAMETER: str << "[Invalid Parameter]"; critical = true; break;
+ case ErrorCode::eINVALID_OPERATION: str << "[Invalid Operation]"; critical = true; break;
+ case ErrorCode::eOUT_OF_MEMORY: str << "[Out of] Memory"; critical = true; break;
+ case ErrorCode::eINTERNAL_ERROR: str << "[Internal Error]"; critical = true; break;
+ case ErrorCode::eABORT: str << "[Abort]"; critical = true; break;
+ case ErrorCode::ePERF_WARNING: str << "[Perf Warning]"; critical = false; break;
+ default: NVBLAST_ASSERT(false);
+ }
+#if NV_DEBUG || NV_CHECKED
+ str << file << "(" << line << "): ";
+#else
+ NV_UNUSED(file);
+ NV_UNUSED(line);
+#endif
+ str << " " << msg << "\n";
+ std::cerr << str.str();
+
+ if (critical)
+ {
+ std::cerr << "Authoring failed. Exiting.\n";
+ exit(-1);
+ }
+ }
+ };
+ CustomErrorCallback errorCallback;
+ NvBlastGlobalSetErrorCallback(&errorCallback);
+
+ // setup cmd line
+ TCLAP::CmdLine cmd("Blast SDK: Authoring Tool", ' ', "1.1");
+
+ TCLAP::UnlabeledValueArg<std::string> infileArg("file", "File to load", true, "", "infile");
+ cmd.add(infileArg);
+
+ TCLAP::UnlabeledValueArg<std::string> outAssetName("outAssetName", "Output asset name", true, DEFAULT_ASSET_NAME, "output asset name");
+ cmd.add(outAssetName);
+
+ TCLAP::ValueArg<std::string> outDirArg("", "outputDir", "Output directory", false, ".", "by default directory of the input file");
+ cmd.add(outDirArg);
+
+ TCLAP::SwitchArg cleanArg("", "clean", "Try cleaning mesh before fracturing", false);
+ cmd.add(cleanArg);
+
+ // The output modes
+ //NOTE: Fun TCLAP quirk here - if you set the default to true and specify this switch on the command line, the value will be false!
+ TCLAP::SwitchArg pxOutputArg("", "px", "Output ExtPxAsset to the .blast file in the output directory.", false);
+ cmd.add(pxOutputArg);
+
+ TCLAP::SwitchArg tkOutputArg("", "tk", "Output TkAsset to the .blast file in the output directory.", false);
+ cmd.add(tkOutputArg);
+
+ TCLAP::SwitchArg llOutputArg("", "ll", "Output LL Blast (NvBlastAsset) to the .blast file in the output directory.", false);
+ cmd.add(llOutputArg);
+
+ TCLAP::SwitchArg fbxAsciiArg("", "fbxascii", "Output FBX as an ascii file (defaults to binary output)", false);
+ cmd.add(fbxAsciiArg);
+
+ TCLAP::SwitchArg objOutputArg("", "obj", "Output a OBJ mesh to the output directory", false);
+ cmd.add(objOutputArg);
+
+ TCLAP::SwitchArg fbxOutputArg("", "fbx", "Output a FBX mesh to the output directory", false);
+ cmd.add(fbxOutputArg);
+
+ TCLAP::SwitchArg fbxCollision("", "fbxcollision", "Add collision geometry to FBX file", false);
+ cmd.add(fbxCollision);
+
+ TCLAP::SwitchArg jsonCollision("", "jsoncollision", "Save collision geometry to a json file", false);
+ cmd.add(jsonCollision);
+
+ TCLAP::SwitchArg nonSkinnedFBX("", "nonskinned", "Output a non-skinned FBX file", false);
+ cmd.add(nonSkinnedFBX);
+
+ TCLAP::ValueArg<int32_t> interiorMatId("", "interiorMat", "Use to setup interior material id, by default new material for internal surface will be created.", false, -1, "by default -1");
+ cmd.add(interiorMatId);
+
+ TCLAP::ValueArg<unsigned char> fracturingMode("", "mode", "Fracturing mode", false, 'v',
+ "v - voronoi, c - clustered voronoi, s - slicing, p - plane cut, u - cutout.");
+ cmd.add(fracturingMode);
+ TCLAP::ValueArg<uint32_t> cellsCount("", "cells", "Voronoi cells count", false, 5, "by default 5");
+ cmd.add(cellsCount);
+ TCLAP::ValueArg<uint32_t> clusterCount("", "clusters", "Uniform Voronoi cluster count", false, 5, "by default 5");
+ cmd.add(clusterCount);
+ TCLAP::ValueArg<float> clusterRad("", "radius", "Clustered Voronoi cluster radius", false, 1.0f, "by default 1.0");
+ cmd.add(clusterRad);
+
+ TCLAP::ValueArg<TCLAPint3> slicingNumber("", "slices", "Number of slices per direction", false, TCLAPint3(1, 1, 1), "by default 1 1 1");
+ cmd.add(slicingNumber);
+
+ TCLAP::ValueArg<float> angleVariation("", "avar", "Slicing angle variation", false, 0.0, "by default 0.0");
+ cmd.add(angleVariation);
+
+ TCLAP::ValueArg<float> offsetVariation("", "ovar", "Slicing offset variation", false, 0.0, "by default 0.0");
+ cmd.add(offsetVariation);
+
+ TCLAP::ValueArg<TCLAPfloat3> point("", "point", "Plane surface point", false, TCLAPfloat3(0, 0, 0), "by default 0 0 0");
+ cmd.add(point);
+
+ TCLAP::ValueArg<TCLAPfloat3> normal("", "normal", "Plane surface normal", false, TCLAPfloat3(1, 0, 0), "by default 1 0 0");
+ cmd.add(normal);
+
+ TCLAP::ValueArg<std::string> cutoutBitmapPath("", "cutoutBitmap", "Path to *.bmp file with cutout bitmap", false, ".", "by defualt empty");
+ cmd.add(cutoutBitmapPath);
+
+ try
+ {
+ // parse cmd input
+ cmd.parse(argc, argv);
+ }
+ catch (TCLAP::ArgException &e) // catch any exceptions
+ {
+ std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ return -1;
+ }
+
+ // get cmd parse results
+ std::string infile = infileArg.getValue();
+ if (!isFileExist(infile))
+ {
+ std::cerr << "[Error] Can't find input file: " << infile << std::endl;
+ return -1;
+ }
+
+ std::string outDir;
+
+ std::cout << "Input file: " << infile << std::endl;
+
+ if (outDirArg.isSet())
+ {
+ outDir = outDirArg.getValue();
+ std::string temp = outDir + '/';
+ if (!isDirectoryExist(outDir.data()))
+ {
+ std::cout << "Output directory doesn't exist. It will be created." << std::endl;
+ if (!mkDirRecursively(temp.data()))
+ {
+ std::cerr << "Directory creation failed!" << std::endl;
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ auto idx = infile.find_last_of("/\\");
+ if (idx == 0 || idx == std::string::npos)
+ {
+ outDir = ".";
+ }
+ else
+ {
+ outDir = infile.substr(0, idx);
+ }
+ }
+ std::cout << "Output directory: " << outDir << std::endl;
+ std::string assetName = outAssetName.getValue();
+
+ // Determine whether to use the obj or fbx loader
+
+ auto idx = infile.rfind('.');
+ std::string extension;
+
+
+ if (idx != std::string::npos)
+ {
+ extension = infile.substr(idx + 1);
+ std::transform(extension.begin(), extension.end(), extension.begin(), std::toupper);
+ }
+ else
+ {
+ std::cerr << "Can't determine extension (and thus, loader) of input file. " << infile << std::endl;
+ return -1;
+ }
+
+ bool bOutputPX = pxOutputArg.getValue();
+ bool bOutputTK = tkOutputArg.getValue();
+ bool bOutputLL = llOutputArg.getValue();
+
+ bool bOutputFBXAscii = fbxAsciiArg.getValue();
+
+ bool bOutputObjFile = objOutputArg.isSet();
+ bool bOutputFbxFile = fbxOutputArg.isSet();
+
+ // Did we specify no output formats?
+ if (!bOutputPX && !bOutputTK && !bOutputLL)
+ {
+ std::cout << "Didn't specify an output format on the command line. Use default: LL Blast asset (NvBlastAsset)." << std::endl;
+ bOutputLL = true;
+ }
+ else if ((int)bOutputPX + (int)bOutputTK + (int)bOutputLL > 1)
+ {
+ std::cerr << "More than one of the --ll, --tk, and --px options are set. Choose one. " << std::endl;
+ return -1;
+ }
+
+ // Did we specify no geometry output formats?
+ if (!bOutputObjFile && !bOutputFbxFile)
+ {
+ std::cout << "Didn't specify an output geometry format on the command line. Use default: .FBX" << std::endl;
+ bOutputFbxFile = true;
+ }
+
+ std::shared_ptr<IMeshFileReader> fileReader;
+
+ if (extension.compare("FBX")==0)
+ {
+ fileReader = std::shared_ptr<IMeshFileReader>(NvBlastExtExporterCreateFbxFileReader(), [](IMeshFileReader* p) {p->release(); });
+ }
+ else if (extension.compare("OBJ")==0)
+ {
+ fileReader = std::shared_ptr<IMeshFileReader>(NvBlastExtExporterCreateObjFileReader(), [](IMeshFileReader* p) {p->release(); });
+ }
+ else
+ {
+ std::cout << "Unsupported file extension " << extension << std::endl;
+ return -1;
+ }
+
+ // Load the asset
+ fileReader->loadFromFile(infile.c_str());
+
+ uint32_t vcount = fileReader->getVerticesCount();
+
+ if (!initPhysX())
+ {
+ std::cerr << "Failed to initialize PhysX" << std::endl;
+ return -1;
+ }
+ Nv::Blast::FractureTool* fTool = NvBlastExtAuthoringCreateFractureTool();
+
+ PxVec3* pos = fileReader->getPositionArray();
+ PxVec3* norm = fileReader->getNormalsArray();
+ PxVec2* uv = fileReader->getUvArray();
+
+ Nv::Blast::Mesh* mesh = NvBlastExtAuthoringCreateMesh(pos, norm, uv, vcount, fileReader->getIndexArray(), fileReader->getIndicesCount());
+
+ if (cleanArg.isSet())
+ {
+ MeshCleaner* clr = NvBlastExtAuthoringCreateMeshCleaner();
+ Nv::Blast::Mesh* nmesh;
+ nmesh = clr->cleanMesh(mesh);
+ clr->release();
+ mesh->release();
+ mesh = nmesh;
+ }
+ mesh->setMaterialId(fileReader->getMaterialIds());
+ mesh->setSmoothingGroup(fileReader->getSmoothingGroups());
+
+ fTool->setSourceMesh(mesh);
+
+
+ SimpleRandomGenerator rng;
+ Nv::Blast::VoronoiSitesGenerator* voronoiSitesGenerator = NvBlastExtAuthoringCreateVoronoiSitesGenerator(mesh, &rng);
+ if (voronoiSitesGenerator == nullptr)
+ {
+ std::cerr << "Failed to create Voronoi sites generator" << std::endl;
+ return -1;
+ }
+
+ // Send it to the fracture processor
+
+ switch (fracturingMode.getValue())
+ {
+ case 'v':
+ {
+ std::cout << "Fracturing with Voronoi..." << std::endl;
+ voronoiSitesGenerator->uniformlyGenerateSitesInMesh(cellsCount.getValue());
+ const physx::PxVec3* sites = nullptr;
+ uint32_t sitesCount = voronoiSitesGenerator->getVoronoiSites(sites);
+ if (fTool->voronoiFracturing(0, sitesCount, sites, false) != 0)
+ {
+ std::cerr << "Failed to fracture with Voronoi" << std::endl;
+ return -1;
+ }
+ break;
+ }
+ case 'c':
+ {
+ std::cout << "Fracturing with Clustered Voronoi..." << std::endl;
+ voronoiSitesGenerator->clusteredSitesGeneration(cellsCount.getValue(), clusterCount.getValue(), clusterRad.getValue());
+ const physx::PxVec3* sites = nullptr;
+ uint32_t sitesCount = voronoiSitesGenerator->getVoronoiSites(sites);
+ if (fTool->voronoiFracturing(0, sitesCount, sites, false) != 0)
+ {
+ std::cerr << "Failed to fracture with Clustered Voronoi" << std::endl;
+ return -1;
+ }
+ break;
+ }
+ case 's':
+ {
+ std::cout << "Fracturing with Slicing..." << std::endl;
+ SlicingConfiguration slConfig;
+ slConfig.x_slices = slicingNumber.getValue().x;
+ slConfig.y_slices = slicingNumber.getValue().y;
+ slConfig.z_slices = slicingNumber.getValue().z;
+ slConfig.angle_variations = angleVariation.getValue();
+ slConfig.offset_variations = offsetVariation.getValue();
+ if (fTool->slicing(0, slConfig, false, &rng) != 0)
+ {
+ std::cerr << "Failed to fracture with Slicing" << std::endl;
+ return -1;
+ }
+ break;
+ }
+ case 'p':
+ {
+ std::cout << "Plane cut fracturing..." << std::endl;
+ NoiseConfiguration noise;
+ if (fTool->cut(0, normal.getValue(), point.getValue(), noise, false, &rng) != 0)
+ {
+ std::cerr << "Failed to fracture with Cutout (in half-space, plane cut)" << std::endl;
+ return -1;
+ }
+ break;
+ }
+ case 'u':
+ {
+ std::cout << "Cutout fracturing..." << std::endl;
+ CutoutConfiguration cutoutConfig;
+ physx::PxVec3 axis = normal.getValue();
+ if (axis.isZero())
+ {
+ axis = PxVec3(0.f, 0.f, 1.f);
+ }
+ axis.normalize();
+ float d = axis.dot(physx::PxVec3(0.f, 0.f, 1.f));
+ if (d < (1e-6f - 1.0f))
+ {
+ cutoutConfig.transform.q = physx::PxQuat(physx::PxPi, PxVec3(1.f, 0.f, 0.f));
+ }
+ else if (d < 1.f)
+ {
+ float s = physx::PxSqrt((1 + d) * 2);
+ float invs = 1 / s;
+ auto c = axis.cross(PxVec3(0.f, 0.f, 1.f));
+ cutoutConfig.transform.q = physx::PxQuat(c.x * invs, c.y * invs, c.z * invs, s * 0.5f);
+ cutoutConfig.transform.q.normalize();
+ }
+ cutoutConfig.transform.p = point.getValue();
+ if (cutoutBitmapPath.isSet())
+ {
+ BITMAPINFOHEADER header;
+ uint8_t* bitmap = LoadBitmapFile(cutoutBitmapPath.getValue().c_str(), &header);
+ if (bitmap != nullptr)
+ {
+ cutoutConfig.cutoutSet = NvBlastExtAuthoringCreateCutoutSet();
+ NvBlastExtAuthoringBuildCutoutSet(*cutoutConfig.cutoutSet, bitmap, header.biWidth, header.biHeight, 0.001f, 1.f, false, true);
+ }
+ }
+ if (fTool->cutout(0, cutoutConfig, false, &rng) != 0)
+ {
+ std::cerr << "Failed to fracture with Cutout" << std::endl;
+ return -1;
+ }
+ break;
+ }
+ default:
+ std::cerr << "Unknown mode" << std::endl;
+ return -1;
+ }
+ voronoiSitesGenerator->release();
+ mesh->release();
+
+ Nv::Blast::BlastBondGenerator* bondGenerator = NvBlastExtAuthoringCreateBondGenerator(gCooking, &gPhysics->getPhysicsInsertionCallback());
+ Nv::Blast::ConvexMeshBuilder* collisionBuilder = NvBlastExtAuthoringCreateConvexMeshBuilder(gCooking, &gPhysics->getPhysicsInsertionCallback());
+ Nv::Blast::CollisionParams collisionParameter;
+ collisionParameter.maximumNumberOfHulls = 1;
+ collisionParameter.voxelGridResolution = 0;
+ Nv::Blast::AuthoringResult* result = NvBlastExtAuthoringProcessFracture(*fTool, *bondGenerator, *collisionBuilder, collisionParameter);
+ NvBlastTkFrameworkCreate();
+
+ collisionBuilder->release();
+ bondGenerator->release();
+ fTool->release();
+
+ // Output the results
+ // NOTE: Writing to FBX by default.
+
+ std::vector<const char*> matNames;
+ for (int32_t i = 0; i < fileReader->getMaterialCount(); ++i)
+ {
+ matNames.push_back(fileReader->getMaterialName(i));
+ }
+ result->materialNames = matNames.data();
+ result->materialCount = static_cast<uint32_t>(matNames.size());
+
+ const std::string assetNameFull = outDir + "\\" + assetName;
+
+ if (jsonCollision.isSet())
+ {
+ const std::string fullJsonFilename = assetNameFull + ".json";
+ IJsonCollisionExporter* collisionExporter = NvBlastExtExporterCreateJsonCollisionExporter();
+ if (collisionExporter != nullptr)
+ {
+ if (collisionExporter->writeCollision(fullJsonFilename.c_str(), result->chunkCount, result->collisionHullOffset, result->collisionHull))
+ {
+ std::cout << "Exported collision geometry: " << fullJsonFilename << std::endl;
+ }
+ else
+ {
+ std::cerr << "Can't write collision geometry to json file." << std::endl;
+ }
+ collisionExporter->release();
+ }
+ }
+
+ if (!fbxCollision.isSet())
+ {
+ result->releaseCollisionHulls();
+ }
+
+ if (bOutputObjFile)
+ {
+ std::shared_ptr<IMeshFileWriter> fileWriter(NvBlastExtExporterCreateObjFileWriter(), [](IMeshFileWriter* p) {p->release(); });
+ if (interiorMatId.isSet() && interiorMatId.getValue() >= 0)
+ {
+ fileWriter->setInteriorIndex(interiorMatId.getValue());
+ }
+ fileWriter->appendMesh(*result, assetName.c_str());
+ if (!fileWriter->saveToFile(assetName.c_str(), outDir.c_str()))
+ {
+ std::cerr << "Can't write geometry to OBJ file." << std::endl;
+ return -1;
+ }
+ std::cout << "Exported render mesh geometry: " << assetNameFull << ".obj" << std::endl;
+ }
+ if (bOutputFbxFile)
+ {
+ std::shared_ptr<IMeshFileWriter> fileWriter(NvBlastExtExporterCreateFbxFileWriter(bOutputFBXAscii), [](IMeshFileWriter* p) {p->release(); });
+ if (interiorMatId.isSet() && interiorMatId.getValue() >= 0)
+ {
+ fileWriter->setInteriorIndex(interiorMatId.getValue());
+ }
+ fileWriter->appendMesh(*result, assetName.c_str(), nonSkinnedFBX.isSet());
+ if (!fileWriter->saveToFile(assetName.c_str(), outDir.c_str()))
+ {
+ std::cerr << "Can't write geometry to FBX file." << std::endl;
+ return -1;
+ }
+ if (fbxCollision.isSet())
+ {
+ std::cout << "Exported render mesh and collision geometry: " << assetNameFull << ".fbx" << std::endl;
+ }
+ else
+ {
+ std::cout << "Exported render mesh geometry: " << assetNameFull << ".fbx" << std::endl;
+ }
+ }
+
+ auto saveBlastData = [&](BlastDataExporter& blExpr)
+ {
+ if (bOutputLL)
+ {
+ blExpr.saveBlastObject(outDir, assetName, result->asset, LlObjectTypeID::Asset);
+ std::cout << "Exported NvBlastAsset: " << assetNameFull << ".blast" << std::endl;
+ }
+ else
+ {
+ Nv::Blast::TkAssetDesc descriptor;
+ descriptor.bondCount = result->bondCount;
+ descriptor.bondDescs = result->bondDescs;
+ descriptor.bondFlags = nullptr;
+ descriptor.chunkCount = result->chunkCount;
+ descriptor.chunkDescs = result->chunkDescs;
+ Nv::Blast::ExtPxAsset* physicsAsset = Nv::Blast::ExtPxAsset::create(descriptor, result->physicsChunks, result->physicsSubchunks, *NvBlastTkFrameworkGet());
+ if (bOutputTK)
+ {
+ blExpr.saveBlastObject(outDir, assetName, &physicsAsset->getTkAsset(), TkObjectTypeID::Asset);
+ std::cout << "Exported TkAsset: " << assetNameFull << ".blast" << std::endl;
+ }
+ else if (bOutputPX)
+ {
+ blExpr.saveBlastObject(outDir, assetName, physicsAsset, ExtPxObjectTypeID::Asset);
+ std::cout << "Exported ExtPxAsset: " << assetNameFull << ".blast" << std::endl;
+ }
+ physicsAsset->release();
+ }
+ };
+
+ BlastDataExporter blExpr(NvBlastTkFrameworkGet(), gPhysics, gCooking);
+ saveBlastData(blExpr);
+
+ result->release();
+
+ std::cout << "Success!" << std::endl;
+
+ return 0;
+}
diff --git a/tools/AuthoringTool/src/SimpleRandomGenerator.h b/tools/AuthoringTool/src/SimpleRandomGenerator.h
index 63e2d45..9ad06ea 100644..100755
--- a/tools/AuthoringTool/src/SimpleRandomGenerator.h
+++ b/tools/AuthoringTool/src/SimpleRandomGenerator.h
@@ -1,27 +1,27 @@
-#pragma once
-#include "NvBlastExtAuthoringTypes.h"
-
-
-class SimpleRandomGenerator : public Nv::Blast::RandomGeneratorBase
-{
-public:
- SimpleRandomGenerator() {
- remember = false;
- };
-
- virtual float getRandomValue()
- {
- float r = (float)rand();
- r = r / RAND_MAX;
- return r;
- }
- virtual void seed(int32_t seed)
- {
- srand(seed);
- }
-
- virtual ~SimpleRandomGenerator() {};
-
-private:
- bool remember;
+#pragma once
+#include "NvBlastExtAuthoringTypes.h"
+
+
+class SimpleRandomGenerator : public Nv::Blast::RandomGeneratorBase
+{
+public:
+ SimpleRandomGenerator() {
+ remember = false;
+ };
+
+ virtual float getRandomValue()
+ {
+ float r = (float)rand();
+ r = r / RAND_MAX;
+ return r;
+ }
+ virtual void seed(int32_t seed)
+ {
+ srand(seed);
+ }
+
+ virtual ~SimpleRandomGenerator() {};
+
+private:
+ bool remember;
}; \ No newline at end of file
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 6e3c58c..6bb6507 100644..100755
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -1,95 +1,95 @@
-cmake_minimum_required(VERSION 3.3)
-
-project(BlastTools CXX)
-
-CMAKE_POLICY(SET CMP0057 NEW) # Enable IN_LIST
-
-IF(NOT DEFINED BLAST_ROOT_DIR)
-
- STRING(REPLACE "\\" "/" BRD_TEMP $ENV{BLAST_ROOT_DIR})
-
- # This env variable is set by GenerateProjects.bat, and is no longer available when CMake rebuilds, so this stores it in the cache
- SET(BLAST_ROOT_DIR ${BRD_TEMP} CACHE INTERNAL "Root of the Blast source tree")
-
-ENDIF()
-
-IF(NOT EXISTS ${BLAST_ROOT_DIR})
- MESSAGE(FATAL_ERROR "BLAST_ROOT_DIR environment variable wasn't set or was invalid.")
-ENDIF()
-
-
-SET(GW_DEPS_ROOT $ENV{PM_PACKAGES_ROOT})
-
-# Add the project specific CMake modules to the module path
-LIST(APPEND CMAKE_MODULE_PATH ${BLAST_ROOT_DIR}/sdk/compiler/cmake/modules/)
-
-IF(NOT DEFINED CMAKEMODULES_VERSION)
- SET(CMAKEMODULES_VERSION $ENV{PM_CMakeModules_VERSION} CACHE INTERNAL "CMakeModules version from generation batch")
-ENDIF()
-
-#TODO: More elegance
-IF(NOT EXISTS ${GW_DEPS_ROOT}/$ENV{PM_CMakeModules_NAME}/${CMAKEMODULES_VERSION})
- MESSAGE(FATAL_ERROR "Could not find $ENV{PM_CMakeModules_NAME}/${CMAKEMODULES_VERSION} at ${GW_DEPS_ROOT}")
-ENDIF()
-
-SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${GW_DEPS_ROOT}/$ENV{PM_CMakeModules_NAME}/${CMAKEMODULES_VERSION}")
-
-MESSAGE("Module path:" ${CMAKE_MODULE_PATH})
-
-
-IF(CMAKE_CONFIGURATION_TYPES)
- SET(CMAKE_CONFIGURATION_TYPES debug profile checked release)
- SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
- "Reset config to what we need"
- FORCE)
-
- SET(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
- SET(CMAKE_SHARED_LINKER_FLAGS_PROFILE "")
-
- SET(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
- SET(CMAKE_EXE_LINKER_FLAGS_PROFILE "")
-
-ENDIF()
-
-# Default to appending "DEBUG", "PROFILE", etc to produced artifacts
-IF(NOT DEFINED APPEND_CONFIG_NAME)
- SET(APPEND_CONFIG_NAME ON)
-ENDIF()
-
-IF (APPEND_CONFIG_NAME)
- MESSAGE("Appending config to output names")
-
- SET(CMAKE_DEBUG_POSTFIX "DEBUG")
- SET(CMAKE_PROFILE_POSTFIX "PROFILE")
- SET(CMAKE_CHECKED_POSTFIX "CHECKED")
- SET(CMAKE_RELEASE_POSTFIX "")
-ENDIF()
-
-INCLUDE(SetOutputPaths)
-
-# Either have to define a single output path, or each one.
-
-IF(NOT DEFINED BL_OUTPUT_DIR)
- IF (NOT DEFINED BL_LIB_OUTPUT_DIR)
- MESSAGE(FATAL_ERROR "BL_LIB_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
- ENDIF()
-
- IF (NOT DEFINED BL_DLL_OUTPUT_DIR)
- MESSAGE(FATAL_ERROR "BL_DLL_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
- ENDIF()
-
- IF (NOT DEFINED BL_EXE_OUTPUT_DIR)
- MESSAGE(FATAL_ERROR "BL_EXE_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
- ENDIF()
-
- SetLibOutputPath(${BL_LIB_OUTPUT_DIR})
- SetDllOutputPath(${BL_DLL_OUTPUT_DIR})
- SetExeOutputPath(${BL_EXE_OUTPUT_DIR})
-ELSE()
- SetSingleOutputPath(${BL_OUTPUT_DIR})
-ENDIF()
-
-SET(PROJECT_CMAKE_FILES_DIR compiler/cmake/)
-
-# Include the platform specific configuration
-INCLUDE(${PROJECT_CMAKE_FILES_DIR}${TARGET_BUILD_PLATFORM}/CMakeLists.txt OPTIONAL)
+cmake_minimum_required(VERSION 3.3)
+
+project(BlastTools CXX)
+
+CMAKE_POLICY(SET CMP0057 NEW) # Enable IN_LIST
+
+IF(NOT DEFINED BLAST_ROOT_DIR)
+
+ STRING(REPLACE "\\" "/" BRD_TEMP $ENV{BLAST_ROOT_DIR})
+
+ # This env variable is set by GenerateProjects.bat, and is no longer available when CMake rebuilds, so this stores it in the cache
+ SET(BLAST_ROOT_DIR ${BRD_TEMP} CACHE INTERNAL "Root of the Blast source tree")
+
+ENDIF()
+
+IF(NOT EXISTS ${BLAST_ROOT_DIR})
+ MESSAGE(FATAL_ERROR "BLAST_ROOT_DIR environment variable wasn't set or was invalid.")
+ENDIF()
+
+
+SET(GW_DEPS_ROOT $ENV{PM_PACKAGES_ROOT})
+
+# Add the project specific CMake modules to the module path
+LIST(APPEND CMAKE_MODULE_PATH ${BLAST_ROOT_DIR}/sdk/compiler/cmake/modules/)
+
+IF(NOT DEFINED CMAKEMODULES_VERSION)
+ SET(CMAKEMODULES_VERSION $ENV{PM_CMakeModules_VERSION} CACHE INTERNAL "CMakeModules version from generation batch")
+ENDIF()
+
+#TODO: More elegance
+IF(NOT EXISTS $ENV{PM_CMakeModules_PATH})
+ MESSAGE(FATAL_ERROR "Could not find $ENV{PM_CMakeModules_PATH}")
+ENDIF()
+
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{PM_CMakeModules_PATH}")
+
+MESSAGE("Module path:" ${CMAKE_MODULE_PATH})
+
+
+IF(CMAKE_CONFIGURATION_TYPES)
+ SET(CMAKE_CONFIGURATION_TYPES debug profile checked release)
+ SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
+ "Reset config to what we need"
+ FORCE)
+
+ SET(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
+ SET(CMAKE_SHARED_LINKER_FLAGS_PROFILE "")
+
+ SET(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
+ SET(CMAKE_EXE_LINKER_FLAGS_PROFILE "")
+
+ENDIF()
+
+# Default to appending "DEBUG", "PROFILE", etc to produced artifacts
+IF(NOT DEFINED APPEND_CONFIG_NAME)
+ SET(APPEND_CONFIG_NAME ON)
+ENDIF()
+
+IF (APPEND_CONFIG_NAME)
+ MESSAGE("Appending config to output names")
+
+ SET(CMAKE_DEBUG_POSTFIX "DEBUG")
+ SET(CMAKE_PROFILE_POSTFIX "PROFILE")
+ SET(CMAKE_CHECKED_POSTFIX "CHECKED")
+ SET(CMAKE_RELEASE_POSTFIX "")
+ENDIF()
+
+INCLUDE(SetOutputPaths)
+
+# Either have to define a single output path, or each one.
+
+IF(NOT DEFINED BL_OUTPUT_DIR)
+ IF (NOT DEFINED BL_LIB_OUTPUT_DIR)
+ MESSAGE(FATAL_ERROR "BL_LIB_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
+ ENDIF()
+
+ IF (NOT DEFINED BL_DLL_OUTPUT_DIR)
+ MESSAGE(FATAL_ERROR "BL_DLL_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
+ ENDIF()
+
+ IF (NOT DEFINED BL_EXE_OUTPUT_DIR)
+ MESSAGE(FATAL_ERROR "BL_EXE_OUTPUT_DIR not defined - Define either BL_OUTPUT_DIR or BL_LIB_OUTPUT_DIR and BL_DLL_OUTPUT_DIR and BL_EXE_OUTPUT_DIR")
+ ENDIF()
+
+ SetLibOutputPath(${BL_LIB_OUTPUT_DIR})
+ SetDllOutputPath(${BL_DLL_OUTPUT_DIR})
+ SetExeOutputPath(${BL_EXE_OUTPUT_DIR})
+ELSE()
+ SetSingleOutputPath(${BL_OUTPUT_DIR})
+ENDIF()
+
+SET(PROJECT_CMAKE_FILES_DIR compiler/cmake/)
+
+# Include the platform specific configuration
+INCLUDE(${PROJECT_CMAKE_FILES_DIR}${TARGET_BUILD_PLATFORM}/CMakeLists.txt OPTIONAL)
diff --git a/tools/LegacyConverter/src/Main.cpp b/tools/LegacyConverter/src/Main.cpp
index 74f261f..c3f677e 100644..100755
--- a/tools/LegacyConverter/src/Main.cpp
+++ b/tools/LegacyConverter/src/Main.cpp
@@ -1,329 +1,329 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "NvBlastExtSerialization.h"
-#include "NvBlastExtLlSerialization.h"
-#include "NvBlastExtTkSerialization.h"
-#include "NvBlastExtPxSerialization.h"
-#include "NvBlastTk.h"
-#include <string>
-#include <iostream>
-#include "tclap/CmdLine.h"
-#include <stdint.h>
-#include <iterator>
-#include <fstream>
-#include <functional>
-
-#include "PxIO.h"
-#include "PxPhysics.h"
-#include "PxFileBuf.h"
-#include "cooking/PxCooking.h"
-
-#include "NvBlastExtSerializationInternal.h"
-#include "NvBlastPxCallbacks.h"
-#include "PxFoundation.h"
-#include "PxFoundationVersion.h"
-#include "PxPhysicsVersion.h"
-
-
-using namespace Nv::Blast;
-using namespace physx;
-using namespace physx::general_PxIOStream2;
-
-
-static ExtSerializationInternal* sSer = nullptr;
-static TkFramework* sFwk = nullptr;
-static PxFoundation* sFnd = nullptr;
-static PxPhysics* sPhys = nullptr;
-static PxCooking* sCook = nullptr;
-
-
-static void str_to_upper(std::string& str)
-{
- for (auto & c : str) c = (char)::toupper(c);
-}
-
-
-static void decompose_filename(std::string& name, std::string& ext, const std::string& filename)
-{
- const size_t pos = filename.find_last_of('.');
- if (pos != std::string::npos)
- {
- name = filename.substr(0, pos);
- ext = filename.substr(pos + 1);
- }
- else
- {
- name = filename;
- ext = "";
- }
-}
-
-
-static uint32_t encodingID_from_str(const std::string& str)
-{
- const char* s = str.c_str();
- return str.length() >= 4 ? NVBLAST_FOURCC(s[0], s[1], s[2], s[3]) : 0;
-}
-
-
-static int init_framework()
-{
- // create serialization manager and load all serializers
- sSer = static_cast<ExtSerializationInternal*>(NvBlastExtSerializationCreate());
- if (sSer == nullptr)
- {
- std::cerr << "FAIL: Could not create serialization manager" << std::endl;
- return -1;
- }
-
- sFwk = NvBlastTkFrameworkCreate();
- if (sFwk != nullptr)
- {
- NvBlastExtTkSerializerLoadSet(*sFwk, *sSer);
- }
-
- sFnd = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
- if (sFnd != nullptr)
- {
- PxTolerancesScale tol;
- PxCookingParams cookingParams(tol);
- cookingParams.buildGPUData = true;
- sPhys = PxCreatePhysics(PX_PHYSICS_VERSION, *sFnd, tol, true);
- if (sPhys != nullptr)
- {
- sCook = PxCreateCooking(PX_PHYSICS_VERSION, sPhys->getFoundation(), cookingParams);
- if (sPhys != nullptr && sCook != nullptr)
- {
- NvBlastExtPxSerializerLoadSet(*sFwk, *sPhys, *sCook, *sSer);
- return 0;
- }
- }
- }
-
- return -1;
-}
-
-
-static void term_framework()
-{
- // release serialization
- if (sSer != nullptr)
- {
- sSer->release();
- }
-
- // release framework, physics, foundation, and cooking
- if (sCook != nullptr)
- {
- sCook->release();
- }
- if (sPhys != nullptr)
- {
- sPhys->release();
- }
- if (sFnd != nullptr)
- {
- sFnd->release();
- }
- if (sFwk != nullptr)
- {
- sFwk->release();
- }
-}
-
-
-static bool parse_inputs(uint32_t& objectTypeID, uint32_t& inEncodingID, std::string& outfile, uint32_t& outEncodingID, TCLAP::CmdLine& cmd, std::vector<std::string>& args, const std::string& infile)
-{
- TCLAP::ValueArg<std::string> typeArg("t", "type", "Input file type: llasset, tkasset, bpxa, pllasset, ptkasset, or pbpxa. The default will be based upon the input filename's extension.", false, "", "type");
- cmd.add(typeArg);
- TCLAP::ValueArg<std::string> outfileArg("o", "outfile", "Output filename. The extension will be .blast if none is given in the filename. If no outfile is given, infile with .blast extension will be used.", false, "", "outfile");
- cmd.add(outfileArg);
- TCLAP::ValueArg<std::string> encodingArg("e", "encoding", "Output encoding: cpnb or raw (default is cpnb).", false, "", "encoding");
- cmd.add(encodingArg);
-
- cmd.parse(args);
-
- std::string name;
- std::string ext;
- decompose_filename(name, ext, infile);
-
- std::string type = typeArg.isSet() ? typeArg.getValue() : ext;
- str_to_upper(type);
- const char* types[] = { "LLASSET", "PLLASSET", "TKASSET", "PTKASSET", "BPXA", "PBPXA" };
- size_t typeIndex = 0;
- for (; typeIndex < sizeof(types) / sizeof(types[0]) && type != types[typeIndex]; ++typeIndex) {}
-
- inEncodingID = ExtSerialization::EncodingID::CapnProtoBinary;
- switch (typeIndex)
- {
- case 0:
- inEncodingID = ExtSerialization::EncodingID::RawBinary;
- case 1:
- objectTypeID = LlObjectTypeID::Asset;
- break;
- case 2:
- inEncodingID = ExtSerialization::EncodingID::RawBinary;
- case 3:
- objectTypeID = TkObjectTypeID::Asset;
- break;
- case 4:
- inEncodingID = ExtSerialization::EncodingID::RawBinary;
- case 5:
- objectTypeID = ExtPxObjectTypeID::Asset;
- break;
- default:
- return false;
- }
-
- if (outfileArg.isSet())
- {
- outfile = outfileArg.getValue();
- if (std::string::npos == outfile.find_first_of('.'))
- {
- outfile += ".blast";
- }
- }
- else
- {
- outfile = name + ".blast";
- }
-
- std::string encoding = encodingArg.isSet() ? encodingArg.getValue() : "CPNB";
- str_to_upper(encoding);
- if (encoding.length() < 4)
- {
- encoding.insert(encoding.end(), 4 - encoding.length(), ' ');
- }
- outEncodingID = encodingID_from_str(encoding);
-
- return true;
-}
-
-
-int customMain(std::vector<std::string>& args)
-{
- try
- {
- // setup cmd line
- TCLAP::CmdLine cmd("Blast Legacy File Converter", ' ', "1.0");
-
- // parse cmd input
- std::string infile;
- if (args.size() > 1)
- {
- infile = args[1];
- args.erase(args.begin() + 1);
- }
- uint32_t objectTypeID;
- uint32_t inEncodingID;
- std::string outfile;
- uint32_t outEncodingID;
- if (!parse_inputs(objectTypeID, inEncodingID, outfile, outEncodingID, cmd, args, infile))
- {
- std::cerr << "FAIL: Could not parse inputs" << std::endl;
- return -1;
- }
-
- if (init_framework())
- {
- return -1;
- }
-
- sSer->setSerializationEncoding(outEncodingID);
-
- // find serializer
- ExtSerializer* serializer = sSer->findSerializer(objectTypeID, inEncodingID);
- if (serializer == nullptr)
- {
- std::cerr << "FAIL: No serializer for the file object type and encoding found" << std::endl;
- return -1;
- }
-
- // read input file
- std::ifstream infileStream(infile.c_str(), std::ios::binary);
- if (!infileStream.is_open())
- {
- std::cerr << "FAIL: Can't open input file: " << infile << std::endl;
- return -1;
- }
- const std::vector<char> inBuffer((std::istreambuf_iterator<char>(infileStream)), std::istreambuf_iterator<char>());
- infileStream.close();
-
- // deserialize
- void* object = serializer->deserializeFromBuffer(inBuffer.data(), inBuffer.size());
- if (object == nullptr)
- {
- std::cerr << "FAIL: serializer could not deserialize data from input file: " << infile << std::endl;
- return -1;
- }
-
- // serialize using manager, so that the appropriate header information is written
- void* outBuffer;
- const uint64_t bytesWritten = sSer->serializeIntoBuffer(outBuffer, object, objectTypeID);
- if (bytesWritten == 0)
- {
- std::cerr << "FAIL: could not serialize object in requested output format" << std::endl;
- return -1;
- }
-
- // release object
- NVBLAST_FREE(object);
-
- // write file
- std::ofstream outfileStream(outfile.c_str(), std::ios::binary);
- if (!outfileStream.is_open())
- {
- std::cerr << "FAIL: Can't open output file: " << outfile << std::endl;
- return -1;
- }
- outfileStream.write(reinterpret_cast<char*>(outBuffer), bytesWritten);
- outfileStream.close();
-
- // release buffer
- NVBLAST_FREE(outBuffer);
-
- // release framework
- term_framework();
- }
- catch (TCLAP::ArgException &e) // catch any exceptions
- {
- std::cout << "error: " << e.error() << " for arg " << e.argId() << std::endl;
- }
-
- return 0;
-}
-
-
-int main(int argc, const char* const* argv)
-{
- std::vector<std::string> args;
- for (int i = 0; i < argc; i++)
- args.push_back(argv[i]);
- return customMain(args);
-}
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "NvBlastExtSerialization.h"
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
+#include "NvBlastTk.h"
+#include <string>
+#include <iostream>
+#include "tclap/CmdLine.h"
+#include <stdint.h>
+#include <iterator>
+#include <fstream>
+#include <functional>
+
+#include "PxIO.h"
+#include "PxPhysics.h"
+#include "PxFileBuf.h"
+#include "cooking/PxCooking.h"
+
+#include "NvBlastExtSerializationInternal.h"
+#include "NvBlastPxCallbacks.h"
+#include "PxFoundation.h"
+#include "PxFoundationVersion.h"
+#include "PxPhysicsVersion.h"
+
+
+using namespace Nv::Blast;
+using namespace physx;
+using namespace physx::general_PxIOStream2;
+
+
+static ExtSerializationInternal* sSer = nullptr;
+static TkFramework* sFwk = nullptr;
+static PxFoundation* sFnd = nullptr;
+static PxPhysics* sPhys = nullptr;
+static PxCooking* sCook = nullptr;
+
+
+static void str_to_upper(std::string& str)
+{
+ for (auto & c : str) c = (char)::toupper(c);
+}
+
+
+static void decompose_filename(std::string& name, std::string& ext, const std::string& filename)
+{
+ const size_t pos = filename.find_last_of('.');
+ if (pos != std::string::npos)
+ {
+ name = filename.substr(0, pos);
+ ext = filename.substr(pos + 1);
+ }
+ else
+ {
+ name = filename;
+ ext = "";
+ }
+}
+
+
+static uint32_t encodingID_from_str(const std::string& str)
+{
+ const char* s = str.c_str();
+ return str.length() >= 4 ? NVBLAST_FOURCC(s[0], s[1], s[2], s[3]) : 0;
+}
+
+
+static int init_framework()
+{
+ // create serialization manager and load all serializers
+ sSer = static_cast<ExtSerializationInternal*>(NvBlastExtSerializationCreate());
+ if (sSer == nullptr)
+ {
+ std::cerr << "FAIL: Could not create serialization manager" << std::endl;
+ return -1;
+ }
+
+ sFwk = NvBlastTkFrameworkCreate();
+ if (sFwk != nullptr)
+ {
+ NvBlastExtTkSerializerLoadSet(*sFwk, *sSer);
+ }
+
+ sFnd = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
+ if (sFnd != nullptr)
+ {
+ PxTolerancesScale tol;
+ PxCookingParams cookingParams(tol);
+ cookingParams.buildGPUData = true;
+ sPhys = PxCreatePhysics(PX_PHYSICS_VERSION, *sFnd, tol, true);
+ if (sPhys != nullptr)
+ {
+ sCook = PxCreateCooking(PX_PHYSICS_VERSION, sPhys->getFoundation(), cookingParams);
+ if (sPhys != nullptr && sCook != nullptr)
+ {
+ NvBlastExtPxSerializerLoadSet(*sFwk, *sPhys, *sCook, *sSer);
+ return 0;
+ }
+ }
+ }
+
+ return -1;
+}
+
+
+static void term_framework()
+{
+ // release serialization
+ if (sSer != nullptr)
+ {
+ sSer->release();
+ }
+
+ // release framework, physics, foundation, and cooking
+ if (sCook != nullptr)
+ {
+ sCook->release();
+ }
+ if (sPhys != nullptr)
+ {
+ sPhys->release();
+ }
+ if (sFnd != nullptr)
+ {
+ sFnd->release();
+ }
+ if (sFwk != nullptr)
+ {
+ sFwk->release();
+ }
+}
+
+
+static bool parse_inputs(uint32_t& objectTypeID, uint32_t& inEncodingID, std::string& outfile, uint32_t& outEncodingID, TCLAP::CmdLine& cmd, std::vector<std::string>& args, const std::string& infile)
+{
+ TCLAP::ValueArg<std::string> typeArg("t", "type", "Input file type: llasset, tkasset, bpxa, pllasset, ptkasset, or pbpxa. The default will be based upon the input filename's extension.", false, "", "type");
+ cmd.add(typeArg);
+ TCLAP::ValueArg<std::string> outfileArg("o", "outfile", "Output filename. The extension will be .blast if none is given in the filename. If no outfile is given, infile with .blast extension will be used.", false, "", "outfile");
+ cmd.add(outfileArg);
+ TCLAP::ValueArg<std::string> encodingArg("e", "encoding", "Output encoding: cpnb or raw (default is cpnb).", false, "", "encoding");
+ cmd.add(encodingArg);
+
+ cmd.parse(args);
+
+ std::string name;
+ std::string ext;
+ decompose_filename(name, ext, infile);
+
+ std::string type = typeArg.isSet() ? typeArg.getValue() : ext;
+ str_to_upper(type);
+ const char* types[] = { "LLASSET", "PLLASSET", "TKASSET", "PTKASSET", "BPXA", "PBPXA" };
+ size_t typeIndex = 0;
+ for (; typeIndex < sizeof(types) / sizeof(types[0]) && type != types[typeIndex]; ++typeIndex) {}
+
+ inEncodingID = ExtSerialization::EncodingID::CapnProtoBinary;
+ switch (typeIndex)
+ {
+ case 0:
+ inEncodingID = ExtSerialization::EncodingID::RawBinary;
+ case 1:
+ objectTypeID = LlObjectTypeID::Asset;
+ break;
+ case 2:
+ inEncodingID = ExtSerialization::EncodingID::RawBinary;
+ case 3:
+ objectTypeID = TkObjectTypeID::Asset;
+ break;
+ case 4:
+ inEncodingID = ExtSerialization::EncodingID::RawBinary;
+ case 5:
+ objectTypeID = ExtPxObjectTypeID::Asset;
+ break;
+ default:
+ return false;
+ }
+
+ if (outfileArg.isSet())
+ {
+ outfile = outfileArg.getValue();
+ if (std::string::npos == outfile.find_first_of('.'))
+ {
+ outfile += ".blast";
+ }
+ }
+ else
+ {
+ outfile = name + ".blast";
+ }
+
+ std::string encoding = encodingArg.isSet() ? encodingArg.getValue() : "CPNB";
+ str_to_upper(encoding);
+ if (encoding.length() < 4)
+ {
+ encoding.insert(encoding.end(), 4 - encoding.length(), ' ');
+ }
+ outEncodingID = encodingID_from_str(encoding);
+
+ return true;
+}
+
+
+int customMain(std::vector<std::string>& args)
+{
+ try
+ {
+ // setup cmd line
+ TCLAP::CmdLine cmd("Blast Legacy File Converter", ' ', "1.0");
+
+ // parse cmd input
+ std::string infile;
+ if (args.size() > 1)
+ {
+ infile = args[1];
+ args.erase(args.begin() + 1);
+ }
+ uint32_t objectTypeID;
+ uint32_t inEncodingID;
+ std::string outfile;
+ uint32_t outEncodingID;
+ if (!parse_inputs(objectTypeID, inEncodingID, outfile, outEncodingID, cmd, args, infile))
+ {
+ std::cerr << "FAIL: Could not parse inputs" << std::endl;
+ return -1;
+ }
+
+ if (init_framework())
+ {
+ return -1;
+ }
+
+ sSer->setSerializationEncoding(outEncodingID);
+
+ // find serializer
+ ExtSerializer* serializer = sSer->findSerializer(objectTypeID, inEncodingID);
+ if (serializer == nullptr)
+ {
+ std::cerr << "FAIL: No serializer for the file object type and encoding found" << std::endl;
+ return -1;
+ }
+
+ // read input file
+ std::ifstream infileStream(infile.c_str(), std::ios::binary);
+ if (!infileStream.is_open())
+ {
+ std::cerr << "FAIL: Can't open input file: " << infile << std::endl;
+ return -1;
+ }
+ const std::vector<char> inBuffer((std::istreambuf_iterator<char>(infileStream)), std::istreambuf_iterator<char>());
+ infileStream.close();
+
+ // deserialize
+ void* object = serializer->deserializeFromBuffer(inBuffer.data(), inBuffer.size());
+ if (object == nullptr)
+ {
+ std::cerr << "FAIL: serializer could not deserialize data from input file: " << infile << std::endl;
+ return -1;
+ }
+
+ // serialize using manager, so that the appropriate header information is written
+ void* outBuffer;
+ const uint64_t bytesWritten = sSer->serializeIntoBuffer(outBuffer, object, objectTypeID);
+ if (bytesWritten == 0)
+ {
+ std::cerr << "FAIL: could not serialize object in requested output format" << std::endl;
+ return -1;
+ }
+
+ // release object
+ NVBLAST_FREE(object);
+
+ // write file
+ std::ofstream outfileStream(outfile.c_str(), std::ios::binary);
+ if (!outfileStream.is_open())
+ {
+ std::cerr << "FAIL: Can't open output file: " << outfile << std::endl;
+ return -1;
+ }
+ outfileStream.write(reinterpret_cast<char*>(outBuffer), bytesWritten);
+ outfileStream.close();
+
+ // release buffer
+ NVBLAST_FREE(outBuffer);
+
+ // release framework
+ term_framework();
+ }
+ catch (TCLAP::ArgException &e) // catch any exceptions
+ {
+ std::cout << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ }
+
+ return 0;
+}
+
+
+int main(int argc, const char* const* argv)
+{
+ std::vector<std::string> args;
+ for (int i = 0; i < argc; i++)
+ args.push_back(argv[i]);
+ return customMain(args);
+}
diff --git a/tools/common/BlastDataExporter.cpp b/tools/common/BlastDataExporter.cpp
index 3ffffb1..2f88476 100644..100755
--- a/tools/common/BlastDataExporter.cpp
+++ b/tools/common/BlastDataExporter.cpp
@@ -1,141 +1,141 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "BlastDataExporter.h"
-#include "NvBlastExtPxManager.h"
-#include <NvBlastExtAuthoringCollisionBuilder.h>
-#include "NvBlastExtSerialization.h"
-#include "NvBlastExtLlSerialization.h"
-#include "NvBlastExtTkSerialization.h"
-#include "NvBlastExtPxSerialization.h"
-#include <Log.h>
-#include "PsFileBuffer.h"
-#include "NvBlastExtPxAsset.h"
-#include "NvBlast.h"
-#include "NvBlastGlobals.h"
-#include <NvBlastTkAsset.h>
-#include <fstream>
-using namespace Nv::Blast;
-
-
-BlastDataExporter::BlastDataExporter(TkFramework* framework, physx::PxPhysics* physics, physx::PxCooking* cooking) : mFramework(framework)
-{
- mSerialization = NvBlastExtSerializationCreate();
- if (mSerialization != nullptr && physics != nullptr && cooking != nullptr && framework != nullptr)
- {
- NvBlastExtTkSerializerLoadSet(*framework, *mSerialization);
- NvBlastExtPxSerializerLoadSet(*framework, *physics, *cooking, *mSerialization);
- mSerialization->setSerializationEncoding(NVBLAST_FOURCC('C', 'P', 'N', 'B'));
- }
-}
-
-
-BlastDataExporter::~BlastDataExporter()
-{
- if (mSerialization != nullptr)
- {
- mSerialization->release();
- }
-}
-
-
-ExtPxAsset* BlastDataExporter::createExtBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs,
- std::vector<ExtPxAssetDesc::ChunkDesc>& physicsChunks)
-{
- ExtPxAssetDesc descriptor;
- descriptor.bondCount = static_cast<uint32_t>(bondDescs.size());
- descriptor.bondDescs = bondDescs.data();
- descriptor.chunkCount = static_cast<uint32_t>(chunkDescs.size());
- descriptor.chunkDescs = chunkDescs.data();
- descriptor.bondFlags = nullptr;
- descriptor.pxChunks = physicsChunks.data();
- ExtPxAsset* asset = ExtPxAsset::create(descriptor, *mFramework);
- return asset;
-}
-
-
-NvBlastAsset* BlastDataExporter::createLlBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs)
-{
- NvBlastAssetDesc assetDesc;
- assetDesc.bondCount = static_cast<uint32_t>(bondDescs.size());
- assetDesc.bondDescs = bondDescs.data();
-
- assetDesc.chunkCount = static_cast<uint32_t>(chunkDescs.size());
- assetDesc.chunkDescs = chunkDescs.data();
-
- std::vector<uint8_t> scratch(static_cast<unsigned int>(NvBlastGetRequiredScratchForCreateAsset(&assetDesc, logLL)));
- void* mem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&assetDesc, logLL));
- NvBlastAsset* asset = NvBlastCreateAsset(mem, &assetDesc, scratch.data(), logLL);
- return asset;
-}
-
-
-TkAsset* BlastDataExporter::createTkBlastAsset(const std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs)
-{
- TkAssetDesc desc;
- desc.bondCount = static_cast<uint32_t>(bondDescs.size());
- desc.bondDescs = bondDescs.data();
- desc.chunkCount = static_cast<uint32_t>(chunkDescs.size());
- desc.chunkDescs = chunkDescs.data();
- desc.bondFlags = nullptr;
- TkAsset* asset = mFramework->createAsset(desc);
- return asset;
-};
-
-
-bool BlastDataExporter::saveBlastObject(const std::string& outputDir, const std::string& objectName, const void* object, uint32_t objectTypeID)
-{
- void* buffer;
- const uint64_t bufferSize = mSerialization->serializeIntoBuffer(buffer, object, objectTypeID);
- if (bufferSize == 0)
- {
- std::cerr << "saveBlastObject: Serialization failed.\n";
- return false;
- }
-
- physx::PsFileBuffer fileBuf((outputDir + "/" + objectName + ".blast").c_str(), physx::PxFileBuf::OPEN_WRITE_ONLY);
- bool result = fileBuf.isOpen();
-
- if (!result)
- {
- std::cerr << "Can't open output buffer.\n";
- }
- else
- {
- result = (bufferSize == (size_t)fileBuf.write(buffer, (uint32_t)bufferSize));
- if (!result)
- {
- std::cerr << "Buffer write failed.\n";
- }
- fileBuf.close();
- }
-
- NVBLAST_FREE(buffer);
-
- return result;
-};
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "BlastDataExporter.h"
+#include "NvBlastExtPxManager.h"
+#include <NvBlastExtAuthoringCollisionBuilder.h>
+#include "NvBlastExtSerialization.h"
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
+#include <Log.h>
+#include "PsFileBuffer.h"
+#include "NvBlastExtPxAsset.h"
+#include "NvBlast.h"
+#include "NvBlastGlobals.h"
+#include <NvBlastTkAsset.h>
+#include <fstream>
+using namespace Nv::Blast;
+
+
+BlastDataExporter::BlastDataExporter(TkFramework* framework, physx::PxPhysics* physics, physx::PxCooking* cooking) : mFramework(framework)
+{
+ mSerialization = NvBlastExtSerializationCreate();
+ if (mSerialization != nullptr && physics != nullptr && cooking != nullptr && framework != nullptr)
+ {
+ NvBlastExtTkSerializerLoadSet(*framework, *mSerialization);
+ NvBlastExtPxSerializerLoadSet(*framework, *physics, *cooking, *mSerialization);
+ mSerialization->setSerializationEncoding(NVBLAST_FOURCC('C', 'P', 'N', 'B'));
+ }
+}
+
+
+BlastDataExporter::~BlastDataExporter()
+{
+ if (mSerialization != nullptr)
+ {
+ mSerialization->release();
+ }
+}
+
+
+ExtPxAsset* BlastDataExporter::createExtBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs,
+ std::vector<ExtPxAssetDesc::ChunkDesc>& physicsChunks)
+{
+ ExtPxAssetDesc descriptor;
+ descriptor.bondCount = static_cast<uint32_t>(bondDescs.size());
+ descriptor.bondDescs = bondDescs.data();
+ descriptor.chunkCount = static_cast<uint32_t>(chunkDescs.size());
+ descriptor.chunkDescs = chunkDescs.data();
+ descriptor.bondFlags = nullptr;
+ descriptor.pxChunks = physicsChunks.data();
+ ExtPxAsset* asset = ExtPxAsset::create(descriptor, *mFramework);
+ return asset;
+}
+
+
+NvBlastAsset* BlastDataExporter::createLlBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs)
+{
+ NvBlastAssetDesc assetDesc;
+ assetDesc.bondCount = static_cast<uint32_t>(bondDescs.size());
+ assetDesc.bondDescs = bondDescs.data();
+
+ assetDesc.chunkCount = static_cast<uint32_t>(chunkDescs.size());
+ assetDesc.chunkDescs = chunkDescs.data();
+
+ std::vector<uint8_t> scratch(static_cast<unsigned int>(NvBlastGetRequiredScratchForCreateAsset(&assetDesc, logLL)));
+ void* mem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&assetDesc, logLL));
+ NvBlastAsset* asset = NvBlastCreateAsset(mem, &assetDesc, scratch.data(), logLL);
+ return asset;
+}
+
+
+TkAsset* BlastDataExporter::createTkBlastAsset(const std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs)
+{
+ TkAssetDesc desc;
+ desc.bondCount = static_cast<uint32_t>(bondDescs.size());
+ desc.bondDescs = bondDescs.data();
+ desc.chunkCount = static_cast<uint32_t>(chunkDescs.size());
+ desc.chunkDescs = chunkDescs.data();
+ desc.bondFlags = nullptr;
+ TkAsset* asset = mFramework->createAsset(desc);
+ return asset;
+};
+
+
+bool BlastDataExporter::saveBlastObject(const std::string& outputDir, const std::string& objectName, const void* object, uint32_t objectTypeID)
+{
+ void* buffer;
+ const uint64_t bufferSize = mSerialization->serializeIntoBuffer(buffer, object, objectTypeID);
+ if (bufferSize == 0)
+ {
+ std::cerr << "saveBlastObject: Serialization failed.\n";
+ return false;
+ }
+
+ physx::PsFileBuffer fileBuf((outputDir + "/" + objectName + ".blast").c_str(), physx::PxFileBuf::OPEN_WRITE_ONLY);
+ bool result = fileBuf.isOpen();
+
+ if (!result)
+ {
+ std::cerr << "Can't open output buffer.\n";
+ }
+ else
+ {
+ result = (bufferSize == (size_t)fileBuf.write(buffer, (uint32_t)bufferSize));
+ if (!result)
+ {
+ std::cerr << "Buffer write failed.\n";
+ }
+ fileBuf.close();
+ }
+
+ NVBLAST_FREE(buffer);
+
+ return result;
+};
diff --git a/tools/common/BlastDataExporter.h b/tools/common/BlastDataExporter.h
index f3cae31..54e2bbf 100644..100755
--- a/tools/common/BlastDataExporter.h
+++ b/tools/common/BlastDataExporter.h
@@ -1,100 +1,100 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
-
-
-#ifndef BLAST_DATA_EXPORTER
-#define BLAST_DATA_EXPORTER
-
-
-#include <NvBlastIndexFns.h>
-#include <NvBlastExtAuthoringTypes.h>
-#include <NvBlastExtPxAsset.h>
-#include <vector>
-#include <string>
-
-using namespace Nv::Blast;
-
-namespace physx
-{
-class PxPhysics;
-class PxCooking;
-}
-
-
-struct NvBlastBondDesc;
-struct NvBlastChunkDesc;
-
-struct NvBlastAsset;
-namespace Nv
-{
-namespace Blast
-{
-class TkAsset;
-class ExtPxAsset;
-class ExtSerialization;
-}
-}
-
-
-/**
- Tool for Blast asset creation and exporting
-*/
-class BlastDataExporter
-{
-public:
- BlastDataExporter(TkFramework* framework, physx::PxPhysics* physics, physx::PxCooking* cooking);
- ~BlastDataExporter();
-
- /**
- Creates ExtPxAsset
- */
- ExtPxAsset* createExtBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs,
- std::vector<ExtPxAssetDesc::ChunkDesc>& physicsChunks);
- /**
- Creates Low Level Blast asset
- */
- NvBlastAsset* createLlBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs);
-
- /**
- Creates Blast Toolkit Asset asset
- */
- TkAsset* createTkBlastAsset(const std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs);
-
- /*
- Saves a Blast object to given path
- */
- bool saveBlastObject(const std::string& outputDir, const std::string& objectName, const void* object, uint32_t objectTypeID);
-
-private:
- TkFramework* mFramework;
- ExtSerialization* mSerialization;
-};
-
-
-
-
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef BLAST_DATA_EXPORTER
+#define BLAST_DATA_EXPORTER
+
+
+#include <NvBlastIndexFns.h>
+#include <NvBlastExtAuthoringTypes.h>
+#include <NvBlastExtPxAsset.h>
+#include <vector>
+#include <string>
+
+using namespace Nv::Blast;
+
+namespace physx
+{
+class PxPhysics;
+class PxCooking;
+}
+
+
+struct NvBlastBondDesc;
+struct NvBlastChunkDesc;
+
+struct NvBlastAsset;
+namespace Nv
+{
+namespace Blast
+{
+class TkAsset;
+class ExtPxAsset;
+class ExtSerialization;
+}
+}
+
+
+/**
+ Tool for Blast asset creation and exporting
+*/
+class BlastDataExporter
+{
+public:
+ BlastDataExporter(TkFramework* framework, physx::PxPhysics* physics, physx::PxCooking* cooking);
+ ~BlastDataExporter();
+
+ /**
+ Creates ExtPxAsset
+ */
+ ExtPxAsset* createExtBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs,
+ std::vector<ExtPxAssetDesc::ChunkDesc>& physicsChunks);
+ /**
+ Creates Low Level Blast asset
+ */
+ NvBlastAsset* createLlBlastAsset(std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs);
+
+ /**
+ Creates Blast Toolkit Asset asset
+ */
+ TkAsset* createTkBlastAsset(const std::vector<NvBlastBondDesc>& bondDescs, const std::vector<NvBlastChunkDesc>& chunkDescs);
+
+ /*
+ Saves a Blast object to given path
+ */
+ bool saveBlastObject(const std::string& outputDir, const std::string& objectName, const void* object, uint32_t objectTypeID);
+
+private:
+ TkFramework* mFramework;
+ ExtSerialization* mSerialization;
+};
+
+
+
+
#endif \ No newline at end of file
diff --git a/tools/common/Log.cpp b/tools/common/Log.cpp
index 0d4c8f7..57a25b4 100644..100755
--- a/tools/common/Log.cpp
+++ b/tools/common/Log.cpp
@@ -1,87 +1,87 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "Log.h"
-
-#include "PsString.h"
-
-#include <iomanip>
-#include <stdarg.h>
-#include <stdio.h>
-
-///////////////////////////////////////////////////////////////////////////
-
-namespace Nv
-{
-namespace Blast
-{
-
-void fLogf(const char* format, ...)
-{
- char buf[4096], *p = buf;
- va_list args;
- int n;
-
- va_start(args, format);
- //n = _vsnprintf(p, sizeof buf - 3, format, args);
- n = vsprintf_s(p, sizeof(buf)-3, format, args);
- va_end(args);
-
- p += (n < 0) ? sizeof buf - 3 : n;
-
- while (p > buf && isspace((unsigned char)p[-1]))
- {
- *--p = '\0';
- }
-
- *p++ = '\r';
- *p++ = '\n';
- *p = '\0';
-
- fLog(buf, Log::TYPE_INFO);
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-void Log::flushDeferredMessages()
-{
- if (mDeferredMessages.size() == 0) return;
-
- std::cout << std::endl;
- for (std::vector<std::string>::iterator it = mDeferredMessages.begin(); it != mDeferredMessages.end(); ++it)
- {
- log(*it, mMinVerbosity);
- }
- mDeferredMessages.clear();
-}
-
-
-
-} // namespace Blast
-} // namespace Nv
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "Log.h"
+
+#include "PsString.h"
+
+#include <iomanip>
+#include <stdarg.h>
+#include <stdio.h>
+
+///////////////////////////////////////////////////////////////////////////
+
+namespace Nv
+{
+namespace Blast
+{
+
+void fLogf(const char* format, ...)
+{
+ char buf[4096], *p = buf;
+ va_list args;
+ int n;
+
+ va_start(args, format);
+ //n = _vsnprintf(p, sizeof buf - 3, format, args);
+ n = vsprintf_s(p, sizeof(buf)-3, format, args);
+ va_end(args);
+
+ p += (n < 0) ? sizeof buf - 3 : n;
+
+ while (p > buf && isspace((unsigned char)p[-1]))
+ {
+ *--p = '\0';
+ }
+
+ *p++ = '\r';
+ *p++ = '\n';
+ *p = '\0';
+
+ fLog(buf, Log::TYPE_INFO);
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+void Log::flushDeferredMessages()
+{
+ if (mDeferredMessages.size() == 0) return;
+
+ std::cout << std::endl;
+ for (std::vector<std::string>::iterator it = mDeferredMessages.begin(); it != mDeferredMessages.end(); ++it)
+ {
+ log(*it, mMinVerbosity);
+ }
+ mDeferredMessages.clear();
+}
+
+
+
+} // namespace Blast
+} // namespace Nv
diff --git a/tools/common/Log.h b/tools/common/Log.h
index 8df9660..588c32b 100644..100755
--- a/tools/common/Log.h
+++ b/tools/common/Log.h
@@ -1,150 +1,150 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#ifndef LOG_H
-#define LOG_H
-
-#include "Utils.h"
-#include "PxVec3.h"
-
-#include <sstream>
-
-namespace Nv
-{
-namespace Blast
-{
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-void fLogf(const char* format, ...);
-
-class Log : public Singleton<Log>
-{
- friend class Singleton<Log>;
-
-public:
-
- enum MessageType {
- TYPE_INFO = 0,
- TYPE_WARNING,
- TYPE_ERROR,
- TYPE_DEFERRED,
-
- NUM_TYPES,
- MOST_VERBOSE = TYPE_INFO,
- LEAST_VERBOSE = TYPE_ERROR
-#if defined(_DEBUG)
- , DEFAULT_VERBOSITY = MOST_VERBOSE
-#else
- , DEFAULT_VERBOSITY = LEAST_VERBOSE
-#endif
- };
- typedef MessageType Verbosity;
-
- ///////////////////////////////////////////////////////////////////////////
-
- template<typename T>
- Log& log(const T& value, MessageType messageType);
-
- void flushDeferredMessages();
-
- ///////////////////////////////////////////////////////////////////////////
-
- void setCurrentVerbosity(Verbosity verbosity) { mCurrentVerbosity = verbosity; }
- Verbosity getCurrentVerbosity() const { return mCurrentVerbosity; }
-
- // Messages types below this level will be ignored
- void setMinVerbosity(Verbosity verbosity) { mMinVerbosity = verbosity; }
- Verbosity getMinVerbosity() const { return mMinVerbosity; }
-
- ///////////////////////////////////////////////////////////////////////////
-
-protected:
- Log(MessageType verbosity = DEFAULT_VERBOSITY)
- : mCurrentVerbosity(LEAST_VERBOSE),
- mMinVerbosity(verbosity) { }
-
-private:
- Verbosity mCurrentVerbosity;
- Verbosity mMinVerbosity;
- std::vector<std::string> mDeferredMessages;
-};
-
-///////////////////////////////////////////////////////////////////////////
-
-PX_INLINE std::ostream& operator<< (std::ostream& stream, const physx::PxVec3& vec)
-{
- return stream << "(" << vec.x << ", " << vec.y << ", " << vec.z << ")";
-}
-
-template<typename T>
-Log& Log::log(const T& value, Log::MessageType messageType)
-{
- if (TYPE_DEFERRED == messageType)
- {
- std::stringstream ss;
- ss << value;
- mDeferredMessages.push_back(ss.str());
- }
- else if(mMinVerbosity <= messageType)
- {
- std::cout << value;
- }
- return *this;
-}
-
-PX_INLINE Log& lout() { return Log::instance(); }
-
-template <typename T>
-PX_INLINE void fLog(const T& value, Log::MessageType messageType = Log::TYPE_INFO)
-{
- lout().log<T>(value, messageType);
-}
-template <typename T>
-PX_INLINE Log& operator<<(Log& logger, const T& value)
-{
- return logger.log<T>(value, logger.getCurrentVerbosity());
-}
-PX_INLINE Log& operator<<(Log& logger, Log::MessageType verbosity)
-{
- logger.setCurrentVerbosity(verbosity);
- return logger;
-}
-typedef std::ostream& (*ostream_manipulator)(std::ostream&);
-PX_INLINE Log& operator<<(Log& logger, ostream_manipulator pf)
-{
- return operator<< <ostream_manipulator> (logger, pf);
-}
-
-
-} // namespace Blast
-} // namespace Nv
-
-
-#endif
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef LOG_H
+#define LOG_H
+
+#include "Utils.h"
+#include "PxVec3.h"
+
+#include <sstream>
+
+namespace Nv
+{
+namespace Blast
+{
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+void fLogf(const char* format, ...);
+
+class Log : public Singleton<Log>
+{
+ friend class Singleton<Log>;
+
+public:
+
+ enum MessageType {
+ TYPE_INFO = 0,
+ TYPE_WARNING,
+ TYPE_ERROR,
+ TYPE_DEFERRED,
+
+ NUM_TYPES,
+ MOST_VERBOSE = TYPE_INFO,
+ LEAST_VERBOSE = TYPE_ERROR
+#if defined(_DEBUG)
+ , DEFAULT_VERBOSITY = MOST_VERBOSE
+#else
+ , DEFAULT_VERBOSITY = LEAST_VERBOSE
+#endif
+ };
+ typedef MessageType Verbosity;
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ template<typename T>
+ Log& log(const T& value, MessageType messageType);
+
+ void flushDeferredMessages();
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ void setCurrentVerbosity(Verbosity verbosity) { mCurrentVerbosity = verbosity; }
+ Verbosity getCurrentVerbosity() const { return mCurrentVerbosity; }
+
+ // Messages types below this level will be ignored
+ void setMinVerbosity(Verbosity verbosity) { mMinVerbosity = verbosity; }
+ Verbosity getMinVerbosity() const { return mMinVerbosity; }
+
+ ///////////////////////////////////////////////////////////////////////////
+
+protected:
+ Log(MessageType verbosity = DEFAULT_VERBOSITY)
+ : mCurrentVerbosity(LEAST_VERBOSE),
+ mMinVerbosity(verbosity) { }
+
+private:
+ Verbosity mCurrentVerbosity;
+ Verbosity mMinVerbosity;
+ std::vector<std::string> mDeferredMessages;
+};
+
+///////////////////////////////////////////////////////////////////////////
+
+PX_INLINE std::ostream& operator<< (std::ostream& stream, const physx::PxVec3& vec)
+{
+ return stream << "(" << vec.x << ", " << vec.y << ", " << vec.z << ")";
+}
+
+template<typename T>
+Log& Log::log(const T& value, Log::MessageType messageType)
+{
+ if (TYPE_DEFERRED == messageType)
+ {
+ std::stringstream ss;
+ ss << value;
+ mDeferredMessages.push_back(ss.str());
+ }
+ else if(mMinVerbosity <= messageType)
+ {
+ std::cout << value;
+ }
+ return *this;
+}
+
+PX_INLINE Log& lout() { return Log::instance(); }
+
+template <typename T>
+PX_INLINE void fLog(const T& value, Log::MessageType messageType = Log::TYPE_INFO)
+{
+ lout().log<T>(value, messageType);
+}
+template <typename T>
+PX_INLINE Log& operator<<(Log& logger, const T& value)
+{
+ return logger.log<T>(value, logger.getCurrentVerbosity());
+}
+PX_INLINE Log& operator<<(Log& logger, Log::MessageType verbosity)
+{
+ logger.setCurrentVerbosity(verbosity);
+ return logger;
+}
+typedef std::ostream& (*ostream_manipulator)(std::ostream&);
+PX_INLINE Log& operator<<(Log& logger, ostream_manipulator pf)
+{
+ return operator<< <ostream_manipulator> (logger, pf);
+}
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif
diff --git a/tools/common/Utils.cpp b/tools/common/Utils.cpp
index d42ed81..8355f48 100644..100755
--- a/tools/common/Utils.cpp
+++ b/tools/common/Utils.cpp
@@ -1,194 +1,194 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#include "Utils.h"
-
-#include "Log.h"
-
-#include <string.h>
-
-#if PX_WINDOWS_FAMILY
-#include <direct.h>
-#define getCwd _getcwd
-#else
-#include <unistd.h>
-#define getCwd getcwd
-#endif
-
-///////////////////////////////////////////////////////////////////////////
-
-namespace Nv
-{
-namespace Blast
-{
-
-//////////////////////////////////////////////////////////////////////////////
-
-static void addSlashToPath(std::string& path)
-{
- if (path[path.length() - 1] != '/' && path[path.length() - 1] != '\\')
- {
- path.append("/");
- }
-}
-
-FileUtils::FileUtils()
-{
- mSearchPaths.push_back("");
- char currentPathTemp[FILENAME_MAX];
- if (getCwd(currentPathTemp, sizeof(currentPathTemp)))
- {
- std::string currentPath(currentPathTemp);
- addSlashToPath(currentPath);
- addAbsolutePath(currentPath);
- mCurrentPath = currentPath;
- }
-}
-
-std::string FileUtils::getDirectory(const std::string& filePath)
-{
- return filePath.substr(0, filePath.find_last_of("/\\") + 1);
-}
-
-std::string FileUtils::getFilename(const std::string& filePath, bool bWithExtension)
-{
- size_t p0 = filePath.find_last_of("/\\") + 1;
- if (bWithExtension)
- {
- return filePath.substr(p0);
- }
- else
- {
- return filePath.substr(p0, filePath.find_last_of(".") - p0);
- }
-}
-
-std::string FileUtils::getFileExtension(const std::string& filePath)
-{
- std::string filename = getFilename(filePath);
- size_t p0 = filename.find_last_of(".");
- if (p0 != std::string::npos)
- return filePath.substr(p0);// + 1);
- return "";
-}
-
-void FileUtils::addAbsolutePath(const std::string& path)
-{
- if (path.empty())
- {
- return;
- }
-
- std::string newPath = path;
- addSlashToPath(newPath);
-
- mSearchPaths.push_back(newPath);
-}
-
-void FileUtils::addRelativePath(const std::string& relPath)
-{
- addAbsolutePath(mCurrentPath + relPath);
-}
-
-void FileUtils::clearPaths()
-{
- mSearchPaths.clear();
-}
-
-FILE* FileUtils::findFile(const std::string& path, bool bVerbose)
-{
- FILE* file;
- if (find(path, &file, NULL, bVerbose))
- {
- return file;
- }
- else
- {
- return NULL;
- }
-}
-
-std::string FileUtils::findPath(const std::string& path, bool bVerbose)
-{
- std::string fullPath;
- if (find(path, NULL, &fullPath, bVerbose))
- {
- return fullPath;
- }
- else
- {
- return path;
- }
-}
-
-bool FileUtils::find(const std::string& path, FILE** ppFile, std::string* pFullPath, bool bVerbose)
-{
- if (mSearchPaths.empty() || path.empty())
- {
- if (bVerbose)
- {
- lout() << Log::TYPE_ERROR << "Error: Invalid search path configuration.";
- }
- return false;
- }
-
- std::string fullPath;
-
- FILE* file = NULL;
- const uint32_t numSearchPaths = (uint32_t)mSearchPaths.size();
- for (uint32_t i = 0; i < numSearchPaths; ++i)
- {
- fullPath = mSearchPaths[i] + path;
- fopen_s(&file, fullPath.c_str(), "rb");
- if (file)
- {
- break;
- }
- }
-
- if (!file)
- {
- if (bVerbose)
- lout() << Log::TYPE_ERROR << std::endl << "Error: Unable to find file " << path << std::endl;
- return false;
- }
-
- if (ppFile)
- *ppFile = file;
- else
- fclose(file);
-
- if (pFullPath)
- *pFullPath = fullPath;
-
- return true;
-}
-
-
-} // namespace Blast
-} // namespace Nv
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#include "Utils.h"
+
+#include "Log.h"
+
+#include <string.h>
+
+#if PX_WINDOWS_FAMILY
+#include <direct.h>
+#define getCwd _getcwd
+#else
+#include <unistd.h>
+#define getCwd getcwd
+#endif
+
+///////////////////////////////////////////////////////////////////////////
+
+namespace Nv
+{
+namespace Blast
+{
+
+//////////////////////////////////////////////////////////////////////////////
+
+static void addSlashToPath(std::string& path)
+{
+ if (path[path.length() - 1] != '/' && path[path.length() - 1] != '\\')
+ {
+ path.append("/");
+ }
+}
+
+FileUtils::FileUtils()
+{
+ mSearchPaths.push_back("");
+ char currentPathTemp[FILENAME_MAX];
+ if (getCwd(currentPathTemp, sizeof(currentPathTemp)))
+ {
+ std::string currentPath(currentPathTemp);
+ addSlashToPath(currentPath);
+ addAbsolutePath(currentPath);
+ mCurrentPath = currentPath;
+ }
+}
+
+std::string FileUtils::getDirectory(const std::string& filePath)
+{
+ return filePath.substr(0, filePath.find_last_of("/\\") + 1);
+}
+
+std::string FileUtils::getFilename(const std::string& filePath, bool bWithExtension)
+{
+ size_t p0 = filePath.find_last_of("/\\") + 1;
+ if (bWithExtension)
+ {
+ return filePath.substr(p0);
+ }
+ else
+ {
+ return filePath.substr(p0, filePath.find_last_of(".") - p0);
+ }
+}
+
+std::string FileUtils::getFileExtension(const std::string& filePath)
+{
+ std::string filename = getFilename(filePath);
+ size_t p0 = filename.find_last_of(".");
+ if (p0 != std::string::npos)
+ return filePath.substr(p0);// + 1);
+ return "";
+}
+
+void FileUtils::addAbsolutePath(const std::string& path)
+{
+ if (path.empty())
+ {
+ return;
+ }
+
+ std::string newPath = path;
+ addSlashToPath(newPath);
+
+ mSearchPaths.push_back(newPath);
+}
+
+void FileUtils::addRelativePath(const std::string& relPath)
+{
+ addAbsolutePath(mCurrentPath + relPath);
+}
+
+void FileUtils::clearPaths()
+{
+ mSearchPaths.clear();
+}
+
+FILE* FileUtils::findFile(const std::string& path, bool bVerbose)
+{
+ FILE* file;
+ if (find(path, &file, NULL, bVerbose))
+ {
+ return file;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+std::string FileUtils::findPath(const std::string& path, bool bVerbose)
+{
+ std::string fullPath;
+ if (find(path, NULL, &fullPath, bVerbose))
+ {
+ return fullPath;
+ }
+ else
+ {
+ return path;
+ }
+}
+
+bool FileUtils::find(const std::string& path, FILE** ppFile, std::string* pFullPath, bool bVerbose)
+{
+ if (mSearchPaths.empty() || path.empty())
+ {
+ if (bVerbose)
+ {
+ lout() << Log::TYPE_ERROR << "Error: Invalid search path configuration.";
+ }
+ return false;
+ }
+
+ std::string fullPath;
+
+ FILE* file = NULL;
+ const uint32_t numSearchPaths = (uint32_t)mSearchPaths.size();
+ for (uint32_t i = 0; i < numSearchPaths; ++i)
+ {
+ fullPath = mSearchPaths[i] + path;
+ fopen_s(&file, fullPath.c_str(), "rb");
+ if (file)
+ {
+ break;
+ }
+ }
+
+ if (!file)
+ {
+ if (bVerbose)
+ lout() << Log::TYPE_ERROR << std::endl << "Error: Unable to find file " << path << std::endl;
+ return false;
+ }
+
+ if (ppFile)
+ *ppFile = file;
+ else
+ fclose(file);
+
+ if (pFullPath)
+ *pFullPath = fullPath;
+
+ return true;
+}
+
+
+} // namespace Blast
+} // namespace Nv
diff --git a/tools/common/Utils.h b/tools/common/Utils.h
index 5d01480..8eb3530 100644..100755
--- a/tools/common/Utils.h
+++ b/tools/common/Utils.h
@@ -1,141 +1,141 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
-
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include "PsString.h"
-
-#include <string>
-#include <iostream>
-#include <vector>
-#include <map>
-
-//////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////////////
-
-namespace Nv
-{
-namespace Blast
-{
-
-///////////////////////////////////////////////////////////////////////////
-
-template<class T>
-PX_INLINE bool isNull(const T* p) { return nullptr == p; }
-
-template<class Releasable, class Releaser> class ScopedResource;
-template<class Releasable, class Releaser>
-PX_INLINE bool isNull(const ScopedResource<Releasable,Releaser>& p) { return !p; }
-
-PX_INLINE bool isNullString(const char* pString)
-{
- return (nullptr == pString || pString[0] == '\0' || physx::shdfnd::strcmp(pString, "null") == 0);
-}
-
-template<class T>
-PX_INLINE bool isValid(const T& p) { return !isNull(p.get()); }
-
-PX_INLINE bool isValidString(const char* pString) { return !isNullString(pString); }
-
-///////////////////////////////////////////////////////////////////////////
-
-// Note: This is not a thread safe singleton class
-template <class T>
-class Singleton
-{
- // The fact that I cannot declare T a friend directly is rather absurd...
- typedef T Type;
- friend typename Singleton<T>::Type;
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- static T& instance()
- {
- static T _instance;
- return _instance;
- }
-
- //////////////////////////////////////////////////////////////////////////////
-
-private:
- Singleton() { }
- ~Singleton() { };
- Singleton(const Singleton&);
- Singleton& operator=(const Singleton&);
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-class FileUtils : public Singleton<FileUtils>
-{
- friend class Singleton<FileUtils>;
-
-public:
- void addAbsolutePath(const std::string&);
- void addRelativePath(const std::string&);
- void clearPaths();
-
- //////////////////////////////////////////////////////////////////////////////
-
- FILE* findFile(const std::string&, bool bVerbose = true);
- std::string findPath(const std::string&, bool bVerbose = true);
- bool find(const std::string&, FILE**, std::string*, bool bVerbose = true);
-
- //////////////////////////////////////////////////////////////////////////////
-
- const std::string& getCurrentPath() const
- {
- return mCurrentPath;
- }
-
- //////////////////////////////////////////////////////////////////////////////
-
- static std::string getDirectory(const std::string&);
- static std::string getFilename(const std::string&, bool bWithExtension = true);
- static std::string getFileExtension(const std::string&);
-
- //////////////////////////////////////////////////////////////////////////////
-
-protected:
- FileUtils();
-
- //////////////////////////////////////////////////////////////////////////////
-
- std::string mCurrentPath;
- std::vector<std::string> mSearchPaths;
-};
-
-
-} // namespace Blast
-} // namespace Nv
-
-
-#endif
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
+
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include "PsString.h"
+
+#include <string>
+#include <iostream>
+#include <vector>
+#include <map>
+
+//////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace Nv
+{
+namespace Blast
+{
+
+///////////////////////////////////////////////////////////////////////////
+
+template<class T>
+PX_INLINE bool isNull(const T* p) { return nullptr == p; }
+
+template<class Releasable, class Releaser> class ScopedResource;
+template<class Releasable, class Releaser>
+PX_INLINE bool isNull(const ScopedResource<Releasable,Releaser>& p) { return !p; }
+
+PX_INLINE bool isNullString(const char* pString)
+{
+ return (nullptr == pString || pString[0] == '\0' || physx::shdfnd::strcmp(pString, "null") == 0);
+}
+
+template<class T>
+PX_INLINE bool isValid(const T& p) { return !isNull(p.get()); }
+
+PX_INLINE bool isValidString(const char* pString) { return !isNullString(pString); }
+
+///////////////////////////////////////////////////////////////////////////
+
+// Note: This is not a thread safe singleton class
+template <class T>
+class Singleton
+{
+ // The fact that I cannot declare T a friend directly is rather absurd...
+ typedef T Type;
+ friend typename Singleton<T>::Type;
+
+ //////////////////////////////////////////////////////////////////////////////
+
+public:
+ static T& instance()
+ {
+ static T _instance;
+ return _instance;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+
+private:
+ Singleton() { }
+ ~Singleton() { };
+ Singleton(const Singleton&);
+ Singleton& operator=(const Singleton&);
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+class FileUtils : public Singleton<FileUtils>
+{
+ friend class Singleton<FileUtils>;
+
+public:
+ void addAbsolutePath(const std::string&);
+ void addRelativePath(const std::string&);
+ void clearPaths();
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ FILE* findFile(const std::string&, bool bVerbose = true);
+ std::string findPath(const std::string&, bool bVerbose = true);
+ bool find(const std::string&, FILE**, std::string*, bool bVerbose = true);
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ const std::string& getCurrentPath() const
+ {
+ return mCurrentPath;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ static std::string getDirectory(const std::string&);
+ static std::string getFilename(const std::string&, bool bWithExtension = true);
+ static std::string getFileExtension(const std::string&);
+
+ //////////////////////////////////////////////////////////////////////////////
+
+protected:
+ FileUtils();
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ std::string mCurrentPath;
+ std::vector<std::string> mSearchPaths;
+};
+
+
+} // namespace Blast
+} // namespace Nv
+
+
+#endif
diff --git a/tools/compiler/cmake/ApexImporter.cmake b/tools/compiler/cmake/ApexImporter.cmake
index f8e4a45..7ab0907 100644..100755
--- a/tools/compiler/cmake/ApexImporter.cmake
+++ b/tools/compiler/cmake/ApexImporter.cmake
@@ -1,81 +1,81 @@
-#
-# Build ApexImporter common
-#
-
-SET(APEXIMPORTER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/ApexImporter/src)
-SET(TOOLS_COMMON_DIR ${BLAST_ROOT_DIR}/tools/common)
-SET(TOOLS_COMMON_DIR ${BLAST_ROOT_DIR}/tools/common)
-SET(APEX_MODULES_DIR ${BLAST_ROOT_DIR}/sdk/extensions/import/apexmodules)
-
-FIND_PACKAGE(PhysXSDK $ENV{PM_PhysX_VERSION} REQUIRED)
-FIND_PACKAGE(PxSharedSDK $ENV{PM_PxShared_VERSION} REQUIRED)
-FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
-FIND_PACKAGE(FBXSDK $ENV{PM_FBXSDK_VERSION} REQUIRED)
-
-
-# Include here after the directories are defined so that the platform specific file can use the variables.
-include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/ApexImporter.cmake)
-
-SET(COMMON_FILES
- ${APEXIMPORTER_PLATFORM_COMMON_FILES}
-
- ${APEXIMPORTER_SOURCE_DIR}/Main.cpp
- ${APEXIMPORTER_SOURCE_DIR}/ApexDestructibleObjExporter.cpp
- ${APEXIMPORTER_SOURCE_DIR}/ApexDestructibleObjExporter.h
- ${BLAST_ROOT_DIR}/tools/common/BlastDataExporter.cpp
- ${BLAST_ROOT_DIR}/tools/common/BlastDataExporter.h
-)
-
-ADD_EXECUTABLE(ApexImporter
- ${COMMON_FILES}
-)
-
-set_target_properties(ApexImporter
- PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
- CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
- RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
- PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
-)
-
-SOURCE_GROUP("src" FILES ${COMMON_FILES})
-
-# Target specific compile options
-
-TARGET_INCLUDE_DIRECTORIES(ApexImporter
- PRIVATE ${APEXIMPORTER_PLATFORM_INCLUDES}
-
- PRIVATE ${BLAST_ROOT_DIR}/sdk/common
- PRIVATE ${TOOLS_COMMON_DIR}
-
- PRIVATE ${PHYSXSDK_INCLUDE_DIRS}
- PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
- PRIVATE ${TCLAP_INCLUDE_DIRS}
- PRIVATE ${FBXSDK_INCLUDE_DIRS}
-
- PRIVATE ${APEX_MODULES_DIR}/nvparutils
-
- PRIVATE ${APEX_MODULES_DIR}/NvParameterized/include
-)
-
-TARGET_COMPILE_DEFINITIONS(ApexImporter
- PRIVATE ${APEXIMPORTER_COMPILE_DEFS}
-)
-
-SET_TARGET_PROPERTIES(ApexImporter PROPERTIES
- COMPILE_PDB_NAME_DEBUG "ApexImporter${CMAKE_DEBUG_POSTFIX}"
- COMPILE_PDB_NAME_CHECKED "ApexImporter${CMAKE_CHECKED_POSTFIX}"
- COMPILE_PDB_NAME_PROFILE "ApexImporter${CMAKE_PROFILE_POSTFIX}"
- COMPILE_PDB_NAME_RELEASE "ApexImporter${CMAKE_RELEASE_POSTFIX}"
-)
-
-# Do final direct sets after the target has been defined
-TARGET_LINK_LIBRARIES(ApexImporter
- PRIVATE NvBlast NvBlastExtPhysX NvBlastExtAuthoring NvBlastExtImport NvBlastExtExporter NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization Rpcrt4
- PRIVATE ${FBXSDK_LIBRARIES}
-)
-
-ADD_CUSTOM_COMMAND(TARGET ApexImporter POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
- ${BL_EXE_OUTPUT_DIR}
-)
+#
+# Build ApexImporter common
+#
+
+SET(APEXIMPORTER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/ApexImporter/src)
+SET(TOOLS_COMMON_DIR ${BLAST_ROOT_DIR}/tools/common)
+SET(TOOLS_COMMON_DIR ${BLAST_ROOT_DIR}/tools/common)
+SET(APEX_MODULES_DIR ${BLAST_ROOT_DIR}/sdk/extensions/import/apexmodules)
+
+FIND_PACKAGE(PhysXSDK $ENV{PM_PhysX_VERSION} REQUIRED)
+FIND_PACKAGE(PxSharedSDK $ENV{PM_PxShared_VERSION} REQUIRED)
+FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
+FIND_PACKAGE(FBXSDK $ENV{PM_FBXSDK_VERSION} REQUIRED)
+
+
+# Include here after the directories are defined so that the platform specific file can use the variables.
+include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/ApexImporter.cmake)
+
+SET(COMMON_FILES
+ ${APEXIMPORTER_PLATFORM_COMMON_FILES}
+
+ ${APEXIMPORTER_SOURCE_DIR}/Main.cpp
+ ${APEXIMPORTER_SOURCE_DIR}/ApexDestructibleObjExporter.cpp
+ ${APEXIMPORTER_SOURCE_DIR}/ApexDestructibleObjExporter.h
+ ${BLAST_ROOT_DIR}/tools/common/BlastDataExporter.cpp
+ ${BLAST_ROOT_DIR}/tools/common/BlastDataExporter.h
+)
+
+ADD_EXECUTABLE(ApexImporter
+ ${COMMON_FILES}
+)
+
+set_target_properties(ApexImporter
+ PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
+ CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
+ RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
+ PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
+)
+
+SOURCE_GROUP("src" FILES ${COMMON_FILES})
+
+# Target specific compile options
+
+TARGET_INCLUDE_DIRECTORIES(ApexImporter
+ PRIVATE ${APEXIMPORTER_PLATFORM_INCLUDES}
+
+ PRIVATE ${BLAST_ROOT_DIR}/sdk/common
+ PRIVATE ${TOOLS_COMMON_DIR}
+
+ PRIVATE ${PHYSXSDK_INCLUDE_DIRS}
+ PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
+ PRIVATE ${TCLAP_INCLUDE_DIRS}
+ PRIVATE ${FBXSDK_INCLUDE_DIRS}
+
+ PRIVATE ${APEX_MODULES_DIR}/nvparutils
+
+ PRIVATE ${APEX_MODULES_DIR}/NvParameterized/include
+)
+
+TARGET_COMPILE_DEFINITIONS(ApexImporter
+ PRIVATE ${APEXIMPORTER_COMPILE_DEFS}
+)
+
+SET_TARGET_PROPERTIES(ApexImporter PROPERTIES
+ COMPILE_PDB_NAME_DEBUG "ApexImporter${CMAKE_DEBUG_POSTFIX}"
+ COMPILE_PDB_NAME_CHECKED "ApexImporter${CMAKE_CHECKED_POSTFIX}"
+ COMPILE_PDB_NAME_PROFILE "ApexImporter${CMAKE_PROFILE_POSTFIX}"
+ COMPILE_PDB_NAME_RELEASE "ApexImporter${CMAKE_RELEASE_POSTFIX}"
+)
+
+# Do final direct sets after the target has been defined
+TARGET_LINK_LIBRARIES(ApexImporter
+ PRIVATE NvBlast NvBlastExtPhysX NvBlastExtAuthoring NvBlastExtImport NvBlastExtExporter NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization Rpcrt4
+ PRIVATE ${FBXSDK_LIBRARIES}
+)
+
+ADD_CUSTOM_COMMAND(TARGET ApexImporter POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
+ ${BL_EXE_OUTPUT_DIR}
+)
diff --git a/tools/compiler/cmake/AuthoringTool.cmake b/tools/compiler/cmake/AuthoringTool.cmake
index 82132b9..3b16da0 100644..100755
--- a/tools/compiler/cmake/AuthoringTool.cmake
+++ b/tools/compiler/cmake/AuthoringTool.cmake
@@ -1,85 +1,85 @@
-#
-# Build AuthoringTool common
-#
-
-SET(AUTHORTINGTOOL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/AuthoringTool/src)
-SET(TOOLS_COMMON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/common)
-
-SET(EXT_AUTHORING_INCLUDE_DIR ${BLAST_ROOT_DIR}/sdk/extensions/authoring/include)
-SET(TK_INCLUDE_DIR ${BLAST_ROOT_DIR}/sdk/toolkit/include)
-
-FIND_PACKAGE(PhysXSDK $ENV{PM_PhysXSDK_VERSION} REQUIRED)
-FIND_PACKAGE(PxSharedSDK $ENV{PM_PxSharedSDK_VERSION} REQUIRED)
-FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
-FIND_PACKAGE(tinyObjLoader $ENV{PM_tinyObjLoader_VERSION} REQUIRED)
-FIND_PACKAGE(FBXSDK $ENV{PM_FBXSDK_VERSION} REQUIRED)
-
-
-# Include here after the directories are defined so that the platform specific file can use the variables.
-include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/AuthoringTool.cmake)
-
-SET(COMMON_FILES
- ${AUTHORTINGTOOL_PLATFORM_COMMON_FILES}
-
- ${AUTHORTINGTOOL_SOURCE_DIR}/AuthoringTool.cpp
- ${AUTHORTINGTOOL_SOURCE_DIR}/SimpleRandomGenerator.h
- ${TOOLS_COMMON_SOURCE_DIR}/BlastDataExporter.h
- ${TOOLS_COMMON_SOURCE_DIR}/BlastDataExporter.cpp
-)
-
-ADD_EXECUTABLE(AuthoringTool
- ${COMMON_FILES}
-)
-
-set_target_properties(AuthoringTool
- PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
- CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
- RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
- PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
-)
-
-SOURCE_GROUP("src" FILES ${COMMON_FILES})
-
-# Target specific compile options
-
-TARGET_INCLUDE_DIRECTORIES(AuthoringTool
- PRIVATE ${AUTHORTINGTOOL_PLATFORM_INCLUDES}
-
- PRIVATE ${TOOLS_COMMON_SOURCE_DIR}
- PRIVATE ${EXT_AUTHORING_INCLUDE_DIR}
- PRIVATE ${TK_INCLUDE_DIR}
- PRIVATE ${BLAST_ROOT_DIR}/sdk/common
- PRIVATE ${BLAST_ROOT_DIR}/sdk/extensions/common/include
-
- PRIVATE ${PHYSXSDK_INCLUDE_DIRS}
- PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
- PRIVATE ${TCLAP_INCLUDE_DIRS}
- PRIVATE ${TINYOBJLOADER_INCLUDE_DIRS}
- PRIVATE ${FBXSDK_INCLUDE_DIRS}
-)
-
-TARGET_COMPILE_DEFINITIONS(AuthoringTool
- PRIVATE ${AUTHORTINGTOOL_COMPILE_DEFS}
-)
-
-SET_TARGET_PROPERTIES(AuthoringTool PROPERTIES
- PDB_NAME_DEBUG "AuthoringTool${CMAKE_DEBUG_POSTFIX}"
- PDB_NAME_CHECKED "AuthoringTool${CMAKE_CHECKED_POSTFIX}"
- PDB_NAME_PROFILE "AuthoringTool${CMAKE_PROFILE_POSTFIX}"
- PDB_NAME_RELEASE "AuthoringTool${CMAKE_RELEASE_POSTFIX}"
-)
-
-# Do final direct sets after the target has been defined
-TARGET_LINK_LIBRARIES(AuthoringTool
- PRIVATE NvBlast NvBlastTk NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization NvBlastExtPhysX NvBlastExtExporter NvBlastExtAuthoring
- PRIVATE ${FBXSDK_LIBRARIES}
-)
-
-# Copy the dlls from the deps
-
-ADD_CUSTOM_COMMAND(TARGET AuthoringTool POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${APEXSDK_DLLS} ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
- ${BL_EXE_OUTPUT_DIR}
-)
-
+#
+# Build AuthoringTool common
+#
+
+SET(AUTHORTINGTOOL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/AuthoringTool/src)
+SET(TOOLS_COMMON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/common)
+
+SET(EXT_AUTHORING_INCLUDE_DIR ${BLAST_ROOT_DIR}/sdk/extensions/authoring/include)
+SET(TK_INCLUDE_DIR ${BLAST_ROOT_DIR}/sdk/toolkit/include)
+
+FIND_PACKAGE(PhysXSDK $ENV{PM_PhysXSDK_VERSION} REQUIRED)
+FIND_PACKAGE(PxSharedSDK $ENV{PM_PxSharedSDK_VERSION} REQUIRED)
+FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
+FIND_PACKAGE(tinyObjLoader $ENV{PM_tinyObjLoader_VERSION} REQUIRED)
+FIND_PACKAGE(FBXSDK $ENV{PM_FBXSDK_VERSION} REQUIRED)
+
+
+# Include here after the directories are defined so that the platform specific file can use the variables.
+include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/AuthoringTool.cmake)
+
+SET(COMMON_FILES
+ ${AUTHORTINGTOOL_PLATFORM_COMMON_FILES}
+
+ ${AUTHORTINGTOOL_SOURCE_DIR}/AuthoringTool.cpp
+ ${AUTHORTINGTOOL_SOURCE_DIR}/SimpleRandomGenerator.h
+ ${TOOLS_COMMON_SOURCE_DIR}/BlastDataExporter.h
+ ${TOOLS_COMMON_SOURCE_DIR}/BlastDataExporter.cpp
+)
+
+ADD_EXECUTABLE(AuthoringTool
+ ${COMMON_FILES}
+)
+
+set_target_properties(AuthoringTool
+ PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
+ CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
+ RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
+ PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
+)
+
+SOURCE_GROUP("src" FILES ${COMMON_FILES})
+
+# Target specific compile options
+
+TARGET_INCLUDE_DIRECTORIES(AuthoringTool
+ PRIVATE ${AUTHORTINGTOOL_PLATFORM_INCLUDES}
+
+ PRIVATE ${TOOLS_COMMON_SOURCE_DIR}
+ PRIVATE ${EXT_AUTHORING_INCLUDE_DIR}
+ PRIVATE ${TK_INCLUDE_DIR}
+ PRIVATE ${BLAST_ROOT_DIR}/sdk/common
+ PRIVATE ${BLAST_ROOT_DIR}/sdk/extensions/common/include
+
+ PRIVATE ${PHYSXSDK_INCLUDE_DIRS}
+ PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
+ PRIVATE ${TCLAP_INCLUDE_DIRS}
+ PRIVATE ${TINYOBJLOADER_INCLUDE_DIRS}
+ PRIVATE ${FBXSDK_INCLUDE_DIRS}
+)
+
+TARGET_COMPILE_DEFINITIONS(AuthoringTool
+ PRIVATE ${AUTHORTINGTOOL_COMPILE_DEFS}
+)
+
+SET_TARGET_PROPERTIES(AuthoringTool PROPERTIES
+ PDB_NAME_DEBUG "AuthoringTool${CMAKE_DEBUG_POSTFIX}"
+ PDB_NAME_CHECKED "AuthoringTool${CMAKE_CHECKED_POSTFIX}"
+ PDB_NAME_PROFILE "AuthoringTool${CMAKE_PROFILE_POSTFIX}"
+ PDB_NAME_RELEASE "AuthoringTool${CMAKE_RELEASE_POSTFIX}"
+)
+
+# Do final direct sets after the target has been defined
+TARGET_LINK_LIBRARIES(AuthoringTool
+ PRIVATE NvBlast NvBlastTk NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization NvBlastExtPhysX NvBlastExtExporter NvBlastExtAuthoring
+ PRIVATE ${FBXSDK_LIBRARIES}
+)
+
+# Copy the dlls from the deps
+
+ADD_CUSTOM_COMMAND(TARGET AuthoringTool POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${APEXSDK_DLLS} ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
+ ${BL_EXE_OUTPUT_DIR}
+)
+
diff --git a/tools/compiler/cmake/LegacyConverter.cmake b/tools/compiler/cmake/LegacyConverter.cmake
index dde63d0..7a2c959 100644..100755
--- a/tools/compiler/cmake/LegacyConverter.cmake
+++ b/tools/compiler/cmake/LegacyConverter.cmake
@@ -1,63 +1,63 @@
-#
-# Build LegacyConverter common
-#
-
-SET(LEGACYCONVERTER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/LegacyConverter/src)
-
-FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
-FIND_PACKAGE(PhysXSDK $ENV{PM_PhysX_VERSION} REQUIRED)
-FIND_PACKAGE(PxSharedSDK $ENV{PM_PxShared_VERSION} REQUIRED)
-
-# Include here after the directories are defined so that the platform specific file can use the variables.
-include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/LegacyConverter.cmake)
-
-SET(COMMON_FILES
- ${LEGACYCONVERTER_PLATFORM_COMMON_FILES}
-
- ${LEGACYCONVERTER_SOURCE_DIR}/Main.cpp
-)
-
-ADD_EXECUTABLE(LegacyConverter
- ${COMMON_FILES}
-)
-
-set_target_properties(LegacyConverter
- PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
- CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
- RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
- PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
-)
-
-
-SOURCE_GROUP("src" FILES ${COMMON_FILES})
-
-# Target specific compile options
-
-TARGET_INCLUDE_DIRECTORIES(LegacyConverter
- PRIVATE ${LEGACYCONVERTER_PLATFORM_INCLUDES}
- PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
- PRIVATE ${BLAST_ROOT_DIR}/source/common
-
- PRIVATE ${TCLAP_INCLUDE_DIRS}
-)
-
-TARGET_COMPILE_DEFINITIONS(LegacyConverter
- PRIVATE ${LEGACYCONVERTER_COMPILE_DEFS}
-)
-
-SET_TARGET_PROPERTIES(LegacyConverter PROPERTIES
- PDB_NAME_DEBUG "LegacyConverter${CMAKE_DEBUG_POSTFIX}"
- PDB_NAME_CHECKED "LegacyConverter${CMAKE_CHECKED_POSTFIX}"
- PDB_NAME_PROFILE "LegacyConverter${CMAKE_PROFILE_POSTFIX}"
- PDB_NAME_RELEASE "LegacyConverter${CMAKE_RELEASE_POSTFIX}"
-)
-
-# Do final direct sets after the target has been defined
-TARGET_LINK_LIBRARIES(LegacyConverter NvBlast NvBlastTk NvBlastExtPhysX NvBlastExtImport NvBlastExtExporter NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization)
-
-
-ADD_CUSTOM_COMMAND(TARGET LegacyConverter POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
- ${BL_EXE_OUTPUT_DIR}
-)
+#
+# Build LegacyConverter common
+#
+
+SET(LEGACYCONVERTER_SOURCE_DIR ${PROJECT_SOURCE_DIR}/LegacyConverter/src)
+
+FIND_PACKAGE(tclap $ENV{PM_tclap_VERSION} REQUIRED)
+FIND_PACKAGE(PhysXSDK $ENV{PM_PhysX_VERSION} REQUIRED)
+FIND_PACKAGE(PxSharedSDK $ENV{PM_PxShared_VERSION} REQUIRED)
+
+# Include here after the directories are defined so that the platform specific file can use the variables.
+include(${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/LegacyConverter.cmake)
+
+SET(COMMON_FILES
+ ${LEGACYCONVERTER_PLATFORM_COMMON_FILES}
+
+ ${LEGACYCONVERTER_SOURCE_DIR}/Main.cpp
+)
+
+ADD_EXECUTABLE(LegacyConverter
+ ${COMMON_FILES}
+)
+
+set_target_properties(LegacyConverter
+ PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
+ CHECKED_POSTFIX ${CMAKE_CHECKED_POSTFIX}
+ RELEASE_POSTFIX ${CMAKE_RELEASE_POSTFIX}
+ PROFILE_POSTFIX ${CMAKE_PROFILE_POSTFIX}
+)
+
+
+SOURCE_GROUP("src" FILES ${COMMON_FILES})
+
+# Target specific compile options
+
+TARGET_INCLUDE_DIRECTORIES(LegacyConverter
+ PRIVATE ${LEGACYCONVERTER_PLATFORM_INCLUDES}
+ PRIVATE ${PXSHAREDSDK_INCLUDE_DIRS}
+ PRIVATE ${BLAST_ROOT_DIR}/source/common
+
+ PRIVATE ${TCLAP_INCLUDE_DIRS}
+)
+
+TARGET_COMPILE_DEFINITIONS(LegacyConverter
+ PRIVATE ${LEGACYCONVERTER_COMPILE_DEFS}
+)
+
+SET_TARGET_PROPERTIES(LegacyConverter PROPERTIES
+ PDB_NAME_DEBUG "LegacyConverter${CMAKE_DEBUG_POSTFIX}"
+ PDB_NAME_CHECKED "LegacyConverter${CMAKE_CHECKED_POSTFIX}"
+ PDB_NAME_PROFILE "LegacyConverter${CMAKE_PROFILE_POSTFIX}"
+ PDB_NAME_RELEASE "LegacyConverter${CMAKE_RELEASE_POSTFIX}"
+)
+
+# Do final direct sets after the target has been defined
+TARGET_LINK_LIBRARIES(LegacyConverter NvBlast NvBlastTk NvBlastExtPhysX NvBlastExtImport NvBlastExtExporter NvBlastExtSerialization NvBlastExtTkSerialization NvBlastExtPxSerialization)
+
+
+ADD_CUSTOM_COMMAND(TARGET LegacyConverter POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${PHYSXSDK_DLLS} ${PXSHAREDSDK_DLLS}
+ ${BL_EXE_OUTPUT_DIR}
+)
diff --git a/tools/compiler/cmake/Windows/ApexImporter.cmake b/tools/compiler/cmake/Windows/ApexImporter.cmake
index 6ed576d..17d4234 100644..100755
--- a/tools/compiler/cmake/Windows/ApexImporter.cmake
+++ b/tools/compiler/cmake/Windows/ApexImporter.cmake
@@ -1,20 +1,20 @@
-#
-# Build ApexImporter Windows
-#
-
-SET(APEXIMPORTER_PLATFORM_COMMON_FILES
-)
-
-SET(APEXIMPORTER_PLATFORM_INCLUDES
-)
-
-SET(APEXIMPORTER_COMPILE_DEFS
- # Common to all configurations
- ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
-
- $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
- $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
- $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
- $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
-)
-
+#
+# Build ApexImporter Windows
+#
+
+SET(APEXIMPORTER_PLATFORM_COMMON_FILES
+)
+
+SET(APEXIMPORTER_PLATFORM_INCLUDES
+)
+
+SET(APEXIMPORTER_COMPILE_DEFS
+ # Common to all configurations
+ ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
+
+ $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
+ $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
+ $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
+ $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
+)
+
diff --git a/tools/compiler/cmake/Windows/AuthoringTool.cmake b/tools/compiler/cmake/Windows/AuthoringTool.cmake
index 3dfc954..d41b6e9 100644..100755
--- a/tools/compiler/cmake/Windows/AuthoringTool.cmake
+++ b/tools/compiler/cmake/Windows/AuthoringTool.cmake
@@ -1,20 +1,22 @@
-#
-# Build AuthoringTool Windows
-#
-
-SET(AUTHORTINGTOOL_PLATFORM_COMMON_FILES
-)
-
-SET(AUTHORTINGTOOL_PLATFORM_INCLUDES
-)
-
-SET(AUTHORTINGTOOL_COMPILE_DEFS
- # Common to all configurations
- ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
-
- $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
- $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
- $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
- $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
-)
-
+#
+# Build AuthoringTool Windows
+#
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244")
+
+SET(AUTHORTINGTOOL_PLATFORM_COMMON_FILES
+)
+
+SET(AUTHORTINGTOOL_PLATFORM_INCLUDES
+)
+
+SET(AUTHORTINGTOOL_COMPILE_DEFS
+ # Common to all configurations
+ ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
+
+ $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
+ $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
+ $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
+ $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
+)
+
diff --git a/tools/compiler/cmake/Windows/CMakeLists.txt b/tools/compiler/cmake/Windows/CMakeLists.txt
index 00c8bbf..17b942e 100644..100755
--- a/tools/compiler/cmake/Windows/CMakeLists.txt
+++ b/tools/compiler/cmake/Windows/CMakeLists.txt
@@ -1,51 +1,51 @@
-#Platform specific compile flags and project includes
-
-SET(CMAKE_CXX_FLAGS "/EHsc /GR- /GF /MP /Gy /d2Zi+ /errorReport:prompt /fp:fast /Gd /Gm- /GS- /nologo /W4 /WX /Zc:forScope /Zc:inline /Zc:wchar_t /Zi")
-
-# Are we using the static or dynamic RT library? Whatever we use, it needs to be the same in any dependencies
-# we pull in or we're potentially having mismatch issues.
-IF(STATIC_WINCRT)
- SET(WINCRT_NDEBUG "/MT")
- SET(WINCRT_DEBUG "/MTd")
-ELSE()
- SET(WINCRT_NDEBUG "/MD")
- SET(WINCRT_DEBUG "/MDd")
-ENDIF()
-
-SET(CMAKE_CXX_FLAGS_DEBUG "/Od /RTCsu ${WINCRT_DEBUG}")
-SET(CMAKE_CXX_FLAGS_CHECKED "/Ox ${WINCRT_NDEBUG}")
-SET(CMAKE_CXX_FLAGS_PROFILE "/Ox ${WINCRT_NDEBUG}")
-SET(CMAKE_CXX_FLAGS_RELEASE "/Ox ${WINCRT_NDEBUG}")
-
-# Build PDBs for all configurations
-SET(CMAKE_SHARED_LINKER_FLAGS "/DEBUG")
-
-IF(CMAKE_CL_64)
- ADD_DEFINITIONS(-DWIN64)
-ENDIF(CMAKE_CL_64)
-
-SET(BLASTTOOLS_SLN_COMPILE_DEFS WIN32;WIN64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;)
-
-SET(BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS _DEBUG;NV_DEBUG=1;)
-SET(BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS NDEBUG;NV_CHECKED=1;)
-SET(BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS NDEBUG;NV_PROFILE=1;)
-SET(BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS NDEBUG;)
-
-IF(CMAKE_CL_64)
- SET(LIBPATH_SUFFIX "x64")
-ELSE(CMAKE_CL_64)
- SET(LIBPATH_SUFFIX "x86")
-ENDIF(CMAKE_CL_64)
-
-SET(CMAKE_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}_${LIBPATH_SUFFIX}")
-SET(CMAKE_PROFILE_POSTFIX "${CMAKE_PROFILE_POSTFIX}_${LIBPATH_SUFFIX}")
-SET(CMAKE_CHECKED_POSTFIX "${CMAKE_CHECKED_POSTFIX}_${LIBPATH_SUFFIX}")
-SET(CMAKE_RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}_${LIBPATH_SUFFIX}")
-
-# Should this be here or in the common part?
-#ADD_SUBDIRECTORY(${BLAST_ROOT_DIR}/sdk "${CMAKE_CURRENT_BINARY_DIR}/blast_bin")
-
-# Include all of the projects
-INCLUDE(${PROJECT_CMAKE_FILES_DIR}/LegacyConverter.cmake)
-INCLUDE(${PROJECT_CMAKE_FILES_DIR}/AuthoringTool.cmake)
-INCLUDE(${PROJECT_CMAKE_FILES_DIR}/ApexImporter.cmake)
+#Platform specific compile flags and project includes
+
+SET(CMAKE_CXX_FLAGS "/EHsc /GR- /GF /MP /Gy /d2Zi+ /errorReport:prompt /fp:fast /Gd /Gm- /GS- /nologo /W4 /WX /Zc:forScope /Zc:inline /Zc:wchar_t /Zi")
+
+# Are we using the static or dynamic RT library? Whatever we use, it needs to be the same in any dependencies
+# we pull in or we're potentially having mismatch issues.
+IF(STATIC_WINCRT)
+ SET(WINCRT_NDEBUG "/MT")
+ SET(WINCRT_DEBUG "/MTd")
+ELSE()
+ SET(WINCRT_NDEBUG "/MD")
+ SET(WINCRT_DEBUG "/MDd")
+ENDIF()
+
+SET(CMAKE_CXX_FLAGS_DEBUG "/Od /RTCsu ${WINCRT_DEBUG}")
+SET(CMAKE_CXX_FLAGS_CHECKED "/Ox ${WINCRT_NDEBUG}")
+SET(CMAKE_CXX_FLAGS_PROFILE "/Ox ${WINCRT_NDEBUG}")
+SET(CMAKE_CXX_FLAGS_RELEASE "/Ox ${WINCRT_NDEBUG}")
+
+# Build PDBs for all configurations
+SET(CMAKE_SHARED_LINKER_FLAGS "/DEBUG")
+
+IF(CMAKE_CL_64)
+ ADD_DEFINITIONS(-DWIN64)
+ENDIF(CMAKE_CL_64)
+
+SET(BLASTTOOLS_SLN_COMPILE_DEFS WIN32;WIN64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;)
+
+SET(BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS _DEBUG;NV_DEBUG=1;)
+SET(BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS NDEBUG;NV_CHECKED=1;)
+SET(BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS NDEBUG;NV_PROFILE=1;)
+SET(BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS NDEBUG;)
+
+IF(CMAKE_CL_64)
+ SET(LIBPATH_SUFFIX "x64")
+ELSE(CMAKE_CL_64)
+ SET(LIBPATH_SUFFIX "x86")
+ENDIF(CMAKE_CL_64)
+
+SET(CMAKE_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}_${LIBPATH_SUFFIX}")
+SET(CMAKE_PROFILE_POSTFIX "${CMAKE_PROFILE_POSTFIX}_${LIBPATH_SUFFIX}")
+SET(CMAKE_CHECKED_POSTFIX "${CMAKE_CHECKED_POSTFIX}_${LIBPATH_SUFFIX}")
+SET(CMAKE_RELEASE_POSTFIX "${CMAKE_RELEASE_POSTFIX}_${LIBPATH_SUFFIX}")
+
+# Should this be here or in the common part?
+#ADD_SUBDIRECTORY(${BLAST_ROOT_DIR}/sdk "${CMAKE_CURRENT_BINARY_DIR}/blast_bin")
+
+# Include all of the projects
+INCLUDE(${PROJECT_CMAKE_FILES_DIR}/LegacyConverter.cmake)
+INCLUDE(${PROJECT_CMAKE_FILES_DIR}/AuthoringTool.cmake)
+INCLUDE(${PROJECT_CMAKE_FILES_DIR}/ApexImporter.cmake)
diff --git a/tools/compiler/cmake/Windows/LegacyConverter.cmake b/tools/compiler/cmake/Windows/LegacyConverter.cmake
index 5653bb9..512753c 100644..100755
--- a/tools/compiler/cmake/Windows/LegacyConverter.cmake
+++ b/tools/compiler/cmake/Windows/LegacyConverter.cmake
@@ -1,20 +1,20 @@
-#
-# Build LegacyConverter Windows
-#
-
-SET(LEGACYCONVERTER_PLATFORM_COMMON_FILES
-)
-
-SET(LEGACYCONVERTER_PLATFORM_INCLUDES
-)
-
-SET(LEGACYCONVERTER_COMPILE_DEFS
- # Common to all configurations
- ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
-
- $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
- $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
- $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
- $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
-)
-
+#
+# Build LegacyConverter Windows
+#
+
+SET(LEGACYCONVERTER_PLATFORM_COMMON_FILES
+)
+
+SET(LEGACYCONVERTER_PLATFORM_INCLUDES
+)
+
+SET(LEGACYCONVERTER_COMPILE_DEFS
+ # Common to all configurations
+ ${BLASTTOOLS_SLN_COMPILE_DEFS};_CONSOLE
+
+ $<$<CONFIG:debug>:${BLASTTOOLS_SLN_DEBUG_COMPILE_DEFS}>
+ $<$<CONFIG:checked>:${BLASTTOOLS_SLN_CHECKED_COMPILE_DEFS}>
+ $<$<CONFIG:profile>:${BLASTTOOLS_SLN_PROFILE_COMPILE_DEFS}>
+ $<$<CONFIG:release>:${BLASTTOOLS_SLN_RELEASE_COMPILE_DEFS}>
+)
+