public void LoadCharactor(int id) { posMng = GetComponent <PoseStatusDebug>(); owner = GetComponent <MeteorUnitDebug>(); CharacterIdx = id; Skin = new GameObject(); Skin.transform.SetParent(transform); Skin.transform.localRotation = Quaternion.identity; Skin.transform.localScale = Vector3.one; Skin.transform.localPosition = Vector3.zero; SkcFile skc = SkcLoader.Instance.Load(id); BncFile bnc = BncLoader.Instance.Load(id); Skin.name = skc.Skin; rend = Skin.AddComponent <SkinnedMeshRenderer>(); rend.localBounds = skc.mesh.bounds; rend.materials = skc.Material(id, owner.Camp); rend.sharedMesh = skc.mesh; rend.sharedMesh.RecalculateBounds(); bo = new List <Transform>(); dummy = new List <Transform>(); List <Matrix4x4> bindPos = new List <Matrix4x4>(); bnc.GenerateBone(transform, ref bo, ref dummy, ref bindPos, ref rootBone); rend.bones = bo.ToArray(); rend.sharedMesh.bindposes = bindPos.ToArray(); rend.rootBone = rootBone; RootPos = rootBone.localPosition; RootQuat = rootBone.localRotation; AmbLoader.Ins.LoadCharacterAmb(id); LoadBoxDef(id); }
public void LoadCharactor(int id) { owner = GetComponent <Entity>(); CharacterIndex = id; Skin = new GameObject(); Skin.transform.SetParent(transform); Skin.transform.localRotation = Quaternion.identity; Skin.transform.localScale = Vector3.one; Skin.transform.localPosition = Vector3.zero; //load skin SkcFile skc = SkcLoader.Instance.Load(id); Skin.name = skc.Skin; rend = Skin.AddComponent <SkinnedMeshRenderer>(); BncFile bnc = BncLoader.Instance.Load(id); rend.localBounds = skc.mesh.bounds; rend.materials = skc.Material(id); rend.sharedMesh = skc.mesh; rend.sharedMesh.RecalculateBounds(); bone = new List <Transform>(); dummy = new List <Transform>(); List <Matrix4x4> bindPos = new List <Matrix4x4>(); if (owner.IsHero) { Skin.layer = LayerMask.NameToLayer("LocalPlayer"); } else { Skin.layer = LayerMask.NameToLayer("Monster"); } bnc.GenerateBone(transform, ref bone, ref dummy, ref bindPos, ref rootBone); rend.bones = bone.ToArray(); rend.sharedMesh.bindposes = bindPos.ToArray(); rend.rootBone = rootBone; rootPosition = rootBone.localPosition; rootQuat = rootBone.localRotation; AmbLoader.Ins.LoadCharacterAmb(id); AmbLoader.Ins.LoadCharacterAmb(); LoadBoxDef(id); }
public void LoadCharactor(int id) { owner = GetComponent <MeteorUnit>(); posMng = owner.posMng; CharacterIdx = id; Skin = new GameObject(); Skin.transform.SetParent(transform); Skin.transform.localRotation = Quaternion.identity; Skin.transform.localScale = Vector3.one; Skin.transform.localPosition = Vector3.zero; SkcFile skc = SkcLoader.Instance.Load(id); BncFile bnc = BncLoader.Instance.Load(id); Skin.name = skc.Skin; rend = Skin.AddComponent <SkinnedMeshRenderer>(); rend.localBounds = skc.mesh.bounds; rend.materials = skc.Material(id, owner.Camp); rend.sharedMesh = skc.mesh; rend.sharedMesh.RecalculateBounds(); bo = new List <Transform>(); dummy = new List <Transform>(); List <Matrix4x4> bindPos = new List <Matrix4x4>(); if (owner.Attr.IsPlayer) { Skin.layer = LayerMask.NameToLayer("LocalPlayer"); } else { Skin.layer = LayerMask.NameToLayer("Monster"); } bnc.GenerateBone(transform, ref bo, ref dummy, ref bindPos, ref rootBone); WsGlobal.SetObjectLayer(gameObject, Skin.layer); rend.bones = bo.ToArray(); rend.sharedMesh.bindposes = bindPos.ToArray(); rend.rootBone = rootBone; RootPos = rootBone.localPosition; RootQuat = rootBone.localRotation; AmbLoader.Ins.LoadCharacterAmb(id); //GenerateBounds(skc.mesh, bo); LoadBoxDef(id); }
} //当前动作特效,用于飞镖/飞轮的挂点查询 public void LoadCharactor(int id, Transform Tri) { Target = Tri; Owner = Target.GetComponent <MeteorUnit>(); posMng = Owner.ActionMgr; Skin = new GameObject(); Skin.transform.SetParent(Target); Skin.transform.localRotation = Quaternion.identity; Skin.transform.localScale = Vector3.one; Skin.transform.localPosition = Vector3.zero; SkcFile skc = SkcLoader.Ins.Load(id); BncFile bnc = BncLoader.Ins.Load(id); Skin.name = skc.Skin; render = Skin.AddComponent <SkinnedMeshRenderer>(); render.localBounds = skc.mesh.bounds; render.materials = skc.Material(id, Owner.Camp); //这个方式无法分别子网格 //if (Owner.Attr.IsPlayer) { // for (int i = 0; i < render.materials.Length; i++) { // render.materials[i].shader = Shader.Find("MainPlayer"); // } //} render.sharedMesh = skc.mesh; render.sharedMesh.RecalculateBounds(); bo = new List <Transform>(); dummy = new List <Transform>(); List <Matrix4x4> bindPos = new List <Matrix4x4>(); Skin.layer = LayerManager.Player; bnc.GenerateBone(Target, ref bo, ref dummy, ref bindPos, ref rootBone); //Utility.SetObjectLayer(Target.gameObject, Skin.layer); render.bones = bo.ToArray(); render.sharedMesh.bindposes = bindPos.ToArray(); render.rootBone = rootBone; RootPos = rootBone.localPosition; RootQuat = rootBone.localRotation; AmbLoader.Ins.LoadCharacterAmb(id); //GenerateBounds(skc.mesh, bo); LoadBoxDef(id); }