// // VROOBJLoader.h // ViroRenderer // // Created by Raj Advani on 12/13/16. // Copyright © 2016 Viro Media. All rights reserved. // #ifndef VROOBJLoader_h #define VROOBJLoader_h #include #include #include #include #include #include #include "VROGeometrySource.h" #include "VROGeometryElement.h" #include "tiny_obj_loader.h" class VRONode; class VROTexture; class VROGeometry; enum class VROResourceType; class VROOBJLoader { public: /* Load the OBJ file at the given resource. For all dependent resources (e.g. textures) found, locate them in the parent folder of the resource. If async is true, an empty node is immediately returned while the OBJ is loaded in the background. Afterward, the geometry is injected into the node on the main (rendering) thread, and the given callback is invoked. If async is false, the callback is still executed. */ static void loadOBJFromResource(std::string resource, VROResourceType type, std::shared_ptr destination, bool async = false, std::function node, bool success)> onFinish = nullptr); static void loadOBJFromResources(std::string resource, VROResourceType type, std::shared_ptr destination, std::map resourceMap, bool async = false, std::function node, bool success)> onFinish = nullptr); private: static void injectOBJ(std::shared_ptr geometry, std::shared_ptr node, std::function node, bool success)> onFinish); static std::shared_ptr loadOBJ(std::string file, std::string base, VROResourceType type); static std::shared_ptr loadOBJ(std::string file, std::map resourceMap); static std::shared_ptr processOBJ(tinyobj::attrib_t attrib, std::vector &shapes, std::vector &materials, std::string base, VROResourceType type, std::map *resourceMap = nullptr); }; #endif /* VROOBJLoader_h */