12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- // Simple Obj Loader from https://www.dkscript.com/wiki/SampleCodes/ObjLoader
- // but using tinyObjLoader for MTL convenience
-
- #pragma once
-
- #include <DK.h>
-
- class ObjImportUtil
- {
- public:
- struct ObjVertex
- {
- DKVector3 inPos;
- DKVector3 inColor;
- DKVector3 inNormal;
- DKVector2 inTexCoord;
-
- int Compare(const ObjVertex& Other) const;
-
- inline bool operator > (const ObjVertex& Other) const
- {
- return Compare(Other) > 0;
- }
-
- inline bool operator < (const ObjVertex& Other) const
- {
- return Compare(Other) < 0;
- }
- };
-
- struct ObjImportedMeshData
- {
- DKArray<ObjVertex> vertices;
- DKArray<uint32_t> indices;
- DKAabb aabb;
- uint32_t vertexSize;
- };
-
- static ObjImportedMeshData LoadFromObjFile(
- const DKString& inPath
- , DKResourcePool& inDKResourcePool);
- };
|