sdk/extensions/import/include/NvBlastExtApexImportTool.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 #ifndef NVBLASTEXTAPEXIMPORTTOOL_H
00030 #define NVBLASTEXTAPEXIMPORTTOOL_H
00031 
00032 #include "NvBlast.h"
00033 #include <vector>
00034 #include <string>
00035 #include "NvBlastExtPxAsset.h"
00036 #include <nvparameterized\NvSerializer.h>
00037 #include <NvBlastExtExporter.h>
00038 
00039 namespace physx
00040 {
00041     class PxFoundation;
00042     class PxPhysics;
00043     class PxCooking;
00044 
00045 namespace general_PxIOStream2
00046 {
00047 class PxFileBuf;
00048 }
00049 }
00050 
00051 namespace NvParameterized
00052 {
00053     class Interface;
00054 }
00055 
00056 namespace nvidia
00057 {
00058 namespace apex
00059 {
00060 class ApexSDK;
00061 class ModuleDestructible;
00062 class DestructibleAsset;
00063 }
00064 using namespace physx::general_PxIOStream2;
00065 }
00066 
00067 
00068 namespace Nv
00069 {
00070 namespace Blast
00071 {
00072 
00073 struct CollisionHull;
00074 class TkFramework;
00075 
00076 namespace ApexImporter
00077 {
00078 
00079 struct ApexImporterConfig
00080 {
00090     enum InterfaceSearchMode { EXACT, FORCED, MODE_COUNT };
00091 
00092     ApexImporterConfig()
00093     {
00094         setDefaults();
00095     }
00096 
00097     void setDefaults()
00098     {
00099         infSearchMode               =   EXACT;
00100     }
00101     InterfaceSearchMode infSearchMode;
00102 };
00103 
00104 
00105 class ApexDestruction;
00106 
00107 
00111 class ApexImportTool
00112 {
00113 public:
00114     ApexImportTool();
00115     ~ApexImportTool();
00116     
00122     bool    loadAssetFromFile(nvidia::PxFileBuf* stream, NvParameterized::Serializer::DeserializedData& data);
00123 
00124 
00135     bool                                importApexAsset(std::vector<uint32_t>& chunkReorderInvMap, NvParameterized::Interface* assetNvIfc,
00136                                             std::vector<NvBlastChunkDesc>& chunkDescriptors, std::vector<NvBlastBondDesc>& bondDescriptors, std::vector<uint32_t>& flags);
00137 
00149     bool                                importApexAsset(std::vector<uint32_t>& chunkReorderInvMap, NvParameterized::Interface* assetNvIfc,
00150                                             std::vector<NvBlastChunkDesc>& chunkDescriptors, std::vector<NvBlastBondDesc>& bondDescriptors, std::vector<uint32_t>& flags,
00151                                             const ApexImporterConfig& config);
00152 
00156     bool                                importRendermesh(const std::vector<uint32_t>& chunkReorderInvMap, const NvParameterized::Interface* assetNvIfc, Nv::Blast::ExporterMeshData* outputData, const char* materialsDir);
00157 
00158 
00165     bool                                saveAsset(const NvBlastAsset* asset, nvidia::PxFileBuf* stream);
00166 
00178     bool                                getCollisionGeometry(const NvParameterized::Interface* assetPrm, uint32_t chunkCount, std::vector<uint32_t>& chunkReorderInvMap,
00179                                                 const std::vector<uint32_t>& apexChunkFlags, std::vector<ExtPxAssetDesc::ChunkDesc>& physicsChunks,
00180                                                 std::vector<ExtPxAssetDesc::SubchunkDesc>& physicsSubchunks, std::vector<std::vector<CollisionHull*> >& hullsDesc);
00181 
00183 
00184     bool isValid();
00185 
00186     physx::PxPhysics*       getPxSdk() { return m_PhysxSDK; }
00187     physx::PxCooking*       getCooking() { return m_Cooking; };
00188 
00189 private:
00190     bool                                importApexAssetInternal(std::vector<uint32_t>& chunkReorderInvMap, NvParameterized::Interface* assetNvIfc,
00191                                             std::vector<NvBlastChunkDesc>& chunkDescriptors, std::vector<NvBlastBondDesc>& bondDesc, std::vector<uint32_t>& flags,
00192                                             const ApexImporterConfig& configDesc);
00193 
00194 protected:
00195     ApexImportTool(const ApexImportTool&);
00196     ApexImportTool& operator=(const ApexImportTool&);
00197 
00198     physx::PxFoundation*    m_Foundation;
00199     physx::PxPhysics*       m_PhysxSDK;
00200     physx::PxCooking*       m_Cooking;
00201 
00202 };
00203 
00204 } // namespace ApexImporter
00205 
00206 } // namespace Blast
00207 } // namespace Nv
00208 
00209 #endif // NVBLASTEXTAPEXIMPORTTOOL_H