Esempio n. 1
0
 private static void DrawPointLight(Quaternion _rotation, Vector3 _position, float _radius)
 {
     Vector3[] vector3Array = new Vector3[3]
     {
         Quaternion.op_Multiply(_rotation, Vector3.get_right()),
         Quaternion.op_Multiply(_rotation, Vector3.get_up()),
         Quaternion.op_Multiply(_rotation, Vector3.get_forward())
     };
     if (Camera.get_current().get_orthographic())
     {
         Vector3 forward = ((Component)Camera.get_current()).get_transform().get_forward();
         LightLine.DrawWireDisc(_position, forward, _radius);
         for (int index = 0; index < 3; ++index)
         {
             Vector3 vector3    = Vector3.Cross(vector3Array[index], forward);
             Vector3 normalized = ((Vector3) ref vector3).get_normalized();
             LightLine.DrawTwoShadedWireDisc(_position, vector3Array[index], normalized, 180f, _radius);
         }
     }
     else
     {
         Vector3 _normal      = Vector3.op_Subtraction(_position, ((Component)Camera.get_current()).get_transform().get_position());
         float   sqrMagnitude = ((Vector3) ref _normal).get_sqrMagnitude();
         float   num1         = _radius * _radius;
         float   num2         = num1 * num1 / sqrMagnitude;
         float   num3         = num2 / num1;
         if ((double)num3 < 1.0)
         {
             LightLine.DrawWireDisc(Vector3.op_Subtraction(_position, Vector3.op_Division(Vector3.op_Multiply(num1, _normal), sqrMagnitude)), _normal, Mathf.Sqrt(num1 - num2));
         }
         for (int index = 0; index < 3; ++index)
         {
             if ((double)num3 < 1.0)
             {
                 float num4 = Vector3.Angle(_normal, vector3Array[index]);
                 float num5 = Mathf.Tan((90f - Mathf.Min(num4, 180f - num4)) * ((float)Math.PI / 180f));
                 float num6 = Mathf.Sqrt(num2 + num5 * num5 * num2) / _radius;
                 if ((double)num6 < 1.0)
                 {
                     float   num7       = Mathf.Asin(num6) * 57.29578f;
                     Vector3 vector3    = Vector3.Cross(vector3Array[index], _normal);
                     Vector3 normalized = ((Vector3) ref vector3).get_normalized();
                     Vector3 _from      = Quaternion.op_Multiply(Quaternion.AngleAxis(num7, vector3Array[index]), normalized);
                     LightLine.DrawTwoShadedWireDisc(_position, vector3Array[index], _from, (float)((90.0 - (double)num7) * 2.0), _radius);
                 }
                 else
                 {
                     LightLine.DrawTwoShadedWireDisc(_position, vector3Array[index], _radius);
                 }
             }
             else
             {
                 LightLine.DrawTwoShadedWireDisc(_position, vector3Array[index], _radius);
             }
         }
     }
 }
Esempio n. 2
0
        private static void DrawSpotLight(
            Quaternion _rotation,
            Vector3 _position,
            float _angle,
            float _range,
            float _angleScale,
            float _rangeScale)
        {
            float   num       = _range * _rangeScale;
            float   _radius   = num * Mathf.Tan((float)(Math.PI / 180.0 * (double)_angle / 2.0)) * _angleScale;
            Vector3 _normal   = Quaternion.op_Multiply(_rotation, Vector3.get_forward());
            Vector3 vector3_1 = Quaternion.op_Multiply(_rotation, Vector3.get_up());
            Vector3 vector3_2 = Quaternion.op_Multiply(_rotation, Vector3.get_right());

            LightLine.DrawLine(_position, Vector3.op_Addition(Vector3.op_Addition(_position, Vector3.op_Multiply(_normal, num)), Vector3.op_Multiply(vector3_1, _radius)));
            LightLine.DrawLine(_position, Vector3.op_Subtraction(Vector3.op_Addition(_position, Vector3.op_Multiply(_normal, num)), Vector3.op_Multiply(vector3_1, _radius)));
            LightLine.DrawLine(_position, Vector3.op_Addition(Vector3.op_Addition(_position, Vector3.op_Multiply(_normal, num)), Vector3.op_Multiply(vector3_2, _radius)));
            LightLine.DrawLine(_position, Vector3.op_Subtraction(Vector3.op_Addition(_position, Vector3.op_Multiply(_normal, num)), Vector3.op_Multiply(vector3_2, _radius)));
            LightLine.DrawWireDisc(Vector3.op_Addition(_position, Vector3.op_Multiply(num, _normal)), _normal, _radius);
        }