mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-26 21:04:14 -05:00
RemoveSuffix
This commit is contained in:
@@ -154,7 +154,7 @@ namespace UniGLTF
|
||||
);
|
||||
}
|
||||
|
||||
public virtual int ExportTexture(glTF gltf, int bufferIndex, Texture texture, glTFTextureTypes textureType)
|
||||
public int ExportTexture(glTF gltf, int bufferIndex, Texture texture, glTFTextureTypes textureType)
|
||||
{
|
||||
var bytesWithMime = GetBytesWithMime(texture, textureType); ;
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace UniGLTF
|
||||
var imageIndex = gltf.images.Count;
|
||||
gltf.images.Add(new glTFImage
|
||||
{
|
||||
name = texture.name,
|
||||
name = GetTextureParam.RemoveSuffix(texture.name),
|
||||
bufferView = viewIndex,
|
||||
mimeType = bytesWithMime.mine,
|
||||
});
|
||||
|
||||
@@ -5,8 +5,31 @@ namespace UniGLTF
|
||||
public struct GetTextureParam
|
||||
{
|
||||
public const string NORMAL_PROP = "_BumpMap";
|
||||
public const string NORMAL_SUFFIX = ".normal";
|
||||
public const string METALLIC_GLOSS_PROP = "_MetallicGlossMap";
|
||||
public const string METALLIC_GLOSS_SUFFIX = ".metallicRoughness";
|
||||
public const string OCCLUSION_PROP = "_OcclusionMap";
|
||||
public const string OCCLUSION_SUFFIX = ".occlusion";
|
||||
|
||||
public static string RemoveSuffix(string src)
|
||||
{
|
||||
if (src.EndsWith(NORMAL_SUFFIX))
|
||||
{
|
||||
return src.Substring(0, src.Length - NORMAL_SUFFIX.Length);
|
||||
}
|
||||
else if (src.EndsWith(METALLIC_GLOSS_SUFFIX))
|
||||
{
|
||||
return src.Substring(0, src.Length - METALLIC_GLOSS_SUFFIX.Length);
|
||||
}
|
||||
else if (src.EndsWith(OCCLUSION_SUFFIX))
|
||||
{
|
||||
return src.Substring(0, src.Length - OCCLUSION_SUFFIX.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
readonly string m_name;
|
||||
|
||||
@@ -18,9 +41,9 @@ namespace UniGLTF
|
||||
{
|
||||
switch (TextureType)
|
||||
{
|
||||
case METALLIC_GLOSS_PROP: return $"{m_name}.metallicRoughness";
|
||||
case OCCLUSION_PROP: return $"{m_name}.occlusion";
|
||||
case NORMAL_PROP: return $"{m_name}.normal";
|
||||
case METALLIC_GLOSS_PROP: return $"{m_name}{METALLIC_GLOSS_SUFFIX}";
|
||||
case OCCLUSION_PROP: return $"{m_name}{OCCLUSION_SUFFIX}";
|
||||
case NORMAL_PROP: return $"{m_name}{NORMAL_SUFFIX}";
|
||||
default: return m_name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user