axmol/cocos/3d/CCBundle3D.h

107 lines
3.0 KiB
C
Raw Normal View History

2014-06-05 16:36:01 +08:00
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCBUNDLE3D_H__
#define __CCBUNDLE3D_H__
#include <map>
2014-06-17 10:49:52 +08:00
#include "3d/CCBundle3DData.h"
2014-06-17 15:28:14 +08:00
2014-06-05 16:36:01 +08:00
#include "base/ccMacros.h"
#include "base/CCRef.h"
#include "base/ccTypes.h"
2014-06-17 21:16:32 +08:00
#include "json/document.h"
2014-06-12 10:01:54 +08:00
2014-06-05 16:36:01 +08:00
NS_CC_BEGIN
class Animation3D;
class Bundle3D
{
public:
static Bundle3D* getInstance();
static void purgeBundle3D();
bool load(const std::string& path);
//
/**
* load mesh data from bundle
2014-06-05 16:47:03 +08:00
* @param id The ID of the mesh, load the first Mesh in the bundle if it is empty
2014-06-05 16:36:01 +08:00
*/
bool loadMeshData(const std::string& id, MeshData* meshdata);
//
/**
* load skin data from bundle
2014-06-05 16:47:03 +08:00
* @param id The ID of the skin, load the first Skin in the bundle if it is empty
2014-06-05 16:36:01 +08:00
*/
bool loadSkinData(const std::string& id, SkinData* skindata);
//
/**
* load material data from bundle
2014-06-05 16:47:03 +08:00
* @param id The ID of the material, load the first Material in the bundle if it is empty
2014-06-05 16:36:01 +08:00
*/
bool loadMaterialData(const std::string& id, MaterialData* materialdata);
/**
* load material data from bundle
2014-06-05 16:47:03 +08:00
* @param id The ID of the animation, load the first animation in the bundle if it is empty
2014-06-05 16:36:01 +08:00
*/
bool loadAnimationData(const std::string& id, Animation3DData* animationdata);
2014-06-12 10:01:54 +08:00
protected:
GLenum parseGLType(const std::string& str);
unsigned int parseGLTypeSize(const std::string& str);
2014-06-12 10:01:54 +08:00
unsigned int parseGLProgramAttribute(const std::string& str);
2014-06-12 10:01:54 +08:00
2014-06-16 19:08:43 +08:00
// get model path
void getModelPath(const std::string& path);
2014-06-05 16:36:01 +08:00
protected:
Bundle3D();
~Bundle3D();
static Bundle3D* _instance;
2014-06-16 19:08:43 +08:00
std::string _modelRelativePath;
2014-06-12 10:01:54 +08:00
char* _documentBuffer;
2014-06-17 13:59:03 +08:00
std::string _path;
2014-06-16 19:08:43 +08:00
rapidjson::Document _document;
2014-06-12 10:01:54 +08:00
2014-06-05 16:36:01 +08:00
bool _isBinary;
};
NS_CC_END
#endif // __CCANIMATE3D_H__