More adjustments to fix potential errors
This commit is contained in:
parent
411f07d4fb
commit
31e39b3308
@ -83,11 +83,11 @@ namespace CafeLibrary.M2
|
|||||||
for (int j = 0; j < parameters.Length; j++)
|
for (int j = 0; j < parameters.Length; j++)
|
||||||
{
|
{
|
||||||
if (parameters[j].ToString().StartsWith("34397848")) //tAlbedoMap
|
if (parameters[j].ToString().StartsWith("34397848")) //tAlbedoMap
|
||||||
material.DiffuseMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.DiffuseMap = FindTextureParam(parameters, j);
|
||||||
if (parameters[j].ToString().StartsWith("577110")) //tNormalMap
|
if (parameters[j].ToString().StartsWith("577110")) //tNormalMap
|
||||||
material.NormalMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.NormalMap = FindTextureParam(parameters, j);
|
||||||
// if (parameters[j].ToString().StartsWith("24862")) //tSpecularMap
|
if (parameters[j].ToString().StartsWith("24862")) //tSpecularMap
|
||||||
// material.SpecularMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.SpecularMap = FindTextureParam(parameters, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -96,17 +96,33 @@ namespace CafeLibrary.M2
|
|||||||
for (int j = 0; j < parameters.Length; j++)
|
for (int j = 0; j < parameters.Length; j++)
|
||||||
{
|
{
|
||||||
if (parameters[j].ToString().StartsWith("34397848")) //tAlbedoMap
|
if (parameters[j].ToString().StartsWith("34397848")) //tAlbedoMap
|
||||||
material.DiffuseMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.DiffuseMap = FindTextureParam(parameters, j);
|
||||||
if (parameters[j].ToString().StartsWith("5771109")) //tNormalMap
|
if (parameters[j].ToString().StartsWith("5771109")) //tNormalMap
|
||||||
material.NormalMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.NormalMap = FindTextureParam(parameters, j);
|
||||||
// if (parameters[j].ToString().StartsWith("2486240")) //tSpecularMap
|
if (parameters[j].ToString().StartsWith("2486240")) //tSpecularMap
|
||||||
// material.SpecularMap = this.Textures[(int)parameters[j - 1] - 1];
|
material.SpecularMap = FindTextureParam(parameters, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Texture FindTextureParam(ulong[] parameters, int id)
|
||||||
|
{
|
||||||
|
var index = (uint)parameters[id - 1] - 1;
|
||||||
|
if (index < Textures.Count) //Index before texture hash. Sometimes not always the case?
|
||||||
|
return Textures[(int)index];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Texture FindTextureParam(uint[] parameters, int id)
|
||||||
|
{
|
||||||
|
var index = parameters[id - 1] - 1;
|
||||||
|
if (index < Textures.Count)
|
||||||
|
return Textures[(int)index];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private uint ReadUint(FileReader reader)
|
private uint ReadUint(FileReader reader)
|
||||||
{
|
{
|
||||||
if (_hasUint64Offsets)
|
if (_hasUint64Offsets)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user