예제 #1
0
        ///     2 ------------- 3
        ///   /               /
        ///  1 ------------ 4
        public static GravityOverrideQuad DrawQuadWithBorders(ExtQuad quad, GravityOverrideQuad quadGravity, Color color, out bool hasChanged)
        {
            hasChanged = false;
            bool changed = hasChanged;

            float sizeLine  = quad.LocalScale.magnitude / 35;
            float sizePoint = quad.LocalScale.magnitude / 30;

            Color colorFace = new Color(color.r, color.g, color.b, color.a * 0.5f);
            Color colorLine = new Color(color.r, color.g, color.b, color.a * 0.8f);

            quadGravity.Face1 = DrawQuadFace(quad, quadGravity.Face1, quad.AllowBottom, colorFace, out changed);     hasChanged = (changed) ? true : hasChanged;

            quadGravity.Line1 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line1, quad.P1, quad.P2, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line2 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line2, quad.P2, quad.P3, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line3 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line3, quad.P3, quad.P4, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;
            quadGravity.Line4 = ExtGravityOverrideEditor.DrawLineTrunk(quadGravity.Line4, quad.P4, quad.P1, colorLine, sizeLine, out changed);    hasChanged = (changed) ? true : hasChanged;

            quadGravity.Point1 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point1, quad.P1, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point2 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point2, quad.P2, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point3 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point3, quad.P3, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;
            quadGravity.Point4 = ExtGravityOverrideEditor.DrawPoint(quadGravity.Point4, quad.P4, color, sizePoint, out changed);  hasChanged = (changed) ? true : hasChanged;

            return(quadGravity);
        }
예제 #2
0
        public static GravityOverrideCylinder DrawCylinder(ExtCylinder cylinder, ExtCircle circle1, ExtCircle circle2, GravityOverrideCylinder cylinderGravity, Color color, out bool hasChanged)
        {
            float sizeLine = cylinder.LocalScale.magnitude / 20;

            hasChanged = false;
            bool changed = hasChanged;

            cylinderGravity.Disc1 = ExtGravityOverrideEditor.DrawDisc(circle1, cylinderGravity.Disc1, color, false, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            cylinderGravity.Disc2 = ExtGravityOverrideEditor.DrawDisc(circle2, cylinderGravity.Disc2, color, false, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            cylinderGravity.Trunk = ExtGravityOverrideEditor.DrawLineTrunk(cylinderGravity.Trunk, cylinder.P1, cylinder.P2, new Color(color.r, color.g, color.b, color.a * 0.8f), sizeLine, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            return(cylinderGravity);
        }
예제 #3
0
        public static GravityOverrideLineTopDown DrawLine3d(ExtLine3d line, GravityOverrideLineTopDown lineGravity, Color color, out bool hasChanged)
        {
            float sizeLine  = line.LocalScale.magnitude / 25;
            float sizePoint = line.LocalScale.magnitude / 20;

            hasChanged = false;
            bool changed = hasChanged;

            lineGravity.Trunk  = ExtGravityOverrideEditor.DrawLineTrunk(lineGravity.Trunk, line.P1, line.P2, color, sizeLine, out changed);
            hasChanged         = (changed) ? true : hasChanged;
            lineGravity.Top    = ExtGravityOverrideEditor.DrawPoint(lineGravity.Top, line.P1, color, sizePoint, out changed);
            hasChanged         = (changed) ? true : hasChanged;
            lineGravity.Bottom = ExtGravityOverrideEditor.DrawPoint(lineGravity.Bottom, line.P2, color, sizePoint, out changed);
            hasChanged         = (changed) ? true : hasChanged;
            return(lineGravity);
        }
예제 #4
0
        public static GravityOverrideLineTopDown DrawCapsule(ExtCapsule capsule, GravityOverrideLineTopDown capsuleGravity, Color color, out bool hasChanged)
        {
            float sizeLine  = capsule.LocalScale.magnitude / 25;
            float sizePoint = capsule.LocalScale.magnitude / 20;

            hasChanged = false;
            bool changed = hasChanged;

            capsuleGravity.Trunk  = ExtGravityOverrideEditor.DrawLineTrunk(capsuleGravity.Trunk, capsule.P1, capsule.P2, color, sizeLine, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            capsuleGravity.Top    = ExtGravityOverrideEditor.DrawPoint(capsuleGravity.Top, capsule.P1, color, sizePoint, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            capsuleGravity.Bottom = ExtGravityOverrideEditor.DrawPoint(capsuleGravity.Bottom, capsule.P2, color, sizePoint, out changed);
            hasChanged            = (changed) ? true : hasChanged;
            return(capsuleGravity);
        }
예제 #5
0
        public static GravityOverrideLineTopDown[] DrawPolyLines(ExtPolyLines polyLine, GravityOverrideLineTopDown[] polyLineGravity, Color color, out bool hasChanged)
        {
            float sizeLine  = polyLine.LocalScale.magnitude / 25;
            float sizePoint = polyLine.LocalScale.magnitude / 20;

            hasChanged = false;
            bool changed = hasChanged;

            for (int i = 0; i < polyLineGravity.Length; i++)
            {
                polyLineGravity[i].Trunk = ExtGravityOverrideEditor.DrawLineTrunk(polyLineGravity[i].Trunk, polyLine.LineAt(i).P1, polyLine.LineAt(i).P2, color, sizeLine, out changed);
                hasChanged                = (changed) ? true : hasChanged;
                polyLineGravity[i].Top    = ExtGravityOverrideEditor.DrawPoint(polyLineGravity[i].Top, polyLine.LineAt(i).P1, color, sizePoint, out changed);
                hasChanged                = (changed) ? true : hasChanged;
                polyLineGravity[i].Bottom = ExtGravityOverrideEditor.DrawPoint(polyLineGravity[i].Bottom, polyLine.LineAt(i).P2, color, sizePoint, out changed);
                hasChanged                = (changed) ? true : hasChanged;
            }
            return(polyLineGravity);
        }
예제 #6
0
        /// <summary>
        /// do a custom Line Handle Cap
        /// </summary>
        public static void LineHandleCap(int controlId, Vector3 position, Quaternion rotation, float size, EventType eventType)
        {
            Vector3 sideways = rotation * new Vector3(0, 0, size / 2);
            Vector3 p1       = position - sideways;
            Vector3 p2       = position + sideways;

            switch (eventType)
            {
            case (EventType.Layout):
                float distance = ExtGravityOverrideEditor.DistanceToCylinder(p1, p2, size);
                HandleUtility.AddControl(controlId, distance);
                break;

            case (EventType.Repaint):

                Handles.DrawPolyLine(p1, p2);
                break;
            }
        }
예제 #7
0
        public static GravityOverrideConeSphereBase DrawConeSphereBase(ExtConeSphereBase cone, GravityOverrideConeSphereBase coneGravity, Color color, out bool hasChanged)
        {
            float sizeLine  = cone.LocalScale.magnitude / 20;
            float sizePoint = cone.LocalScale.magnitude / 15;

            hasChanged = false;
            bool changed = hasChanged;

            coneGravity.Base = ExtGravityOverrideEditor.DrawDisc(cone.Base, coneGravity.Base, color, false, out changed);
            hasChanged       = (changed) ? true : hasChanged;

            Color colorLine = new Color(color.r, color.g, color.b, color.a * 0.8f);

            coneGravity.Trunk = ExtGravityOverrideEditor.DrawLineTrunk(coneGravity.Trunk, cone.P1, cone.P2, colorLine, sizeLine, out changed);
            hasChanged        = (changed) ? true : hasChanged;
            coneGravity.Top   = ExtGravityOverrideEditor.DrawPoint(coneGravity.Top, cone.P1, color, sizePoint, out changed);
            hasChanged        = (changed) ? true : hasChanged;


            return(coneGravity);
        }