NvBlastExtExporterObjReader.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2020 NVIDIA Corporation. All rights reserved.
27 
28 
29 #ifndef NVBLASTEXTEXPORTEROBJREADER_H
30 #define NVBLASTEXTEXPORTEROBJREADER_H
31 #include <memory>
32 #include <string>
33 #include <vector>
34 #include "NvBlastExtExporter.h"
35 
36 namespace Nv
37 {
38 namespace Blast
39 {
40 class Mesh;
41 
43 {
44 public:
45  ObjFileReader();
46  ~ObjFileReader() = default;
47 
48  virtual void release() override;
49 
50  /*
51  Load from the specified file path, returning a mesh or nullptr if failed
52  */
53  virtual void loadFromFile(const char* filename) override;
54 
55  virtual uint32_t getVerticesCount() const override
56  {
57  return mVertexPositions.size();
58  }
59 
60  virtual uint32_t getIndicesCount() const override
61  {
62  return mIndices.size();
63  }
64 
68  virtual bool isCollisionLoaded() override;
69 
73  virtual uint32_t getCollision(uint32_t*& hullsOffset, Nv::Blast::CollisionHull**& hulls) override;
74 
78  virtual NvcVec3* getPositionArray() override;
82  virtual NvcVec3* getNormalsArray() override;
86  virtual NvcVec2* getUvArray() override;
90  virtual uint32_t* getIndexArray() override;
91 
95  int32_t* getMaterialIds() override { return mPerFaceMatId.data(); };
96 
100  int32_t* getSmoothingGroups() override { return nullptr; };
101 
105  const char* getMaterialName(int32_t id) override { return mMaterialNames[id].c_str(); }
106 
110  int32_t getMaterialCount() { return mMaterialNames.size(); };
111 
112 private:
113  std::vector<NvcVec3> mVertexPositions;
114  std::vector<NvcVec3> mVertexNormals;
115  std::vector<NvcVec2> mVertexUv;
116  std::vector<uint32_t> mIndices;
117 
118  std::vector<std::string> mMaterialNames;
119  std::vector<int32_t> mPerFaceMatId;
120 
121 };
122 
123 }
124 }
125 
126 #endif // NVBLASTEXTEXPORTEROBJREADER_H
virtual NvcVec3 * getNormalsArray() override
virtual uint32_t * getIndexArray() override
const char * getMaterialName(int32_t id) override
Definition: NvBlastExtExporterObjReader.h:105
virtual bool isCollisionLoaded() override
virtual NvcVec3 * getPositionArray() override
Definition: NvCTypes.h:43
virtual void loadFromFile(const char *filename) override
virtual void release() override
virtual uint32_t getCollision(uint32_t *&hullsOffset, Nv::Blast::CollisionHull **&hulls) override
Definition: NvBlastExtExporterObjReader.h:42
virtual uint32_t getIndicesCount() const override
Definition: NvBlastExtExporterObjReader.h:60
Definition: NvBlastExtAuthoringTypes.h:133
virtual NvcVec2 * getUvArray() override
int32_t * getMaterialIds() override
Definition: NvBlastExtExporterObjReader.h:95
int32_t getMaterialCount()
Definition: NvBlastExtExporterObjReader.h:110
int32_t * getSmoothingGroups() override
Definition: NvBlastExtExporterObjReader.h:100
virtual uint32_t getVerticesCount() const override
Definition: NvBlastExtExporterObjReader.h:55
Definition: NvBlastArray.h:37
Definition: NvCTypes.h:49
Definition: NvBlastExtExporter.h:100