Updated UniGLTF

This commit is contained in:
ousttrue
2018-08-07 19:17:41 +09:00
parent ad4af4ac79
commit 54d2656f5f
4 changed files with 13 additions and 21 deletions

View File

@@ -290,31 +290,22 @@ namespace VRM
{
var x = new TextureItem(context.GLTF, i);
x.Process(context.GLTF, storage);
context.Textures.Add(x);
context.AddTexture(x);
yield return null;
}
}
static IEnumerator LoadMaterials(VRMImporterContext context)
{
Func<int, TextureItem> getTexture = x =>
{
if (x < 0 || x >= context.Textures.Count)
{
return null;
}
return context.Textures[x];
};
if (context.GLTF.materials == null || !context.GLTF.materials.Any())
{
context.AddMaterial(context.MaterialImporter.CreateMaterial(0, null, getTexture));
context.AddMaterial(context.MaterialImporter.CreateMaterial(0, null));
}
else
{
for (int i = 0; i < context.GLTF.materials.Count; ++i)
{
context.AddMaterial(context.MaterialImporter.CreateMaterial(i, context.GLTF.materials[i], getTexture));
context.AddMaterial(context.MaterialImporter.CreateMaterial(i, context.GLTF.materials[i]));
yield return null;
}
}
@@ -448,7 +439,7 @@ namespace VRM
texture.Process(ctx.GLTF, ctx.Storage);
return texture;
})
.ContinueWith(Scheduler.ThreadPool, x => ctx.Textures.Add(x));
.ContinueWith(Scheduler.ThreadPool, x => ctx.AddTexture(x));
}
})
.ContinueWithCoroutine(Scheduler.MainThread, () => LoadMaterials(ctx))

View File

@@ -29,10 +29,11 @@ namespace VRM
meta.Reference = gltfMeta.reference;
meta.Title = gltfMeta.title;
if (gltfMeta.texture >= 0 && gltfMeta.texture < Textures.Count)
var thumbnail = GetTexture(gltfMeta.texture);
if (thumbnail!=null)
{
// ロード済み
meta.Thumbnail = Textures[gltfMeta.texture].Texture;
meta.Thumbnail = thumbnail.Texture;
}
else if (createThumbnail)
{

View File

@@ -9,7 +9,7 @@ namespace VRM
public class VRMMaterialImporter : MaterialImporter
{
List<glTF_VRM_Material> m_materials;
public VRMMaterialImporter(ImporterContext context, List<glTF_VRM_Material> materials) : base(new ShaderStore(context, "VRM/UnlitTexture"))
public VRMMaterialImporter(ImporterContext context, List<glTF_VRM_Material> materials) : base(new ShaderStore(context, "VRM/UnlitTexture"), context)
{
m_materials = materials;
/*
@@ -47,7 +47,7 @@ namespace VRM
"VRM/MToon",
};
public override Material CreateMaterial(int i, glTFMaterial src, Func<int, TextureItem> getTexture)
public override Material CreateMaterial(int i, glTFMaterial src)
{
var item = m_materials[i];
var shaderName = item.shader;
@@ -60,12 +60,12 @@ namespace VRM
if (VRM_SHADER_NAMES.Contains(shaderName))
{
Debug.LogErrorFormat("shader {0} not found. set Assets/VRM/Shaders/VRMShaders to Edit - project setting - Graphics - preloaded shaders", shaderName);
return base.CreateMaterial(i, src, getTexture);
return base.CreateMaterial(i, src);
}
else
{
Debug.LogWarningFormat("unknown shader {0}.", shaderName);
return base.CreateMaterial(i, src, getTexture);
return base.CreateMaterial(i, src);
}
}
@@ -97,7 +97,7 @@ namespace VRM
}
foreach (var kv in item.textureProperties)
{
var texture = getTexture(kv.Value);
var texture = Context.GetTexture(kv.Value);
if (texture != null) {
material.SetTexture(kv.Key, texture.Texture);
}

Submodule UniGLTF updated: 3bc3985f4d...1b41b0ab30