From c5f955466a54be0a76fa6d7d175c56843de50a9d Mon Sep 17 00:00:00 2001 From: lvlong Date: Thu, 22 Jan 2015 17:28:35 +0800 Subject: [PATCH 1/2] fixbug: load obj file's material. --- cocos/3d/CCBundle3D.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index b318fe8ebb..cbe16eb35b 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -207,8 +207,15 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD materialdatas.resetData(); nodedatas.resetData(); + // fix bug: when mtl_basepath is nullptr. + std::string mtlPath = ""; + if (mtl_basepath) + mtlPath = mtl_basepath; + else + mtlPath = fullPath.substr(0, fullPath.find_last_of("\\/") + 1).c_str(); + ObjLoader::shapes_t shapes; - auto ret = ObjLoader::LoadObj(shapes, fullPath.c_str(), mtl_basepath); + auto ret = ObjLoader::LoadObj(shapes, fullPath.c_str(), mtlPath.c_str()); if (ret.empty()) { //fill data From 662117e878391e40985b6bfc184f7bede41dc1d5 Mon Sep 17 00:00:00 2001 From: lvlong Date: Thu, 22 Jan 2015 17:33:24 +0800 Subject: [PATCH 2/2] mtlPath --- cocos/3d/CCBundle3D.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/3d/CCBundle3D.cpp b/cocos/3d/CCBundle3D.cpp index cbe16eb35b..bb8879e41c 100644 --- a/cocos/3d/CCBundle3D.cpp +++ b/cocos/3d/CCBundle3D.cpp @@ -207,7 +207,6 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD materialdatas.resetData(); nodedatas.resetData(); - // fix bug: when mtl_basepath is nullptr. std::string mtlPath = ""; if (mtl_basepath) mtlPath = mtl_basepath;