mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-02 22:14:30 -05:00
vrm-1.0 import 時の index check. node.mesh あるか?
This commit is contained in:
parent
badc8a54e0
commit
c369439dc0
|
|
@ -8,13 +8,23 @@ namespace UniVRM10
|
|||
{
|
||||
public static class ExpressionExtensions
|
||||
{
|
||||
public static UniVRM10.MorphTargetBinding Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer.ModelMap loader, VrmLib.Model model)
|
||||
public static MorphTargetBinding? Build10(this MorphTargetBind bind, GameObject root, Vrm10Importer.ModelMap loader, VrmLib.Model model)
|
||||
{
|
||||
var libNode = model.Nodes[bind.Node.Value];
|
||||
var node = loader.Nodes[libNode].transform;
|
||||
var mesh = loader.Meshes[libNode.MeshGroup];
|
||||
var relativePath = node.RelativePathFrom(root.transform);
|
||||
return new UniVRM10.MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
|
||||
if (bind.Node.TryGetValidIndex(model.Nodes.Count, out var nodeIndex))
|
||||
{
|
||||
var libNode = model.Nodes[nodeIndex];
|
||||
if (libNode.MeshGroup == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
var node = loader.Nodes[libNode].transform;
|
||||
var relativePath = node.RelativePathFrom(root.transform);
|
||||
return new MorphTargetBinding(relativePath, bind.Index.Value, bind.Weight.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public static UniVRM10.MaterialColorBinding? Build10(this MaterialColorBind bind, IReadOnlyList<MaterialFactory.MaterialLoadInfo> materials)
|
||||
|
|
|
|||
|
|
@ -316,7 +316,10 @@ namespace UniVRM10
|
|||
|
||||
if (expression.MorphTargetBinds != null)
|
||||
{
|
||||
clip.MorphTargetBindings = expression.MorphTargetBinds?.Select(x => x.Build10(Root, m_map, m_model))
|
||||
clip.MorphTargetBindings = expression.MorphTargetBinds?
|
||||
.Select(x => x.Build10(Root, m_map, m_model))
|
||||
.Where(x => x.HasValue)
|
||||
.Select(x => x.Value)
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
|
|
@ -492,15 +495,17 @@ namespace UniVRM10
|
|||
var fp = vrmExtension.FirstPerson;
|
||||
foreach (var x in fp.MeshAnnotations)
|
||||
{
|
||||
var node = Nodes[x.Node.Value];
|
||||
var relative = node.RelativePathFrom(Root.transform);
|
||||
vrm.FirstPerson.Renderers.Add(new RendererFirstPersonFlags
|
||||
if (x.Node.TryGetValidIndex(Nodes.Count, out var index))
|
||||
{
|
||||
FirstPersonFlag = x.Type,
|
||||
Renderer = relative,
|
||||
});
|
||||
var node = Nodes[x.Node.Value];
|
||||
var relative = node.RelativePathFrom(Root.transform);
|
||||
vrm.FirstPerson.Renderers.Add(new RendererFirstPersonFlags
|
||||
{
|
||||
FirstPersonFlag = x.Type,
|
||||
Renderer = relative,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// default 値を割り当てる
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user