-
Notifications
You must be signed in to change notification settings - Fork 430
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2183 from ousttrue/fix/firstperson_split
[vrm1.0] impl mesh split by blendshape existence
- Loading branch information
Showing
14 changed files
with
554 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 39 additions & 16 deletions
55
Assets/UniGLTF/Runtime/MeshUtility/MeshIntegrationResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace UniGLTF.MeshUtility | ||
{ | ||
[System.Serializable] | ||
public class MeshMap | ||
public struct DrawCount | ||
{ | ||
public List<Mesh> Sources = new List<Mesh>(); | ||
public Mesh Integrated; | ||
public Material[] SharedMaterials; | ||
public Transform[] Bones; | ||
public int Count; | ||
public Material Material; | ||
} | ||
|
||
public class MeshIntegrationResult | ||
[Serializable] | ||
public class MeshInfo | ||
{ | ||
public List<SkinnedMeshRenderer> SourceSkinnedMeshRenderers = new List<SkinnedMeshRenderer>(); | ||
public List<MeshRenderer> SourceMeshRenderers = new List<MeshRenderer>(); | ||
public MeshMap MeshMap = new MeshMap(); | ||
public Mesh Mesh; | ||
public List<DrawCount> SubMeshes = new List<DrawCount>(); | ||
|
||
public SkinnedMeshRenderer IntegratedRenderer; | ||
|
||
public void AddIntegratedRendererTo(GameObject parent) | ||
public void AddIntegratedRendererTo(GameObject parent, Transform[] bones) | ||
{ | ||
var go = new GameObject(MeshMap.Integrated.name); | ||
var go = new GameObject(Mesh.name); | ||
go.transform.SetParent(parent.transform, false); | ||
var smr = go.AddComponent<SkinnedMeshRenderer>(); | ||
smr.sharedMesh = MeshMap.Integrated; | ||
smr.sharedMaterials = MeshMap.SharedMaterials; | ||
smr.bones = MeshMap.Bones; | ||
|
||
smr.sharedMesh = Mesh; | ||
smr.sharedMaterials = SubMeshes.Where(x => x.Count > 0).Select(x => x.Material).ToArray(); | ||
smr.bones = bones; | ||
IntegratedRenderer = smr; | ||
} | ||
} | ||
|
||
public class MeshIntegrationResult | ||
{ | ||
public List<SkinnedMeshRenderer> SourceSkinnedMeshRenderers = new List<SkinnedMeshRenderer>(); | ||
public List<MeshRenderer> SourceMeshRenderers = new List<MeshRenderer>(); | ||
|
||
public List<Mesh> Sources = new List<Mesh>(); | ||
public MeshInfo Integrated; | ||
public MeshInfo IntegratedNoBlendShape; | ||
public Transform[] Bones; | ||
|
||
public void DestroySourceRenderer() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IEnumerable<GameObject> AddIntegratedRendererTo(GameObject parent) | ||
{ | ||
if (Integrated != null) | ||
{ | ||
Integrated.AddIntegratedRendererTo(parent, Bones); | ||
yield return Integrated.IntegratedRenderer.gameObject; | ||
} | ||
if (IntegratedNoBlendShape != null) | ||
{ | ||
IntegratedNoBlendShape.AddIntegratedRendererTo(parent, Bones); | ||
yield return IntegratedNoBlendShape.IntegratedRenderer.gameObject; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.