123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- #ifndef __CCBUNDLE3D_H__
- #define __CCBUNDLE3D_H__
- #include "base/CCData.h"
- #include "3d/CCBundle3DData.h"
- #include "3d/CCBundleReader.h"
- #include "json/document-wrapper.h"
- NS_CC_BEGIN
- class Animation3D;
- class CC_DLL Bundle3D
- {
- public:
-
- static Bundle3D* createBundle();
-
- static void destroyBundle(Bundle3D* bundle);
-
- virtual void clear();
-
- virtual bool load(const std::string& path);
-
-
- virtual bool loadSkinData(const std::string& id, SkinData* skindata);
-
-
- virtual bool loadAnimationData(const std::string& id, Animation3DData* animationdata);
-
-
- virtual bool loadMeshDatas(MeshDatas& meshdatas);
-
- virtual bool loadNodes(NodeDatas& nodedatas);
-
- virtual bool loadMaterials(MaterialDatas& materialdatas);
-
-
- static std::vector<Vec3> getTrianglesList(const std::string& path);
-
-
- static bool loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeDatas& nodedatas, const std::string& fullPath, const char* mtl_basepath = nullptr);
-
-
- static AABB calculateAABB(const std::vector<float>& vertex, int stride, const std::vector<unsigned short>& index);
-
- protected:
- bool loadJson(const std::string& path);
- bool loadBinary(const std::string& path);
- bool loadMeshDatasJson(MeshDatas& meshdatas);
- bool loadMeshDataJson_0_1(MeshDatas& meshdatas);
- bool loadMeshDataJson_0_2(MeshDatas& meshdatas);
- bool loadMeshDatasBinary(MeshDatas& meshdatas);
- bool loadMeshDatasBinary_0_1(MeshDatas& meshdatas);
- bool loadMeshDatasBinary_0_2(MeshDatas& meshdatas);
- bool loadMaterialsJson(MaterialDatas& materialdatas);
- bool loadMaterialDataJson_0_1(MaterialDatas& materialdatas);
- bool loadMaterialDataJson_0_2(MaterialDatas& materialdatas);
- bool loadMaterialsBinary(MaterialDatas& materialdatas);
- bool loadMaterialsBinary_0_1(MaterialDatas& materialdatas);
- bool loadMaterialsBinary_0_2(MaterialDatas& materialdatas);
- bool loadMeshDataJson(MeshData* meshdata);
- bool loadMeshDataJson_0_1(MeshData* meshdata);
- bool loadMeshDataJson_0_2(MeshData* meshdata);
- bool loadSkinDataJson(SkinData* skindata);
- bool loadSkinDataBinary(SkinData* skindata);
- bool loadMaterialDataJson(MaterialData* materialdata);
- bool loadMaterialDataJson_0_1(MaterialData* materialdata);
- bool loadMaterialDataJson_0_2(MaterialData* materialdata);
- bool loadAnimationDataJson(const std::string& id,Animation3DData* animationdata);
- bool loadAnimationDataBinary(const std::string& id,Animation3DData* animationdata);
-
- bool loadNodesJson(NodeDatas& nodedatas);
- NodeData* parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bool singleSprite);
-
- bool loadNodesBinary(NodeDatas& nodedatas);
- NodeData* parseNodesRecursivelyBinary(bool& skeleton, bool singleSprite);
-
- GLenum parseGLType(const std::string& str);
-
- NTextureData::Usage parseGLTextureType(const std::string& str);
-
- unsigned int parseGLProgramAttribute(const std::string& str);
-
- void getModelRelativePath(const std::string& path);
-
- Reference* seekToFirstType(unsigned int type, const std::string& id = "");
- CC_CONSTRUCTOR_ACCESS:
- Bundle3D();
- virtual ~Bundle3D();
-
- protected:
- std::string _modelPath;
- std::string _path;
- std::string _version;
-
-
- std::string _jsonBuffer;
- rapidjson::Document _jsonReader;
-
- Data _binaryBuffer;
- BundleReader _binaryReader;
- unsigned int _referenceCount;
- Reference* _references;
- bool _isBinary;
- };
- NS_CC_END
- #endif
|