mirror of https://github.com/axmolengine/axmol.git
do not try to load empty texture
This commit is contained in:
parent
7a332aef04
commit
908b9e470d
|
@ -280,7 +280,7 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas, MaterialDatas& materialdatas, NodeD
|
|||
for (const auto& it : shapes.shapes)
|
||||
{
|
||||
NTextureData tex;
|
||||
tex.filename = dir + it.material.diffuse_texname;
|
||||
tex.filename = it.material.diffuse_texname.empty() ? it.material.diffuse_texname : dir + it.material.diffuse_texname;
|
||||
tex.type = NTextureData::Usage::Diffuse;
|
||||
tex.wrapS = GL_CLAMP_TO_EDGE;
|
||||
tex.wrapT = GL_CLAMP_TO_EDGE;
|
||||
|
@ -855,7 +855,7 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas)
|
|||
return false;
|
||||
}
|
||||
|
||||
textureData.filename = _modelPath + texturePath;
|
||||
textureData.filename = texturePath.empty() ? texturePath : _modelPath + texturePath;
|
||||
float uvdata[4];
|
||||
_binaryReader.read(&uvdata,sizeof(float), 4);
|
||||
textureData.type = parseGLTextureType(_binaryReader.readString());
|
||||
|
@ -882,7 +882,7 @@ bool Bundle3D::loadMaterialsBinary_0_1(MaterialDatas& materialdatas)
|
|||
}
|
||||
|
||||
NTextureData textureData;
|
||||
textureData.filename = _modelPath + texturePath;
|
||||
textureData.filename = texturePath.empty() ? texturePath : _modelPath + texturePath;
|
||||
textureData.type= NTextureData::Usage::Diffuse;
|
||||
textureData.id="";
|
||||
materialData.textures.push_back(textureData);
|
||||
|
@ -910,7 +910,7 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas)
|
|||
}
|
||||
|
||||
NTextureData textureData;
|
||||
textureData.filename = _modelPath + texturePath;
|
||||
textureData.filename = texturePath.empty() ? texturePath : _modelPath + texturePath;
|
||||
textureData.type= NTextureData::Usage::Diffuse;
|
||||
textureData.id="";
|
||||
materialData.textures.push_back(textureData);
|
||||
|
@ -936,7 +936,7 @@ bool Bundle3D::loadMaterialsJson(MaterialDatas& materialdatas)
|
|||
NTextureData textureData;
|
||||
const rapidjson::Value& texture_val = testure_array[j];
|
||||
std::string filename = texture_val[FILENAME].GetString();
|
||||
textureData.filename = _modelPath + filename;
|
||||
textureData.filename = filename.empty() ? filename : _modelPath + filename;
|
||||
textureData.type = parseGLTextureType(texture_val["type"].GetString());
|
||||
textureData.wrapS = parseGLType(texture_val["wrapModeU"].GetString());
|
||||
textureData.wrapT = parseGLType(texture_val["wrapModeV"].GetString());
|
||||
|
@ -1301,7 +1301,8 @@ bool Bundle3D::loadMaterialDataJson_0_1(MaterialDatas& materialdatas)
|
|||
const rapidjson::Value& material_data_base_array_0 = material_data_base_array[(rapidjson::SizeType)0];
|
||||
NTextureData textureData;
|
||||
// set texture
|
||||
textureData.filename =_modelPath + material_data_base_array_0[FILENAME].GetString();
|
||||
std::string filename = material_data_base_array_0[FILENAME].GetString();
|
||||
textureData.filename = filename.empty() ? filename : _modelPath + filename;
|
||||
textureData.type= NTextureData::Usage::Diffuse;
|
||||
textureData.id="";
|
||||
materialData.textures.push_back(textureData);
|
||||
|
@ -1325,7 +1326,8 @@ bool Bundle3D::loadMaterialDataJson_0_2(MaterialDatas& materialdatas)
|
|||
const rapidjson::Value& material_val = material_array[i];
|
||||
|
||||
// set texture
|
||||
textureData.filename = _modelPath + material_val[TEXTURES].GetString();
|
||||
std::string filename = material_val[TEXTURES].GetString();
|
||||
textureData.filename = filename.empty() ? filename : _modelPath + filename;
|
||||
textureData.type= NTextureData::Usage::Diffuse;
|
||||
textureData.id="";
|
||||
materialData.textures.push_back(textureData);
|
||||
|
|
|
@ -258,7 +258,8 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
|
|||
if (modeldata->matrialId == "" && matrialdatas.materials.size())
|
||||
{
|
||||
const NTextureData* textureData = matrialdatas.materials[0].getTextureData(NTextureData::Usage::Diffuse);
|
||||
mesh->setTexture(textureData->filename);
|
||||
if (!textureData->filename.empty())
|
||||
mesh->setTexture(textureData->filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -266,7 +267,7 @@ Sprite3D* Sprite3D::createSprite3DNode(NodeData* nodedata,ModelData* modeldata,c
|
|||
if(materialData)
|
||||
{
|
||||
const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
|
||||
if(textureData)
|
||||
if(textureData && !textureData->filename.empty())
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
|
||||
if(tex)
|
||||
|
@ -401,7 +402,7 @@ void Sprite3D::createNode(NodeData* nodedata, Node* root, const MaterialDatas& m
|
|||
if(materialData)
|
||||
{
|
||||
const NTextureData* textureData = materialData->getTextureData(NTextureData::Usage::Diffuse);
|
||||
if(textureData)
|
||||
if(textureData && !textureData->filename.empty())
|
||||
{
|
||||
auto tex = Director::getInstance()->getTextureCache()->addImage(textureData->filename);
|
||||
if(tex)
|
||||
|
|
Loading…
Reference in New Issue