Main Page Class List Class Members

- Main Page
- User's Guide
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# sdk/extensions/exporter/source/NvBlastExtExporterFbxReader.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) 2020 NVIDIA Corporation. All rights reserved.
    00027
    00028
    00029 #ifndef NVBLASTEXTEXPORTERFBXREADER_H
    00030 #define NVBLASTEXTEXPORTERFBXREADER_H
    00031
    00032 #include <memory>
    00033 #include "fbxsdk.h"
    00034 #include <vector>
    00035 #include <map>
    00036 #include "NvBlastExtExporter.h"
    00037 #include "NvBlastExtAuthoringTypes.h"
    00038
    00039 namespace Nv
    00040 {
    00041 namespace Blast
    00042 {
    00043 class Mesh;
    00044
    00045 class FbxFileReader : public IFbxFileReader
    00046 {
    00047     struct CollisionHullImpl : public Nv::Blast::CollisionHull
    00048     {
    00049         //copy from existing
    00050         CollisionHullImpl(const CollisionHullImpl& other) : CollisionHullImpl()
    00051         {
    00052             copyFrom(other);
    00053         }
    00054
    00055         CollisionHullImpl()
    00056         {
    00057             pointsCount = 0;
    00058             indicesCount = 0;
    00059             polygonDataCount = 0;
    00060             points = nullptr;
    00061             indices = nullptr;
    00062             polygonData = nullptr;
    00063         }
    00064
    00065         CollisionHullImpl(CollisionHullImpl&& other)
    00066         {
    00067             operator=(std::move(other));
    00068         }
    00069
    00070         CollisionHullImpl& operator=(const CollisionHullImpl& other)
    00071         {
    00072             if (&other != this)
    00073             {
    00074                 delete[] points;
    00075                 delete[] indices;
    00076                 delete[] polygonData;
    00077                 copyFrom(other);
    00078             }
    00079             return *this;
    00080         }
    00081
    00082         CollisionHullImpl& operator=(CollisionHullImpl&& other)
    00083         {
    00084             if (&other != this)
    00085             {
    00086                 pointsCount = other.pointsCount;
    00087                 indicesCount = other.indicesCount;
    00088                 polygonDataCount = other.polygonDataCount;
    00089                 points = other.points;
    00090                 indices = other.indices;
    00091                 polygonData = other.polygonData;
    00092
    00093                 other.pointsCount = 0;
    00094                 other.indicesCount = 0;
    00095                 other.polygonDataCount = 0;
    00096                 other.points = nullptr;
    00097                 other.indices = nullptr;
    00098                 other.polygonData = nullptr;
    00099             }
    00100             return *this;
    00101         }
    00102
    00103         virtual ~CollisionHullImpl()
    00104         {
    00105             delete[] points;
    00106             delete[] indices;
    00107             delete[] polygonData;
    00108         }
    00109     private:
    00110
    00111         void copyFrom(const CollisionHullImpl& other)
    00112         {
    00113             pointsCount = other.pointsCount;
    00114             indicesCount = other.indicesCount;
    00115             polygonDataCount = other.polygonDataCount;
    00116             points = new NvcVec3[pointsCount];
    00117             indices = new uint32_t[indicesCount];
    00118             polygonData = new Nv::Blast::HullPolygon[polygonDataCount];
    00119             memcpy(points, other.points, sizeof(points[0]) * pointsCount);
    00120             memcpy(indices, other.indices, sizeof(indices[0]) * indicesCount);
    00121             memcpy(polygonData, other.polygonData, sizeof(polygonData[0]) * polygonDataCount);
    00122         }
    00123     };
    00124
    00125 public:
    00126     FbxFileReader();
    00127     ~FbxFileReader() = default;
    00128
    00129     virtual void release() override;
    00130
    00131     /*
    00132     Load from the specified file path, returning a mesh or nullptr if failed
    00133     */
    00134     virtual void loadFromFile(const char* filename) override;
    00135
    00136     virtual uint32_t getVerticesCount() const override
    00137     {
    00138         return mVertexPositions.size();
    00139     }
    00140
    00141     virtual uint32_t getIndicesCount() const override
    00142     {
    00143         return mIndices.size();
    00144     }
    00145
    00149     virtual bool isCollisionLoaded() override;
    00150
    00154     virtual uint32_t getCollision(uint32_t*& hullsOffset, Nv::Blast::CollisionHull**& hulls) override;
    00155
    00156     virtual uint32_t getBoneInfluences(uint32_t*& out) override;
    00157
    00158     virtual uint32_t getBoneCount() override;
    00159
    00163     virtual NvcVec3* getPositionArray() override;
    00167     virtual NvcVec3* getNormalsArray() override;
    00171     virtual NvcVec2* getUvArray() override;
    00175     virtual uint32_t* getIndexArray() override;
    00176
    00180     int32_t*        getMaterialIds() override;
    00181
    00185     int32_t*        getSmoothingGroups() override;
    00186
    00190     const char*     getMaterialName(int32_t id) override;
    00191
    00192
    00193     int32_t         getMaterialCount() override;
    00194
    00195 private:
    00196
    00197     uint32_t mMeshCount;
    00198     uint32_t mChunkCount;
    00199     std::vector<uint32_t> mHullsOffset;
    00200     std::vector<CollisionHullImpl> mHulls;
    00201     std::vector<uint32_t> mVertexToContainingChunkMap;
    00202     std::multimap<uint32_t, FbxNode*> mCollisionNodes;
    00203     std::vector<NvcVec3> mVertexPositions;
    00204     std::vector<NvcVec3> mVertexNormals;
    00205     std::vector<NvcVec2> mVertexUv;
    00206     std::vector<uint32_t> mIndices;
    00207     std::vector<int32_t> mSmoothingGroups;
    00208     std::vector<int32_t> mMaterialIds;
    00209     std::vector<std::string> mMaterialNames;
    00210
    00211     FbxAMatrix getTransformForNode(FbxNode* node);
    00212     void getFbxMeshes(FbxDisplayLayer* collisionDisplayLayer, FbxNode* node, std::vector<FbxNode*>& meshNodes);
    00213     bool getCollisionInternal();
    00214     bool getBoneInfluencesInternal(FbxMesh* meshNode);
    00215
    00216 };
    00217
    00218 }
    00219 }
    00220
    00221 #endif

Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com