From 8664111e4a20008c0aea173ae527d0828022fdd6 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 21 Oct 2014 17:19:50 +0800 Subject: [PATCH 1/7] modify camera attach bug! --- cocos/3d/CCAttachNode.cpp | 7 +++++++ cocos/3d/CCAttachNode.h | 1 + 2 files changed, 8 insertions(+) diff --git a/cocos/3d/CCAttachNode.cpp b/cocos/3d/CCAttachNode.cpp index ee53d03d9d..2f973a8f43 100644 --- a/cocos/3d/CCAttachNode.cpp +++ b/cocos/3d/CCAttachNode.cpp @@ -62,6 +62,13 @@ Mat4 AttachNode::getWorldToNodeTransform() const return mat; } +const Mat4& AttachNode::getNodeToParentTransform() const +{ + static Mat4 mat; + mat = _attachBone->getWorldMat() * Node::getNodeToParentTransform(); + return mat; +} + void AttachNode::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) { Node::visit(renderer, parentTransform * _attachBone->getWorldMat(), Node::FLAGS_DIRTY_MASK); diff --git a/cocos/3d/CCAttachNode.h b/cocos/3d/CCAttachNode.h index f312b6cc7c..7c14d1017c 100644 --- a/cocos/3d/CCAttachNode.h +++ b/cocos/3d/CCAttachNode.h @@ -49,6 +49,7 @@ public: static AttachNode* create(Bone3D* attachBone); virtual Mat4 getWorldToNodeTransform() const override; + virtual const Mat4& getNodeToParentTransform() const override; virtual void visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) override; CC_CONSTRUCTOR_ACCESS: From 622df56614a62b7f414199f1ea8e8e1d6e5b8472 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 21 Oct 2014 17:22:42 +0800 Subject: [PATCH 2/7] fix OBB intersects bug --- cocos/3d/CCOBB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/3d/CCOBB.cpp b/cocos/3d/CCOBB.cpp index a9e3235c31..582898657b 100755 --- a/cocos/3d/CCOBB.cpp +++ b/cocos/3d/CCOBB.cpp @@ -414,7 +414,7 @@ bool OBB::intersects(const OBB& box) const for (int j = 0; j < 3; j++) { Vec3 axis; - Vec3::cross(getFaceDirection(i), box.getFaceDirection(j), &axis); + Vec3::cross(getEdgeDirection(i), box.getEdgeDirection(j), &axis); getInterval(*this, axis, min1, max1); getInterval(box, axis, min2, max2); if (max1 < min2 || max2 < min1) return false; From 63a47534ab5eb34a522a988d259f04b52ed70504 Mon Sep 17 00:00:00 2001 From: lvlong Date: Tue, 21 Oct 2014 18:44:10 +0800 Subject: [PATCH 3/7] fix 0.2 version load bug. --- cocos/3d/CCBundle3D.cpp | 566 ++++++++++++---------------------------- cocos/3d/CCBundle3D.h | 51 +--- 2 files changed, 175 insertions(+), 442 deletions(-) diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index a80eb35819..a564b71282 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -306,20 +306,6 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD return false; } -bool Bundle3D::loadMeshData(const std::string& id, MeshData* meshdata) -{ - meshdata->resetData(); - - if (_isBinary) - { - return loadMeshDataBinary(meshdata); - } - else - { - return loadMeshDataJson(meshdata); - } -} - bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata) { skindata->resetData(); @@ -334,20 +320,6 @@ bool Bundle3D::loadSkinData(const std::string& id, SkinData* skindata) } } -bool Bundle3D::loadMaterialData(const std::string& id, MaterialData* materialdata) -{ - materialdata->resetData(); - - if (_isBinary) - { - return loadMaterialDataBinary(materialdata); - } - else - { - return loadMaterialDataJson(materialdata); - } -} - bool Bundle3D::loadAnimationData(const std::string& id, Animation3DData* animationdata) { animationdata->resetData(); @@ -368,14 +340,10 @@ bool Bundle3D::loadMeshDatas(MeshDatas& meshdatas) meshdatas.resetData(); if (_isBinary) { - if (_version == "0.1") + if (_version == "0.1" || _version == "0.2") { return loadMeshDatasBinary_0_1(meshdatas); } - else if(_version == "0.2") - { - return loadMeshDatasBinary_0_2(meshdatas); - } else { return loadMeshDatasBinary(meshdatas); @@ -383,14 +351,10 @@ bool Bundle3D::loadMeshDatas(MeshDatas& meshdatas) } else { - if (_version == "1.2") + if (_version == "1.2" || _version == "0.2") { return loadMeshDataJson_0_1(meshdatas); } - else if(_version == "0.2") - { - return loadMeshDataJson_0_2(meshdatas); - } else { return loadMeshDatasJson(meshdatas); @@ -937,7 +901,7 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas) if (texturePath.empty()) { CCLOG("warning: Failed to read Materialdata: texturePath is empty '%s'.", _path.c_str()); - return false; + return true; } NTextureData textureData; @@ -1005,6 +969,73 @@ bool Bundle3D::loadJson(const std::string& path) return true; } + +bool Bundle3D::loadBinary(const std::string& path) +{ + clear(); + + // get file data + CC_SAFE_DELETE(_binaryBuffer); + _binaryBuffer = new (std::nothrow) Data(); + *_binaryBuffer = FileUtils::getInstance()->getDataFromFile(path); + if (_binaryBuffer->isNull()) + { + clear(); + CCLOG("warning: Failed to read file: %s", path.c_str()); + return false; + } + + // Initialise bundle reader + _binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() ); + + // Read identifier info + char identifier[] = { 'C', '3', 'B', '\0'}; + char sig[4]; + if (_binaryReader.read(sig, 1, 4) != 4 || memcmp(sig, identifier, 4) != 0) + { + clear(); + CCLOG("warning: Invalid identifier: %s", path.c_str()); + return false; + } + + // Read version + unsigned char ver[2]; + if (_binaryReader.read(ver, 1, 2)!= 2){ + CCLOG("warning: Failed to read version:"); + return false; + } + + char version[20] = {0}; + sprintf(version, "%d.%d", ver[0], ver[1]); + _version = version; + + // Read ref table size + if (_binaryReader.read(&_referenceCount, 4, 1) != 1) + { + clear(); + CCLOG("warning: Failed to read ref table size '%s'.", path.c_str()); + return false; + } + + // Read all refs + CC_SAFE_DELETE_ARRAY(_references); + _references = new (std::nothrow) Reference[_referenceCount]; + for (ssize_t i = 0; i < _referenceCount; ++i) + { + if ((_references[i].id = _binaryReader.readString()).empty() || + _binaryReader.read(&_references[i].type, 4, 1) != 1 || + _binaryReader.read(&_references[i].offset, 4, 1) != 1) + { + clear(); + CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str()); + CC_SAFE_DELETE_ARRAY(_references); + return false; + } + } + + return true; +} + bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas) { const rapidjson::Value& mesh_data_array = _jsonReader[MESH]; @@ -1145,6 +1176,108 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata) return true; } + +bool Bundle3D::loadSkinDataBinary(SkinData* skindata) +{ + if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN)) + return false; + + std::string boneName = _binaryReader.readString(); + + // transform + float bindShape[16]; + if (!_binaryReader.readMatrix(bindShape)) + { + CCLOG("warning: Failed to read SkinData: bindShape matrix '%s'.", _path.c_str()); + return false; + } + + // bone count + unsigned int boneNum; + if (!_binaryReader.read(&boneNum)) + { + CCLOG("warning: Failed to read SkinData: boneNum '%s'.", _path.c_str()); + return false; + } + + // bone names and bind pos + float bindpos[16]; + for (unsigned int i = 0; i < boneNum; i++) + { + std::string skinBoneName = _binaryReader.readString(); + skindata->skinBoneNames.push_back(skinBoneName); + if (!_binaryReader.readMatrix(bindpos)) + { + CCLOG("warning: Failed to load SkinData: bindpos '%s'.", _path.c_str()); + return false; + } + skindata->inverseBindPoseMatrices.push_back(bindpos); + } + + skindata->skinBoneOriginMatrices.resize(boneNum); + + boneName = _binaryReader.readString(); + + // bind shape + _binaryReader.readMatrix(bindShape); + int rootIndex = skindata->getSkinBoneNameIndex(boneName); + if(rootIndex < 0) + { + skindata->addNodeBoneNames(boneName); + rootIndex = skindata->getBoneNameIndex(boneName); + skindata->nodeBoneOriginMatrices.push_back(bindShape); + } + else + { + skindata->skinBoneOriginMatrices[rootIndex] = bindShape; + } + + // set root bone index + skindata->rootBoneIndex = rootIndex; + + // read parent and child relationship map + float transform[16]; + unsigned int linkNum; + _binaryReader.read(&linkNum); + for (unsigned int i = 0; i < linkNum; ++i) + { + std::string id = _binaryReader.readString(); + int index = skindata->getSkinBoneNameIndex(id); + + + std::string parentid = _binaryReader.readString(); + + if (!_binaryReader.readMatrix(transform)) + { + CCLOG("warning: Failed to load SkinData: transform '%s'.", _path.c_str()); + return false; + } + + if(index < 0) + { + skindata->addNodeBoneNames(id); + index = skindata->getBoneNameIndex(id); + skindata->nodeBoneOriginMatrices.push_back(transform); + } + else + { + skindata->skinBoneOriginMatrices[index] = transform; + } + + int parentIndex = skindata->getSkinBoneNameIndex(parentid); + if(parentIndex < 0) + { + skindata->addNodeBoneNames(parentid); + parentIndex = skindata->getBoneNameIndex(parentid); + } + + skindata->boneChild[parentIndex].push_back(index); + + } + + return true; +} + bool Bundle3D::loadMaterialDataJson_0_1(MaterialDatas& materialdatas) { if (!_jsonReader.HasMember(MATERIAL)) @@ -1269,361 +1402,6 @@ bool Bundle3D::loadAnimationDataJson(const std::string& id, Animation3DData* ani return true; } -bool Bundle3D::loadBinary(const std::string& path) -{ - clear(); - - // get file data - CC_SAFE_DELETE(_binaryBuffer); - _binaryBuffer = new (std::nothrow) Data(); - *_binaryBuffer = FileUtils::getInstance()->getDataFromFile(path); - if (_binaryBuffer->isNull()) - { - clear(); - CCLOG("warning: Failed to read file: %s", path.c_str()); - return false; - } - - // Initialise bundle reader - _binaryReader.init( (char*)_binaryBuffer->getBytes(), _binaryBuffer->getSize() ); - - // Read identifier info - char identifier[] = { 'C', '3', 'B', '\0'}; - char sig[4]; - if (_binaryReader.read(sig, 1, 4) != 4 || memcmp(sig, identifier, 4) != 0) - { - clear(); - CCLOG("warning: Invalid identifier: %s", path.c_str()); - return false; - } - - // Read version - unsigned char ver[2]; - if (_binaryReader.read(ver, 1, 2)!= 2){ - CCLOG("warning: Failed to read version:"); - return false; - } - - char version[20] = {0}; - sprintf(version, "%d.%d", ver[0], ver[1]); - _version = version; - - // Read ref table size - if (_binaryReader.read(&_referenceCount, 4, 1) != 1) - { - clear(); - CCLOG("warning: Failed to read ref table size '%s'.", path.c_str()); - return false; - } - - // Read all refs - CC_SAFE_DELETE_ARRAY(_references); - _references = new (std::nothrow) Reference[_referenceCount]; - for (ssize_t i = 0; i < _referenceCount; ++i) - { - if ((_references[i].id = _binaryReader.readString()).empty() || - _binaryReader.read(&_references[i].type, 4, 1) != 1 || - _binaryReader.read(&_references[i].offset, 4, 1) != 1) - { - clear(); - CCLOG("warning: Failed to read ref number %d for bundle '%s'.", (int)i, path.c_str()); - CC_SAFE_DELETE_ARRAY(_references); - return false; - } - } - - return true; -} - -bool Bundle3D::loadMeshDataBinary(MeshData* meshdata) -{ - if (_version == "0.1") - { - return loadMeshDataBinary_0_1(meshdata); - } - else if(_version == "0.2") - { - return loadMeshDataBinary_0_2(meshdata); - } - else - { - CCLOG("warning: Unsupported version of loadMeshDataBinary() : %s", _version.c_str()); - return false; - } -} - -bool Bundle3D::loadMeshDataBinary_0_1(MeshData* meshdata) -{ - if (!seekToFirstType(BUNDLE_TYPE_MESH)) - return false; - - // read mesh data - if (_binaryReader.read(&meshdata->attribCount, 4, 1) != 1 || meshdata->attribCount < 1) - { - CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str()); - return false; - } - - meshdata->attribs.resize(meshdata->attribCount); - for (ssize_t i = 0; i < meshdata->attribCount; i++) - { - unsigned int vUsage, vSize; - if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1) - { - CCLOG("warning: Failed to read meshdata: usage or size '%s'.", _path.c_str()); - return false; - } - - meshdata->attribs[i].size = vSize; - meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4; - meshdata->attribs[i].type = GL_FLOAT; - meshdata->attribs[i].vertexAttrib = vUsage; - } - - // Read vertex data - if (_binaryReader.read(&meshdata->vertexSizeInFloat, 4, 1) != 1 || meshdata->vertexSizeInFloat == 0) - { - CCLOG("warning: Failed to read meshdata: vertexSizeInFloat '%s'.", _path.c_str()); - return false; - } - - meshdata->vertex.resize(meshdata->vertexSizeInFloat); - if (_binaryReader.read(&meshdata->vertex[0], 4, meshdata->vertexSizeInFloat) != meshdata->vertexSizeInFloat) - { - CCLOG("warning: Failed to read meshdata: vertex element '%s'.", _path.c_str()); - return false; - } - - // Read index data - unsigned int meshPartCount = 1; - //_binaryReader.read(&meshPartCount, 4, 1); - - for (unsigned int i = 0; i < meshPartCount; ++i) - { - unsigned int nIndexCount; - if (_binaryReader.read(&nIndexCount, 4, 1) != 1) - { - CCLOG("warning: Failed to read meshdata: nIndexCount '%s'.", _path.c_str()); - return false; - } - - std::vector indices; - indices.resize(nIndexCount); - if (_binaryReader.read(&indices[0], 2, nIndexCount) != nIndexCount) - { - CCLOG("warning: Failed to read meshdata: indices '%s'.", _path.c_str()); - return false; - } - - meshdata->subMeshIndices.push_back(indices); - } - - return true; -} - -bool Bundle3D::loadMeshDataBinary_0_2(MeshData* meshdata) -{ - if (!seekToFirstType(BUNDLE_TYPE_MESH)) - return false; - - meshdata->resetData(); - - // read mesh data - if (_binaryReader.read(&meshdata->attribCount, 4, 1) != 1 || meshdata->attribCount < 1) - { - CCLOG("warning: Failed to read meshdata: attribCount '%s'.", _path.c_str()); - return false; - } - - meshdata->attribs.resize(meshdata->attribCount); - for (ssize_t i = 0; i < meshdata->attribCount; i++) - { - unsigned int vUsage, vSize; - if (_binaryReader.read(&vUsage, 4, 1) != 1 || _binaryReader.read(&vSize, 4, 1) != 1) - { - CCLOG("warning: Failed to read meshdata: usage or size '%s'.", _path.c_str()); - return false; - } - - meshdata->attribs[i].size = vSize; - meshdata->attribs[i].attribSizeBytes = meshdata->attribs[i].size * 4; - meshdata->attribs[i].type = GL_FLOAT; - meshdata->attribs[i].vertexAttrib = vUsage; - } - - // Read vertex data - if (_binaryReader.read(&meshdata->vertexSizeInFloat, 4, 1) != 1 || meshdata->vertexSizeInFloat == 0) - { - CCLOG("warning: Failed to read meshdata: vertexSizeInFloat '%s'.", _path.c_str()); - return false; - } - - meshdata->vertex.resize(meshdata->vertexSizeInFloat); - if (_binaryReader.read(&meshdata->vertex[0], 4, meshdata->vertexSizeInFloat) != meshdata->vertexSizeInFloat) - { - CCLOG("warning: Failed to read meshdata: vertex element '%s'.", _path.c_str()); - return false; - } - - // read submesh - unsigned int submeshCount; - if (_binaryReader.read(&submeshCount, 4, 1) != 1) - { - CCLOG("warning: Failed to read meshdata: submeshCount '%s'.", _path.c_str()); - return false; - } - - for (unsigned int i = 0; i < submeshCount; ++i) - { - unsigned int nIndexCount; - if (_binaryReader.read(&nIndexCount, 4, 1) != 1) - { - CCLOG("warning: Failed to read meshdata: nIndexCount '%s'.", _path.c_str()); - return false; - } - - std::vector indices; - indices.resize(nIndexCount); - if (_binaryReader.read(&indices[0], 2, nIndexCount) != nIndexCount) - { - CCLOG("warning: Failed to read meshdata: indices '%s'.", _path.c_str()); - return false; - } - - meshdata->subMeshIndices.push_back(indices); - } - - return true; -} - -bool Bundle3D::loadSkinDataBinary(SkinData* skindata) -{ - if (!seekToFirstType(BUNDLE_TYPE_MESHSKIN)) - return false; - - std::string boneName = _binaryReader.readString(); - - // transform - float bindShape[16]; - if (!_binaryReader.readMatrix(bindShape)) - { - CCLOG("warning: Failed to read SkinData: bindShape matrix '%s'.", _path.c_str()); - return false; - } - - // bone count - unsigned int boneNum; - if (!_binaryReader.read(&boneNum)) - { - CCLOG("warning: Failed to read SkinData: boneNum '%s'.", _path.c_str()); - return false; - } - - // bone names and bind pos - float bindpos[16]; - for (unsigned int i = 0; i < boneNum; i++) - { - std::string skinBoneName = _binaryReader.readString(); - skindata->skinBoneNames.push_back(skinBoneName); - if (!_binaryReader.readMatrix(bindpos)) - { - CCLOG("warning: Failed to load SkinData: bindpos '%s'.", _path.c_str()); - return false; - } - skindata->inverseBindPoseMatrices.push_back(bindpos); - } - - skindata->skinBoneOriginMatrices.resize(boneNum); - - boneName = _binaryReader.readString(); - - // bind shape - _binaryReader.readMatrix(bindShape); - int rootIndex = skindata->getSkinBoneNameIndex(boneName); - if(rootIndex < 0) - { - skindata->addNodeBoneNames(boneName); - rootIndex = skindata->getBoneNameIndex(boneName); - skindata->nodeBoneOriginMatrices.push_back(bindShape); - } - else - { - skindata->skinBoneOriginMatrices[rootIndex] = bindShape; - } - - // set root bone index - skindata->rootBoneIndex = rootIndex; - - // read parent and child relationship map - float transform[16]; - unsigned int linkNum; - _binaryReader.read(&linkNum); - for (unsigned int i = 0; i < linkNum; ++i) - { - std::string id = _binaryReader.readString(); - int index = skindata->getSkinBoneNameIndex(id); - - - std::string parentid = _binaryReader.readString(); - - if (!_binaryReader.readMatrix(transform)) - { - CCLOG("warning: Failed to load SkinData: transform '%s'.", _path.c_str()); - return false; - } - - if(index < 0) - { - skindata->addNodeBoneNames(id); - index = skindata->getBoneNameIndex(id); - skindata->nodeBoneOriginMatrices.push_back(transform); - } - else - { - skindata->skinBoneOriginMatrices[index] = transform; - } - - int parentIndex = skindata->getSkinBoneNameIndex(parentid); - if(parentIndex < 0) - { - skindata->addNodeBoneNames(parentid); - parentIndex = skindata->getBoneNameIndex(parentid); - } - - skindata->boneChild[parentIndex].push_back(index); - - } - - return true; -} - -bool Bundle3D::loadMaterialDataBinary(MaterialData* materialdata) -{ - if (!seekToFirstType(BUNDLE_TYPE_MATERIAL)) - return false; - - unsigned int materialnum = 1; - if (_version == "0.2") - { - _binaryReader.read(&materialnum, 4, 1); - } - - for (int i = 0; i < materialnum; i++) - { - std::string texturePath = _binaryReader.readString(); - if (texturePath.empty()) - { - CCLOG("warning: Failed to read Materialdata: texturePath is empty '%s'.", _path.c_str()); - return false; - } - - std::string path = _modelPath + texturePath; - materialdata->texturePaths[i] = path; - } - - return true; -} - bool Bundle3D::loadAnimationDataBinary(const std::string& id, Animation3DData* animationdata) { if (!seekToFirstType(BUNDLE_TYPE_ANIMATIONS)) diff --git a/cocos/3d/CCBundle3D.h b/cocos/3d/CCBundle3D.h index 6f1c1a8bee..b8591bdf0b 100644 --- a/cocos/3d/CCBundle3D.h +++ b/cocos/3d/CCBundle3D.h @@ -58,24 +58,12 @@ public: */ virtual bool load(const std::string& path); - /** - * load mesh data from bundle - * @param id The ID of the mesh, load the first Mesh in the bundle if it is empty - */ - virtual bool loadMeshData(const std::string& id, MeshData* meshdata); - /** * load skin data from bundle * @param id The ID of the skin, load the first Skin in the bundle if it is empty */ virtual bool loadSkinData(const std::string& id, SkinData* skindata); - /** - * load material data from bundle - * @param id The ID of the material, load the first Material in the bundle if it is empty - */ - virtual bool loadMaterialData(const std::string& id, MaterialData* materialdata); - /** * load material data from bundle * @param id The ID of the animation, load the first animation in the bundle if it is empty @@ -95,6 +83,7 @@ public: 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); @@ -111,44 +100,13 @@ protected: bool loadMeshDataJson_0_1(MeshData* meshdata){return true;} bool loadMeshDataJson_0_2(MeshData* meshdata){return true;} bool loadSkinDataJson(SkinData* skindata); + bool loadSkinDataBinary(SkinData* skindata); bool loadMaterialDataJson(MaterialData* materialdata){return true;} bool loadMaterialDataJson_0_1(MaterialData* materialdata){return true;} bool loadMaterialDataJson_0_2(MaterialData* materialdata){return true;} bool loadAnimationDataJson(const std::string& id,Animation3DData* animationdata); - /** - * load data in binary - * @param path The c3b file path - */ - bool loadBinary(const std::string& path); - - /** - * load mesh data in binary - * @param meshdata The mesh data pointer - */ - bool loadMeshDataBinary(MeshData* meshdata); - bool loadMeshDataBinary_0_1(MeshData* meshdata); - bool loadMeshDataBinary_0_2(MeshData* meshdata); - - /** - * load skin data in binary - * @param skindata The skin data pointer - */ - bool loadSkinDataBinary(SkinData* skindata); - - /** - * load material data in binary - * @param materialdata The material pointer - */ - bool loadMaterialDataBinary(MaterialData* materialdata); - - /** - * load animation data in binary - * @param animationdata The animation data pointer - */ bool loadAnimationDataBinary(const std::string& id,Animation3DData* animationdata); - bool checkIsBone(const std::string& name); - /** * load nodes of json */ @@ -196,12 +154,9 @@ CC_CONSTRUCTOR_ACCESS: virtual ~Bundle3D(); protected: - static Bundle3D* _instance; - std::string _modelPath; - std::string _path; - + std::string _path; std::string _version;// the c3b or c3t version // for json reading From 9be19cf5ac6107b0c27cc2c246362a882ea9c7a0 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Tue, 21 Oct 2014 19:29:56 +0800 Subject: [PATCH 4/7] remove nodetoparent --- cocos/3d/CCAttachNode.cpp | 7 ------- cocos/3d/CCAttachNode.h | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cocos/3d/CCAttachNode.cpp b/cocos/3d/CCAttachNode.cpp index 2f973a8f43..ee53d03d9d 100644 --- a/cocos/3d/CCAttachNode.cpp +++ b/cocos/3d/CCAttachNode.cpp @@ -62,13 +62,6 @@ Mat4 AttachNode::getWorldToNodeTransform() const return mat; } -const Mat4& AttachNode::getNodeToParentTransform() const -{ - static Mat4 mat; - mat = _attachBone->getWorldMat() * Node::getNodeToParentTransform(); - return mat; -} - void AttachNode::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) { Node::visit(renderer, parentTransform * _attachBone->getWorldMat(), Node::FLAGS_DIRTY_MASK); diff --git a/cocos/3d/CCAttachNode.h b/cocos/3d/CCAttachNode.h index 7c14d1017c..8f43a4a2b5 100644 --- a/cocos/3d/CCAttachNode.h +++ b/cocos/3d/CCAttachNode.h @@ -49,7 +49,6 @@ public: static AttachNode* create(Bone3D* attachBone); virtual Mat4 getWorldToNodeTransform() const override; - virtual const Mat4& getNodeToParentTransform() const override; virtual void visit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) override; CC_CONSTRUCTOR_ACCESS: @@ -59,7 +58,7 @@ CC_CONSTRUCTOR_ACCESS: protected: - Bone3D* _attachBone; + Bone3D* _attachBone; }; From 799f3758022ab9abe844a2deb8bdc8ae7725f02c Mon Sep 17 00:00:00 2001 From: lvlong Date: Fri, 24 Oct 2014 12:02:55 +0800 Subject: [PATCH 5/7] Fix bug: load sprite3D from cache, the attach node will be discarded. --- cocos/3d/CCSprite3D.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos/3d/CCSprite3D.cpp b/cocos/3d/CCSprite3D.cpp index d47de90238..a498d9b03e 100644 --- a/cocos/3d/CCSprite3D.cpp +++ b/cocos/3d/CCSprite3D.cpp @@ -92,6 +92,14 @@ bool Sprite3D::loadFromCache(const std::string& path) } } + for(const auto& it : spritedata->nodedatas->skeleton) + { + if(it) + { + createAttachSprite3DNode(it,*(spritedata->materialdatas)); + } + } + for (ssize_t i = 0; i < _meshes.size(); i++) { _meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i)); } From 7cf5b5079003d512053537a663af9a3b7502f835 Mon Sep 17 00:00:00 2001 From: yangxiao Date: Fri, 24 Oct 2014 15:24:36 +0800 Subject: [PATCH 6/7] add getMeshCount method --- cocos/3d/CCSprite3D.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos/3d/CCSprite3D.h b/cocos/3d/CCSprite3D.h index 29df67b674..f1621d6d1b 100644 --- a/cocos/3d/CCSprite3D.h +++ b/cocos/3d/CCSprite3D.h @@ -69,6 +69,9 @@ public: /**get mesh*/ Mesh* getMesh() const { return _meshes.at(0); } + /** get Mesh Count */ + ssize_t getMeshCount() const { return _meshes.size(); } + /**get skin*/ CC_DEPRECATED_ATTRIBUTE MeshSkin* getSkin() const; From bdf10426e2d08ecae5aad50367ac7755186303c9 Mon Sep 17 00:00:00 2001 From: lvlong Date: Mon, 27 Oct 2014 16:12:15 +0800 Subject: [PATCH 7/7] new axe.c3b (ver 0.4) --- .../cpp-tests/Resources/Sprite3DTest/axe.c3b | Bin 4191 -> 4543 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/cpp-tests/Resources/Sprite3DTest/axe.c3b diff --git a/tests/cpp-tests/Resources/Sprite3DTest/axe.c3b b/tests/cpp-tests/Resources/Sprite3DTest/axe.c3b old mode 100755 new mode 100644 index 94ec4488f3420808bacf74a5bd916c9536380984..9d69b70fc3458b5ad9ab7aab12d53a91f3316f2f GIT binary patch delta 1356 zcmZvc-%p!W7{{OfpzZnt*c^0>4LZo8#%U-Fa2xCUwzS=J6_QU@P4@io?`d>ytvLuP=UgjXzt%(jF}7hHudU-RjpdVL<#aULPGcsK$tGs=(QG!8 zisdKMQ>kn!J@KzlB9FcjIg!qcN5}M%&r=c?d?ijNA5Et-ag&_8zke6GegDaW*p~O! zlfhdRQ{`-?3ff|7-xg67TkKAUz00Py9i|#~MAZ+DZuQjBqxKzLD(DQU93IBo&P5e$ zGF8n#~7uB|h93Jyd#q*Gbyd=dn zZ(QwqP1WfeQ59cY%~RKWB=?gTSNw7H%zr}F{3H#0(dy@z*RNR{g>Zhu+T04O-M|~= zL%a#U1f*Gf$O{Feg;oG=MThHj1oHC9k6^DHLPw!CX_p{61_h;q`Zzsps1rI)d4lq! zbfNb8SeJA|-4a5l^js&+kV-b6F59F}!pP2-cZys3(E#L;voeT=pdq&EkzrbAQ8P45 z*+TiQoI`{4v2$`BIxiQ{2y=#LU66}xFM6EGx-Vs#pY42jDq zHtLfTP>-CJB)SA$mXy3F@5`8s%Nd!FGibO6DU*Mg&iM3<}nrAeJ zW+00kSJ47A$Gjz!gH~wkxy3T5e>oq1>9>CC%XZ`cOw>!yj!`TYpPKd-QF%s@uQxwi-7(_9OjY57ygseXsjj=&oK&C;RVTaB$$Y#zm&1 yb)0tN(X20w#)a0%)!0}g)_t;?GCsfYbg#|Z60z^z-E*+$Uw@ZbSfBRAX8r-Fn*x~t delta 1384 zcmY+EeN0tl9LK-szU#eQFa)oFg1k6ei-3C(yxjA0k;t&J3`;=816@d&47n6I%gYSb z>)PsZXlrfNW~}~bi_;(I;9gicx0Wt5SDRZpw(<`ettcIgY2R};7M|~Z&+~bH&+j?s zd!KvGlPbDVkk}rq1#C_Ls~Ef54#(R2%F4%NgsJ|AgZP$nSm>tGvZ|6mKFV@RqB%ziL{TVs-#c#@HJ*p1)FQ~wjaj793y*OMY z|52S#W5-U)g-u(Pk6t+;est&}?$kt(VK}FR;nGB$k?AfLcU)V9>JACv))M#byxjB+<_^tvl(-br ztdsNEr>aA5te6);Z=Lwr=NC?Ih3NN2#Jrcg!(5dwA`BmQh%xW0i+p-+W}^2*U~0ip znVMyE-rZz;^YCW%FaIZz59h{`Y3FAqlxx%K+4PO6GmN$GE+ozQj+yTj5lnu-+QwAeRa-n~NOe zVFTIBY_wMd~lv2A$PvaTvrk*9)(8!4qmz49 z!4*0y_o9VrCbe2~I`7iT^-at*b7ecT9bC}~y`N}4-p$Z^2TFUoJMTO5JpA;-