예제 #1
0
 public ExtPlane3d(Vector3 position, Vector3 normal) : this()
 {
     _position = position;
     _rotation = ExtRotation.QuaternionFromVectorDirector(normal, Vector3.up);
     _rotation = ExtRotation.RotateQuaternion(_rotation, new Vector3(-90, 0, 0));
     UpdateMatrix();
 }
예제 #2
0
        /// <summary>
        /// draw a disc
        /// </summary>
        public static GravityOverrideDisc DrawDisc(ExtCircle circle, GravityOverrideDisc discGravity, Color color, bool allowBottom, out bool hasChanged)
        {
            hasChanged = false;
            Quaternion rotation     = ExtRotation.QuaternionFromVectorDirector(circle.Normal, Vector3.up);
            bool       topFace      = discGravity.Face;
            bool       topExtremity = discGravity.Borders;

            bool isCameraViewBehindFace = Vector3.Dot(ExtSceneView.GetSceneViewCameraTransform().forward, circle.Normal) > 0 && !allowBottom;

            Handles.color = color;
            if (!Event.current.alt && Event.current.button != 2 && Handles.Button(circle.Point,
                                                                                  rotation,
                                                                                  circle.Radius,
                                                                                  circle.Radius, Handles.CircleHandleCap))
            {
                Debug.Log("extremity pressed");
                discGravity.Borders = !discGravity.Borders;
                hasChanged          = true;
                Use();
            }

            if (!topFace)
            {
                Handles.color = (isCameraViewBehindFace) ? new Color(color.r, color.g, color.b, color.a / 2) : color;
                Handles.DrawSolidDisc(circle.Point, circle.Normal, circle.Radius / 10 * 8);
            }
            if (!topExtremity)
            {
                Handles.color = (isCameraViewBehindFace) ? new Color(color.r, color.g, color.b, color.a / 2) : color;
                ExtHandle.DrawCircleThickness(circle, 50, ExtHandle.DrawOutlineType.INSIDE);
            }
            Handles.color = Color.red;

            if (!Event.current.alt && Event.current.button != 2 && Handles.Button(circle.Point,
                                                                                  rotation,
                                                                                  circle.Radius / 10 * 7,
                                                                                  circle.Radius / 10 * 7, Handles.CircleHandleCap))
            {
                if (isCameraViewBehindFace)
                {
                    Debug.Log("not behind face");
                }
                else
                {
                    Debug.Log("Face pressed !");
                    discGravity.Face = !discGravity.Face;
                    hasChanged       = true;
                    Use();
                }
            }

            return(discGravity);
        }
예제 #3
0
        ///     2 ------2------ 3
        ///   1 |             3 |
        ///  1 ------4----- 4   |
        ///  |  |      3    |   |
        ///  | 4|           | 2 |
        ///  |       1      |
        ///  |              |
        ///


        public ExtQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) : this()
        {
            _position = ExtVector3.GetMeanOfXPoints(p1, p2, p3, p4);
            Vector3 x = p1 - p2;
            Vector3 y = p1 - p4;

            Vector3 up = Vector3.Cross(x, y);

            _rotation   = ExtRotation.QuaternionFromVectorDirector(up, x.FastNormalized());
            _rotation   = ExtRotation.RotateQuaternion(_rotation, new Vector3(-90, 0, 0));
            _localScale = new Vector3(y.magnitude, 1, x.magnitude);
            UpdateMatrix();
        }