Exemple #1
0
        protected override void onAwake()
        {
            avatarService = Service.Get <AvatarService>();
            Rig component = GetComponent <Rig>();
            SkinnedMeshDefinition skinnedMeshDefinition = new SkinnedMeshDefinition(UseGpuSkinning);

            skinnedMeshDefinition.RootBoneName = component.RootBone.name;
            skinnedMeshDefinition.BoneNames    = new string[component.Bones.Length];
            for (int i = 0; i < component.Bones.Length; i++)
            {
                skinnedMeshDefinition.BoneNames[i] = component.Bones[i].name;
            }
            meshDef = skinnedMeshDefinition;
            rend    = meshDef.CreateRenderer(base.gameObject);
            Model.Definition.RenderProperties.Apply(rend);
        }
Exemple #2
0
        public void OnDrawGizmosSelected()
        {
            Transform transform = this.rootBone;

            if (transform == null)
            {
                transform = Rig.FindRootBone(base.gameObject);
            }
            if (transform != null)
            {
                Gizmos.color = Color.red;
                Transform[] componentsInChildren = transform.GetComponentsInChildren <Transform>();
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    Gizmos.DrawLine(componentsInChildren[i].position, componentsInChildren[i].parent.position);
                }
            }
        }
        public override void ApplyMesh(GameObject go, Mesh overrideMesh = null)
        {
            Rig componentInParent = go.GetComponentInParent <Rig>();

            if (BoneNames == null)
            {
                Log.LogErrorFormatted(this, "BoneNames must be set before calling ApplyMesh");
                return;
            }
            if (!componentInParent)
            {
                Log.LogErrorFormatted(this, "Rig component missing");
                return;
            }
            Transform[] array = new Transform[BoneNames.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = componentInParent[BoneNames[i]];
            }
            setSharedMesh(go, (overrideMesh != null) ? overrideMesh : Mesh);
            Transform rootBone = componentInParent[RootBoneName];

            SetBones(go, array, rootBone);
        }
        public override void ApplyMesh(GameObject go, Mesh overrideMesh = null)
        {
            Rig componentInParent = go.GetComponentInParent <Rig>();

            if (this.BoneNames == null)
            {
                Log.LogErrorFormatted(this, "BoneNames must be set before calling ApplyMesh", new object[0]);
            }
            else if (!componentInParent)
            {
                Log.LogErrorFormatted(this, "Rig component missing", new object[0]);
            }
            else
            {
                Transform[] array = new Transform[this.BoneNames.Length];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = componentInParent[this.BoneNames[i]];
                }
                this.setSharedMesh(go, (overrideMesh != null) ? overrideMesh : this.Mesh);
                Transform rootBone = componentInParent[this.RootBoneName];
                this.SetBones(go, array, rootBone);
            }
        }
 protected override void onAwake()
 {
     children = new AvatarViewDistinctChild[Model.RowMax, Model.ColumnMax];
     rig      = GetComponent <Rig>();
 }
Exemple #6
0
 protected override void onAwake()
 {
     this.children = new AvatarViewDistinctChild[this.Model.RowMax, this.Model.ColumnMax];
     this.rig      = base.GetComponent <Rig>();
 }
Exemple #7
0
 public static void SetupSkinnedMeshRenderer(SkinnedMeshRenderer smr)
 {
     smr.rootBone = Rig.FindRootBone(smr.gameObject);
     smr.bones    = Rig.FindBones(smr.rootBone);
 }