mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-03 06:24:46 -05:00
MeshExportInfo.Renderers
This commit is contained in:
parent
ce98d54976
commit
0706c869ee
|
|
@ -64,28 +64,28 @@ namespace UniGLTF
|
|||
foreach (var info in Meshes)
|
||||
{
|
||||
// invalid materials.len
|
||||
if (info.Renderer.sharedMaterials.Length < info.Mesh.subMeshCount)
|
||||
if (info.Materials.Length < info.Mesh.subMeshCount)
|
||||
{
|
||||
// submesh より material の方が少ない
|
||||
yield return Validation.Error(Messages.MATERIALS_LESS_THAN_SUBMESH_COUNT.Msg());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.Renderer.sharedMaterials.Length > info.Mesh.subMeshCount)
|
||||
if (info.Materials.Length > info.Mesh.subMeshCount)
|
||||
{
|
||||
// submesh より material の方が多い
|
||||
yield return Validation.Warning(Messages.MATERIALS_GREATER_THAN_SUBMESH_COUNT.Msg());
|
||||
}
|
||||
|
||||
if (info.Renderer.sharedMaterials.Take(info.Mesh.subMeshCount).Any(x => x == null))
|
||||
if (info.Materials.Take(info.Mesh.subMeshCount).Any(x => x == null))
|
||||
{
|
||||
// material に null が含まれる(unity で magenta になっているはず)
|
||||
yield return Validation.Error($"{info.Renderer}: {Messages.MATERIALS_CONTAINS_NULL.Msg()}");
|
||||
yield return Validation.Error($"{info.Renderers}: {Messages.MATERIALS_CONTAINS_NULL.Msg()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var m in Meshes.SelectMany(x => x.Renderer.sharedMaterials).Distinct())
|
||||
foreach (var m in Meshes.SelectMany(x => x.Materials).Distinct())
|
||||
{
|
||||
if (m == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,12 +40,15 @@ namespace UniGLTF
|
|||
var (left, right) = LeftRight(r.x, r.y, col0, r.width - col0, EditorGUIUtility.singleLineHeight);
|
||||
EditorGUI.LabelField(left, $"{i,3}");
|
||||
|
||||
GUI.enabled = false;
|
||||
EditorGUI.ObjectField(right, info.Renderer, info.Renderer.GetType(), true);
|
||||
|
||||
right.y += EditorGUIUtility.singleLineHeight;
|
||||
EditorGUI.ObjectField(right, info.Mesh, info.Renderer.GetType(), true);
|
||||
GUI.enabled = true;
|
||||
using (new EditorGUI.DisabledScope(false))
|
||||
{
|
||||
foreach (var renderer in info.Renderers)
|
||||
{
|
||||
EditorGUI.ObjectField(right, renderer, info.Renderers.GetType(), true);
|
||||
}
|
||||
right.y += EditorGUIUtility.singleLineHeight;
|
||||
EditorGUI.ObjectField(right, info.Mesh, info.Renderers.GetType(), true);
|
||||
}
|
||||
|
||||
right.y += EditorGUIUtility.singleLineHeight;
|
||||
EditorGUI.LabelField(right, info.Summary);
|
||||
|
|
|
|||
|
|
@ -7,10 +7,18 @@ using UnityEngine;
|
|||
namespace UniGLTF
|
||||
{
|
||||
[Serializable]
|
||||
public struct MeshExportInfo
|
||||
public class MeshExportInfo
|
||||
{
|
||||
public Renderer Renderer;
|
||||
#region この2つの組が gltf mesh の Unique なキーとなる
|
||||
public Mesh Mesh;
|
||||
public Material[] Materials;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// ひとつの Mesh を複数の Renderer が共有することがありうる
|
||||
/// </summary>
|
||||
public List<Renderer> Renderers;
|
||||
|
||||
public bool IsRendererActive;
|
||||
public bool Skinned;
|
||||
|
||||
|
|
@ -50,6 +58,12 @@ namespace UniGLTF
|
|||
|
||||
public string Summary;
|
||||
|
||||
MeshExportInfo(Renderer renderer)
|
||||
{
|
||||
Materials = renderer.sharedMaterials;
|
||||
Renderers = new List<Renderer> { renderer };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ヒエラルキーからエクスポートする Mesh の情報を収集する
|
||||
/// </summary>
|
||||
|
|
@ -76,27 +90,27 @@ namespace UniGLTF
|
|||
|
||||
static bool TryGetMeshInfo(GameObject root, Renderer renderer, MeshExportSettings settings, IBlendShapeExportFilter blendShapeFilter, out MeshExportInfo info)
|
||||
{
|
||||
info = default;
|
||||
if (root == null)
|
||||
{
|
||||
info.Summary = "";
|
||||
info = default;
|
||||
return false;
|
||||
}
|
||||
if (renderer == null)
|
||||
{
|
||||
info.Summary = "no Renderer";
|
||||
info = default;
|
||||
return false;
|
||||
}
|
||||
info.Renderer = renderer;
|
||||
|
||||
if (renderer is SkinnedMeshRenderer smr)
|
||||
{
|
||||
info = new MeshExportInfo(renderer);
|
||||
info.Skinned = true;
|
||||
info.Mesh = smr.sharedMesh;
|
||||
info.IsRendererActive = smr.EnableForExport();
|
||||
}
|
||||
else if (renderer is MeshRenderer mr)
|
||||
{
|
||||
info = new MeshExportInfo(renderer);
|
||||
var filter = mr.GetComponent<MeshFilter>();
|
||||
if (filter != null)
|
||||
{
|
||||
|
|
@ -106,11 +120,15 @@ namespace UniGLTF
|
|||
}
|
||||
else
|
||||
{
|
||||
info.Summary = "no Mesh";
|
||||
return false;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
info.VertexColor = VertexColorUtility.DetectVertexColor(info.Mesh, info.Renderer.sharedMaterials);
|
||||
if (info.Mesh == null)
|
||||
{
|
||||
info.Summary = "no mesh";
|
||||
}
|
||||
|
||||
info.VertexColor = VertexColorUtility.DetectVertexColor(info.Mesh, info.Materials);
|
||||
|
||||
var relativePath = UniGLTF.UnityExtensions.RelativePathFrom(renderer.transform, root.transform);
|
||||
CalcMeshSize(ref info, relativePath, settings, blendShapeFilter);
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ namespace VRM
|
|||
switch (meshInfo.VertexColor)
|
||||
{
|
||||
case UniGLTF.VertexColorState.ExistsAndMixed:
|
||||
Validation.Warning($"{meshInfo.Renderer}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
|
||||
Validation.Warning($"{meshInfo.Renderers}: Both vcolor.multiply and not multiply unlit materials exist").DrawGUI();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user