Exemplo n.º 1
0
        public void InsertVertexAfter(int i, Vector3 origin)
        {
            int j             = (i + 1) * 2;
            int k             = (i + 1) % curve.Points.Length;
            var originalState = curveTangentHandles[(i * 2) + 1].Constraint;
            var tangent       = (curve.Points[i] - curve.Points[k]).normalized;

            var leftTangentCurve = new TangentCurve2D()
            {
                Tangent    = tangent,
                Constraint = originalState
            };
            var rightTangentCurve = new TangentCurve2D()
            {
                Tangent    = -tangent,
                Constraint = originalState
            };

            var handlePointCurve = new HandlePointCurve2D()
            {
                ID      = -1,
                Tangent = false,
                State   = SelectState.Selected
            };

            var leftTangentCurveHandle = new HandleTangentCurve2D()
            {
                ID         = -1,
                State      = SelectState.Selected,
                Constraint = originalState
            };

            var rightTangentCurveHandle = new HandleTangentCurve2D()
            {
                ID         = -1,
                State      = SelectState.Selected,
                Constraint = originalState
            };

            var handleEdgeCurve = new HandleEdgeCurve2D()
            {
                ID       = -1,
                State    = curveEdgeHandles[i].State,
                Material = curveEdgeHandles[i].Material,
                Texgen   = curveEdgeHandles[i].Texgen
            };

            ArrayUtility.Insert(ref curve.Points, i + 1, origin);
            ArrayUtility.Insert(ref curvePointHandles, i + 1, handlePointCurve);
            ArrayUtility.Insert(ref curveEdgeHandles, i + 1, handleEdgeCurve);

            ArrayUtility.Insert(ref curve.Tangents, j, rightTangentCurve);
            ArrayUtility.Insert(ref curve.Tangents, j, leftTangentCurve);
            ArrayUtility.Insert(ref curveTangentHandles, j, rightTangentCurveHandle);
            ArrayUtility.Insert(ref curveTangentHandles, j, leftTangentCurveHandle);

            ArrayUtility.Insert(ref onGeometryVertices, i + 1, onGeometryVertices[i]);
//			ArrayUtility.Insert(ref onPlaneVertices, i + 1, onPlaneVertices[i]);
            ArrayUtility.Insert(ref onBrushVertices, i + 1, onBrushVertices[i]);
        }
Exemplo n.º 2
0
        public void AddVertex(Vector3 position, CSGBrush brush, CSGPlane plane, bool onGeometry)
        {
            if (curve.Points.Length > 1)
            {
                if ((curve.Points[curve.Points.Length - 1] - position).sqrMagnitude < MathConstants.EqualityEpsilonSqr)
                {
                    return;
                }
                if ((curve.Points[0] - position).sqrMagnitude < MathConstants.EqualityEpsilonSqr)
                {
                    return;
                }
            }

            var leftTangentCurve = new TangentCurve2D()
            {
                Tangent    = MathConstants.leftVector3,
                Constraint = HandleConstraints.Straight
            };

            var rightTangentCurve = new TangentCurve2D()
            {
                Tangent    = MathConstants.rightVector3,
                Constraint = HandleConstraints.Straight
            };

            var handlePointCurve = new HandlePointCurve2D()
            {
                ID    = -1,
                State = SelectState.None
            };

            var leftTangentCurveHandle = new HandleTangentCurve2D()
            {
                ID         = -1,
                State      = SelectState.None,
                Constraint = HandleConstraints.Straight
            };

            var rightTangentCurveHandle = new HandleTangentCurve2D()
            {
                ID         = -1,
                State      = SelectState.None,
                Constraint = HandleConstraints.Straight
            };

            var handleEdgeCurve = new HandleEdgeCurve2D()
            {
                ID     = -1,
                State  = SelectState.None,
                Texgen = new TexGen(CSGSettings.DefaultMaterial)
            };

            ArrayUtility.Add(ref curve.Points, position);
            ArrayUtility.Add(ref curvePointHandles, handlePointCurve);
            ArrayUtility.Add(ref curveEdgeHandles, handleEdgeCurve);

            ArrayUtility.Add(ref curve.Tangents, rightTangentCurve);
            ArrayUtility.Add(ref curve.Tangents, leftTangentCurve);
            ArrayUtility.Add(ref curveTangentHandles, rightTangentCurveHandle);
            ArrayUtility.Add(ref curveTangentHandles, leftTangentCurveHandle);

            ArrayUtility.Add(ref onGeometryVertices, onGeometry);
            //           ArrayUtility.Add(ref onPlaneVertices, plane);
            ArrayUtility.Add(ref onBrushVertices, brush);
        }