public static void Setup(GameObject go) { string body = "body"; string[] eyelash = new string[] { "eyelash", "default" }; string head = "head"; string eyeL = "lefteye"; string eyeR = "righteye"; string blinkL = "blink_left"; string blinkR = "blink_right"; if (go) { Eyes eyes = go.GetComponent <Eyes>(); if (eyes == null) { eyes = go.AddComponent <Eyes>(); } else { DestroyImmediate(eyes); eyes = go.AddComponent <Eyes>(); } QueueProcessor qp = go.GetComponent <QueueProcessor>(); if (qp == null) { qp = go.AddComponent <QueueProcessor>(); } // System Properties eyes.characterRoot = go.transform; eyes.queueProcessor = qp; // Heads - Bone_Rotation eyes.BuildHeadTemplate(Eyes.HeadTemplates.Bone_Rotation_XY); eyes.heads[0].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, head); eyes.heads[0].expData.name = "head"; eyes.heads[0].expData.components[0].name = "head"; eyes.headTargetOffset.y = 0.052f; eyes.CaptureMin(ref eyes.heads); eyes.CaptureMax(ref eyes.heads); // Eyes - Bone_Rotation eyes.BuildEyeTemplate(Eyes.EyeTemplates.Bone_Rotation); eyes.eyes[0].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, eyeL); eyes.eyes[0].expData.name = "eyeL"; eyes.eyes[0].expData.components[0].name = "eyeL"; eyes.eyes[1].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, eyeR); eyes.eyes[1].expData.name = "eyeR"; eyes.eyes[1].expData.components[0].name = "eyeR"; eyes.CaptureMin(ref eyes.eyes); eyes.CaptureMax(ref eyes.eyes); // Blinklids - Bone_Rotation eyes.BuildEyelidTemplate(Eyes.EyelidTemplates.BlendShapes, Eyes.EyelidSelection.Upper); // includes left/right eyelid eyes.AddEyelidShapeExpression(ref eyes.blinklids); // add eyelash left eyes.AddEyelidShapeExpression(ref eyes.blinklids); // add eyelash right float blinkMax = 0.75f; // Left eyelid eyes.blinklids[0].expData.controllerVars[0].smr = Eyes.FindTransform(eyes.characterRoot, body).GetComponent <SkinnedMeshRenderer>(); eyes.blinklids[0].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[0].expData.controllerVars[0].smr, blinkL); eyes.blinklids[0].expData.controllerVars[0].maxShape = blinkMax; eyes.blinklids[0].expData.name = "eyelidL"; // Right eyelid eyes.blinklids[1].expData.controllerVars[0].smr = eyes.blinklids[0].expData.controllerVars[0].smr; eyes.blinklids[1].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[1].expData.controllerVars[0].smr, blinkR); eyes.blinklids[1].expData.controllerVars[0].maxShape = blinkMax; eyes.blinklids[1].expData.name = "eyelidR"; // Left eyelash eyes.blinklids[2].expData.controllerVars[0].smr = Eyes.FindTransform(eyes.characterRoot, eyelash).GetComponent <SkinnedMeshRenderer>(); eyes.blinklids[2].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[2].expData.controllerVars[0].smr, blinkL); eyes.blinklids[2].expData.controllerVars[0].maxShape = blinkMax; eyes.blinklids[2].expData.name = "eyelashL"; // Right eyelash eyes.blinklids[3].expData.controllerVars[0].smr = eyes.blinklids[2].expData.controllerVars[0].smr; eyes.blinklids[3].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[3].expData.controllerVars[0].smr, blinkR); eyes.blinklids[3].expData.controllerVars[0].maxShape = blinkMax; eyes.blinklids[3].expData.name = "eyelashR"; // Tracklids eyes.CopyBlinkToTrack(); // Set track eye index eyes.tracklids[0].referenceIdx = 0; // left eyes.tracklids[1].referenceIdx = 1; // right eyes.tracklids[2].referenceIdx = 0; // left eyes.tracklids[3].referenceIdx = 1; // right // Initialize the Eyes module eyes.Initialize(); } }
public static void Setup(GameObject go) { string head = "boxHead.v2"; if (go) { Eyes eyes = go.GetComponent <Eyes>(); if (eyes == null) { eyes = go.AddComponent <Eyes>(); } else { DestroyImmediate(eyes); eyes = go.AddComponent <Eyes>(); } QueueProcessor qp = go.GetComponent <QueueProcessor>(); if (qp == null) { qp = go.AddComponent <QueueProcessor>(); } // System properties eyes.characterRoot = go.transform; eyes.queueProcessor = qp; // Heads - Bone_Rotation eyes.BuildHeadTemplate(Eyes.HeadTemplates.Bone_Rotation_XY); eyes.heads[0].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, head); eyes.heads[0].expData.name = "head"; eyes.heads[0].expData.components[0].name = "head"; if (go.name.Contains("small")) { eyes.headTargetOffset.y = 0.225f; } else { eyes.headTargetOffset.y = 1.4f; eyes.headRandDistRange = new Vector2(3f, 3f); eyes.headTargetRadius = 0.05f; } eyes.CaptureMin(ref eyes.heads); eyes.CaptureMax(ref eyes.heads); // Eyes - Blendshapes SkinnedMeshRenderer smr = Eyes.FindTransform(eyes.characterRoot, head).GetComponent <SkinnedMeshRenderer>(); eyes.BuildEyeTemplate(Eyes.EyeTemplates.BlendShapes); eyes.RemoveExpression(ref eyes.eyes, 1); eyes.eyes[0].expData.controllerVars[0].smr = smr; eyes.eyes[0].expData.controllerVars[0].blendIndex = 4; eyes.eyes[0].expData.controllerVars[1].smr = smr; eyes.eyes[0].expData.controllerVars[1].blendIndex = 7; eyes.eyes[0].expData.controllerVars[2].smr = smr; eyes.eyes[0].expData.controllerVars[2].blendIndex = 5; eyes.eyes[0].expData.controllerVars[3].smr = smr; eyes.eyes[0].expData.controllerVars[3].blendIndex = 6; if (go.GetComponentInChildren <EyeGizmo>() != null) { DestroyImmediate(go.GetComponentInChildren <EyeGizmo>().gameObject); } eyes.eyes[0].gizmo = eyes.CreateEyeGizmo(smr.name, eyes.characterRoot); eyes.eyes[0].gizmo.transform.parent = smr.transform; if (go.name.Contains("small")) { eyes.eyes[0].gizmo.transform.localPosition = new Vector3(0f, 0.2239f, 0.1624f); } else { eyes.eyes[0].gizmo.transform.localPosition = new Vector3(0f, 1.378f, 1.037f); eyes.eyeRandTrackFov = new Vector3(0.4f, 0.2f, 0f); eyes.eyeRandDistRange = new Vector2(3f, 3f); eyes.eyeTargetRadius = 0.05f; } // Eyelids - Blendshapes eyes.BuildEyelidTemplate(Eyes.EyelidTemplates.BlendShapes, Eyes.EyelidSelection.Upper); eyes.RemoveExpression(ref eyes.blinklids, 1); eyes.blinklids[0].expData.controllerVars[0].smr = smr; eyes.blinklids[0].expData.controllerVars[0].blendIndex = 8; // Add a parent if the character root matches the head bone if (go.transform.parent == null) { eyes.characterRoot = eyes.AddParent(go.transform); } else { eyes.characterRoot = go.transform.parent; } // if (eyes.characterRoot == eyes.heads[0].expData.controllerVars[0].bone) // Initialize the Eyes moduel eyes.Initialize(); } }
public static void Setup(GameObject go, int lod) { string head = "head"; string eyeL = "lefteye"; string eyeR = "righteye"; string body = "body"; string blinkL = "^.*reyeclose.*$"; string blinkR = "^.*leyeclose.*$"; if (go) { Eyes eyes = go.GetComponent <Eyes>(); if (eyes == null) { eyes = go.AddComponent <Eyes>(); } else { DestroyImmediate(eyes); eyes = go.AddComponent <Eyes>(); } QueueProcessor qp = go.GetComponent <QueueProcessor>(); if (qp == null) { qp = go.AddComponent <QueueProcessor>(); } // System Properties eyes.characterRoot = go.transform; eyes.queueProcessor = qp; // Heads - Bone_Rotation eyes.BuildHeadTemplate(Eyes.HeadTemplates.Bone_Rotation_XY); eyes.heads[0].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, head); eyes.headTargetOffset.y = 0.052f; eyes.FixAllTransformAxes(ref eyes.heads, false); eyes.FixAllTransformAxes(ref eyes.heads, true); // Eyes - Bone_Rotation eyes.BuildEyeTemplate(Eyes.EyeTemplates.Bone_Rotation); eyes.eyes[0].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, eyeL); eyes.eyes[1].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, eyeR); eyes.FixAllTransformAxes(ref eyes.eyes, false); eyes.FixAllTransformAxes(ref eyes.eyes, true); // Eyelids - Bone_Rotation eyes.BuildEyelidTemplate(Eyes.EyelidTemplates.BlendShapes); // includes left/right eyelid eyes.SetEyelidShapeSelection(Eyes.EyelidSelection.Upper); float blinkMax = 1f; switch (lod) { case 0: // Crowd body = "^h_dds_.*crowd.*$"; break; case 1: // low body = "^h_dds_.*low.*$"; break; case 2: // mid body = "^h_dds_.*mid.*$"; break; case 3: // high body = "^h_dds_.*high.*$"; break; } // Left eyelid eyes.eyelids[0].referenceIdx = 0; eyes.eyelids[0].expData.controllerVars[0].smr = FindTransform(eyes.characterRoot, body).GetComponent <SkinnedMeshRenderer>(); eyes.eyelids[0].expData.controllerVars[0].blendIndex = FindBlendIdx(eyes.eyelids[0].expData.controllerVars[0].smr, blinkL); eyes.eyelids[0].expData.controllerVars[0].maxShape = blinkMax; // Right eyelid eyes.eyelids[1].referenceIdx = 1; eyes.eyelids[1].expData.controllerVars[0].smr = eyes.eyelids[0].expData.controllerVars[0].smr; eyes.eyelids[1].expData.controllerVars[0].blendIndex = FindBlendIdx(eyes.eyelids[1].expData.controllerVars[0].smr, blinkR); eyes.eyelids[1].expData.controllerVars[0].maxShape = blinkMax; // Initialize the Eyes module eyes.Initialize(); } }