This commit is contained in:
yangxiao 2014-12-31 11:40:37 +08:00
commit d23eb83ba1
1 changed files with 30 additions and 2 deletions

View File

@ -87,6 +87,7 @@ static const char* TRANSLATION = "translation";
static const char* ROTATION = "rotation";
static const char* SCALE = "scale";
static const char* KEYTIME = "keytime";
static const char* AABBS = "aabb";
NS_CC_BEGIN
@ -431,7 +432,22 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
}
meshData->subMeshIndices.push_back(indexArray);
meshData->numIndex = (int)meshData->subMeshIndices.size();
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
//meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
if (_version != "0.3" && _version != "0.4" && _version != "0.5")
{
//read mesh aabb
float aabb[6];
if (_binaryReader.read(aabb, 4, 6) != 6)
{
CCLOG("warning: Failed to read meshdata: aabb '%s'.", _path.c_str());
return false;
}
meshData->subMeshAABB.push_back(AABB(Vec3(aabb[0], aabb[1], aabb[2]), Vec3(aabb[3], aabb[4], aabb[5])));
}
else
{
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
}
}
meshdatas.meshDatas.push_back(meshData);
}
@ -710,7 +726,19 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
meshData->subMeshIndices.push_back(indexArray);
meshData->numIndex = (int)meshData->subMeshIndices.size();
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
//meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
const rapidjson::Value& mesh_part_aabb = mesh_part[AABBS];
if (mesh_part.HasMember(AABBS) && mesh_part_aabb.Size() == 6)
{
Vec3 min = Vec3(mesh_part_aabb[(rapidjson::SizeType)0].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)1].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)2].GetDouble());
Vec3 max = Vec3(mesh_part_aabb[(rapidjson::SizeType)3].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)4].GetDouble(), mesh_part_aabb[(rapidjson::SizeType)5].GetDouble());
meshData->subMeshAABB.push_back(AABB(min, max));
}
else
{
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), indexArray));
}
}
meshdatas.meshDatas.push_back(meshData);
}