コード例 #1
0
    private float AngleVRateCalc()
    {
        if (this.eyeObjs[0] == null)
        {
            return(0.0f);
        }
        EyeTypeState_Ver2 eyeTypeState = this.eyeTypeStates[this.nowPtnNo];

        return((double)eyeTypeState.downBendingAngle <= (double)eyeTypeState.upBendingAngle ? (0.0 <= (double)this.eyeObjs[0].angleV ? -Mathf.InverseLerp(0.0f, eyeTypeState.upBendingAngle, this.eyeObjs[0].angleV) : Mathf.InverseLerp(0.0f, eyeTypeState.downBendingAngle, this.eyeObjs[0].angleV)) : (0.0 <= (double)this.eyeObjs[0].angleV ? -Mathf.InverseLerp(0.0f, eyeTypeState.downBendingAngle, this.eyeObjs[0].angleV) : Mathf.InverseLerp(0.0f, eyeTypeState.upBendingAngle, this.eyeObjs[0].angleV)));
    }
コード例 #2
0
    private void OnDrawGizmos()
    {
        Transform transform = this.calcRootNode ?? this.objRootNode;

        if (!this.isDebugDraw || !Object.op_Implicit((Object)transform))
        {
            Gizmos.set_color(Color.get_white());
        }
        else
        {
            if (0 < this.eyeTypeStates.Length)
            {
                if (this.ptnDraw < 0)
                {
                    this.ptnDraw = 0;
                }
                else if (this.eyeTypeStates.Length <= this.ptnDraw)
                {
                    this.ptnDraw = this.eyeTypeStates.Length - 1;
                }
                Gizmos.set_color(new Color(1f, 1f, 1f, 0.8f));
                EyeTypeState_Ver2 eyeTypeState = this.eyeTypeStates[this.ptnDraw];
                Gizmos.set_color(new Color(0.0f, 1f, 1f, 0.8f));
                Vector3 position1 = transform.get_position();
                Vector3 vector3_1 = Vector3.op_Addition(transform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(0.0f, eyeTypeState.hAngleLimit, 0.0f), Vector3.get_forward()), this.drawLineLength)), position1);
                Vector3 vector3_2 = Vector3.op_Addition(transform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(0.0f, -eyeTypeState.hAngleLimit, 0.0f), Vector3.get_forward()), this.drawLineLength)), position1);
                Vector3 vector3_3 = Vector3.op_Addition(transform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(eyeTypeState.vAngleLimit, 0.0f, 0.0f), Vector3.get_forward()), this.drawLineLength)), position1);
                Vector3 vector3_4 = Vector3.op_Addition(transform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(-eyeTypeState.vAngleLimit, 0.0f, 0.0f), Vector3.get_forward()), this.drawLineLength)), position1);
                Gizmos.DrawLine(position1, vector3_1);
                Gizmos.DrawLine(position1, vector3_2);
                Gizmos.DrawLine(position1, vector3_3);
                Gizmos.DrawLine(position1, vector3_4);
                Gizmos.DrawLine(vector3_1, vector3_4);
                Gizmos.DrawLine(vector3_4, vector3_2);
                Gizmos.DrawLine(vector3_2, vector3_3);
                Gizmos.DrawLine(vector3_3, vector3_1);
                Gizmos.set_color(new Color(1f, 0.0f, 1f, 0.8f));
                for (int index = 0; index < this.eyeObjs.Length; ++index)
                {
                    Vector3 position2 = this.eyeObjs[index].eyeTransform.get_position();
                    Vector3 vector3_5 = Vector3.op_Addition(this.eyeObjs[index].eyeTransform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(0.0f, eyeTypeState.inBendingAngle * (float)this.eyeObjs[index].eyeLR, 0.0f), Vector3.get_forward()), this.drawLineLength)), position2);
                    Vector3 vector3_6 = Vector3.op_Addition(this.eyeObjs[index].eyeTransform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(0.0f, eyeTypeState.outBendingAngle * (float)this.eyeObjs[index].eyeLR, 0.0f), Vector3.get_forward()), this.drawLineLength)), position2);
                    Vector3 vector3_7 = Vector3.op_Addition(this.eyeObjs[index].eyeTransform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(eyeTypeState.upBendingAngle, 0.0f, 0.0f), Vector3.get_forward()), this.drawLineLength)), position2);
                    Vector3 vector3_8 = Vector3.op_Addition(this.eyeObjs[index].eyeTransform.TransformDirection(Vector3.op_Multiply(Quaternion.op_Multiply(Quaternion.Euler(eyeTypeState.downBendingAngle, 0.0f, 0.0f), Vector3.get_forward()), this.drawLineLength)), position2);
                    Gizmos.DrawLine(position2, vector3_5);
                    Gizmos.DrawLine(position2, vector3_6);
                    Gizmos.DrawLine(position2, vector3_7);
                    Gizmos.DrawLine(position2, vector3_8);
                    Gizmos.DrawLine(vector3_5, vector3_8);
                    Gizmos.DrawLine(vector3_8, vector3_6);
                    Gizmos.DrawLine(vector3_6, vector3_7);
                    Gizmos.DrawLine(vector3_7, vector3_5);
                }
            }
            Gizmos.set_color(new Color(1f, 1f, 0.0f, 0.8f));
            for (int index = 0; index < this.eyeObjs.Length; ++index)
            {
                Vector3 position = this.eyeObjs[index].eyeTransform.get_position();
                Gizmos.DrawLine(position, Vector3.op_Addition(position, Vector3.op_Multiply(this.eyeObjs[index].eyeTransform.get_forward(), this.drawLineLength)));
            }
            Gizmos.set_color(Color.get_white());
        }
    }
コード例 #3
0
 private void EyeUpdateCalc(Vector3 _target, int _ptnNo)
 {
     if (!this.initEnd)
     {
         if (!Object.op_Inequality((Object)this.targetObj, (Object)null) || !this.targetObj.get_activeSelf())
         {
             return;
         }
         this.targetObj.SetActive(false);
     }
     else
     {
         this.nowPtnNo = _ptnNo;
         if (!EyeLookControllerVer2.isEnabled || (double)Time.get_deltaTime() == 0.0)
         {
             if (!Object.op_Inequality((Object)this.targetObj, (Object)null) || !this.targetObj.get_activeSelf())
             {
                 return;
             }
             this.targetObj.SetActive(false);
         }
         else
         {
             EyeTypeState_Ver2  eyeTypeState    = this.eyeTypeStates[_ptnNo];
             EYE_LOOK_TYPE_VER2 eyeLookTypeVeR2 = this.eyeTypeStates[_ptnNo].lookType;
             Transform          calcRootNodeRef = this.calcRootNodeRef;
             if (eyeLookTypeVeR2 == EYE_LOOK_TYPE_VER2.NO_LOOK)
             {
                 this.eyeObjs[0].eyeTransform.set_localRotation(this.fixAngle[0]);
                 this.eyeObjs[1].eyeTransform.set_localRotation(this.fixAngle[1]);
                 if (!Object.op_Inequality((Object)this.targetObj, (Object)null) || !this.targetObj.get_activeSelf())
                 {
                     return;
                 }
                 this.targetObj.SetActive(false);
             }
             else
             {
                 Vector3 vector3_1 = calcRootNodeRef.InverseTransformPoint(_target);
                 if ((double)((Vector3) ref vector3_1).get_magnitude() < (double)this.eyeTypeStates[_ptnNo].nearDis)
                 {
                     vector3_1 = Vector3.op_Multiply(((Vector3) ref vector3_1).get_normalized(), this.eyeTypeStates[_ptnNo].nearDis);
                     _target   = calcRootNodeRef.TransformPoint(vector3_1);
                 }
                 Vector3 vector3_2;
                 ((Vector3) ref vector3_2).\u002Ector((float)vector3_1.x, 0.0f, (float)vector3_1.z);
                 float num1 = Vector3.Dot(vector3_2, Vector3.get_forward());
                 float num2 = Vector3.Angle(vector3_2, Vector3.get_forward());
                 ((Vector3) ref vector3_2).\u002Ector(0.0f, (float)vector3_1.y, (float)vector3_1.z);
                 float num3 = Vector3.Dot(vector3_2, Vector3.get_forward());
                 float num4 = Vector3.Angle(vector3_2, Vector3.get_forward());
                 if ((double)num1 < 0.0 || (double)num3 < 0.0 || ((double)this.eyeTypeStates[_ptnNo].hAngleLimit < (double)num2 || (double)this.eyeTypeStates[_ptnNo].vAngleLimit < (double)num4))
                 {
                     eyeLookTypeVeR2 = EYE_LOOK_TYPE_VER2.FORWARD;
                 }
                 if (eyeLookTypeVeR2 == EYE_LOOK_TYPE_VER2.FORWARD)
                 {
                     _target = Vector3.op_Addition(calcRootNodeRef.get_position(), Vector3.op_Multiply(this.originRootNode.get_forward(), this.eyeTypeStates[_ptnNo].frontTagDis));
                 }
                 if (eyeLookTypeVeR2 == EYE_LOOK_TYPE_VER2.CONTROL || this.eyeTypeStates[_ptnNo].lookType == EYE_LOOK_TYPE_VER2.CONTROL)
                 {
                     if (Object.op_Inequality((Object)this.targetObj, (Object)null))
                     {
                         if (!this.targetObj.get_activeSelf())
                         {
                             this.targetObj.SetActive(true);
                         }
                         _target = Vector3.MoveTowards(((Component)calcRootNodeRef).get_transform().get_position(), this.targetObj.get_transform().get_position(), this.eyeTypeStates[_ptnNo].frontTagDis);
                         this.targetObj.get_transform().set_position(Vector3.MoveTowards(((Component)calcRootNodeRef).get_transform().get_position(), _target, 0.5f));
                     }
                 }
                 else if (Object.op_Inequality((Object)this.targetObj, (Object)null))
                 {
                     this.targetObj.get_transform().set_position(Vector3.MoveTowards(((Component)calcRootNodeRef).get_transform().get_position(), _target, 0.5f));
                     if (this.targetObj.get_activeSelf())
                     {
                         this.targetObj.SetActive(false);
                     }
                 }
                 float num5 = -1f;
                 foreach (EyeObject_Ver2 eyeObj in this.eyeObjs)
                 {
                     eyeObj.eyeTransform.set_localRotation(eyeObj.origRotation);
                     Quaternion rotation    = eyeObj.eyeTransform.get_parent().get_rotation();
                     Quaternion quaternion1 = Quaternion.Inverse(rotation);
                     Vector3    vector3_3   = Vector3.op_Subtraction(_target, eyeObj.eyeTransform.get_position());
                     Vector3    normalized  = ((Vector3) ref vector3_3).get_normalized();
                     Vector3    _dirB       = Quaternion.op_Multiply(quaternion1, normalized);
                     float      num6        = this.AngleAroundAxis(eyeObj.referenceLookDir, _dirB, eyeObj.referenceUpDir);
                     Vector3    _axis       = Vector3.Cross(eyeObj.referenceUpDir, _dirB);
                     float      num7        = this.AngleAroundAxis(Vector3.op_Subtraction(_dirB, Vector3.Project(_dirB, eyeObj.referenceUpDir)), _dirB, _axis);
                     float      num8        = Mathf.Max(0.0f, Mathf.Abs(num6) - eyeTypeState.thresholdAngleDifference) * Mathf.Sign(num6);
                     float      num9        = Mathf.Max(0.0f, Mathf.Abs(num7) - eyeTypeState.thresholdAngleDifference) * Mathf.Sign(num7);
                     float      num10       = Mathf.Max(Mathf.Abs(num8) * Mathf.Abs(eyeTypeState.bendingMultiplier), Mathf.Abs(num6) - eyeTypeState.maxAngleDifference) * Mathf.Sign(num6) * Mathf.Sign(eyeTypeState.bendingMultiplier);
                     float      num11       = Mathf.Max(Mathf.Abs(num9) * Mathf.Abs(eyeTypeState.bendingMultiplier), Mathf.Abs(num7) - eyeTypeState.maxAngleDifference) * Mathf.Sign(num7) * Mathf.Sign(eyeTypeState.bendingMultiplier);
                     float      num12       = eyeObj.eyeLR != EYE_LR_VER2.EYE_L ? -eyeTypeState.inBendingAngle : eyeTypeState.outBendingAngle;
                     float      num13       = eyeObj.eyeLR != EYE_LR_VER2.EYE_L ? -eyeTypeState.outBendingAngle : eyeTypeState.inBendingAngle;
                     float      num14       = Mathf.Clamp(num10, num13, num12);
                     float      num15       = Mathf.Clamp(num11, eyeTypeState.upBendingAngle, eyeTypeState.downBendingAngle);
                     Vector3    vector3_4   = Vector3.Cross(eyeObj.referenceUpDir, eyeObj.referenceLookDir);
                     if (eyeLookTypeVeR2 == EYE_LOOK_TYPE_VER2.AWAY)
                     {
                         if ((double)num5 == -1.0)
                         {
                             float num16 = Mathf.Lerp(-1f, 1f, Mathf.InverseLerp(-this.eyeTypeStates[this.nowPtnNo].outBendingAngle, -this.eyeTypeStates[this.nowPtnNo].inBendingAngle, eyeObj.angleH));
                             float num17 = Mathf.Lerp(-1f, 1f, Mathf.InverseLerp(-this.eyeTypeStates[this.nowPtnNo].outBendingAngle, -this.eyeTypeStates[this.nowPtnNo].inBendingAngle, num14));
                             float num18 = num16 - num17;
                             if ((double)Mathf.Abs(num18) < (double)this.awayRate)
                             {
                                 num5  = Mathf.InverseLerp(-1f, 1f, (double)num18 >= 0.0 ? (0.0 >= (double)num18 ? num17 + this.awayRate : ((double)this.awayRate >= (double)num17 ? num17 + this.awayRate : num17 - this.awayRate)) : ((double)num17 >= -(double)this.awayRate ? num17 - this.awayRate : num17 + this.awayRate));
                                 num14 = Mathf.Lerp(-this.eyeTypeStates[this.nowPtnNo].outBendingAngle, -this.eyeTypeStates[this.nowPtnNo].inBendingAngle, num5);
                             }
                             else
                             {
                                 num5  = Mathf.InverseLerp(-1f, 1f, num16);
                                 num14 = eyeObj.angleH;
                             }
                         }
                         else
                         {
                             num14 = Mathf.Lerp(-this.eyeTypeStates[this.nowPtnNo].outBendingAngle, -this.eyeTypeStates[this.nowPtnNo].inBendingAngle, num5);
                         }
                         num15 = -num15;
                     }
                     eyeObj.angleH = Mathf.Lerp(eyeObj.angleH, num14, Time.get_deltaTime() * eyeTypeState.leapSpeed);
                     eyeObj.angleV = Mathf.Lerp(eyeObj.angleV, num15, Time.get_deltaTime() * eyeTypeState.leapSpeed);
                     _dirB         = Quaternion.op_Multiply(Quaternion.op_Multiply(Quaternion.AngleAxis(eyeObj.angleH, eyeObj.referenceUpDir), Quaternion.AngleAxis(eyeObj.angleV, vector3_4)), eyeObj.referenceLookDir);
                     Vector3 referenceUpDir = eyeObj.referenceUpDir;
                     Vector3.OrthoNormalize(ref _dirB, ref referenceUpDir);
                     Vector3 vector3_5 = _dirB;
                     eyeObj.dirUp = Vector3.Slerp(eyeObj.dirUp, referenceUpDir, Time.get_deltaTime());
                     Vector3.OrthoNormalize(ref vector3_5, ref eyeObj.dirUp);
                     Quaternion quaternion2 = Quaternion.op_Multiply(Quaternion.op_Multiply(rotation, Quaternion.LookRotation(vector3_5, eyeObj.dirUp)), Quaternion.Inverse(Quaternion.op_Multiply(rotation, Quaternion.LookRotation(eyeObj.referenceLookDir, eyeObj.referenceUpDir))));
                     eyeObj.eyeTransform.set_rotation(Quaternion.op_Multiply(quaternion2, eyeObj.eyeTransform.get_rotation()));
                 }
                 this.targetPos   = _target;
                 this.fixAngle[0] = this.eyeObjs[0].eyeTransform.get_localRotation();
                 this.fixAngle[1] = this.eyeObjs[1].eyeTransform.get_localRotation();
                 this.AngleHRateCalc();
                 this.angleVRate = this.AngleVRateCalc();
             }
         }
     }
 }