예제 #1
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Repeaters/Radial Repeater")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("RadialRepeater");
         * }
         */

        public override void drawBoundsHandles(Matrix4x4 consumerM, bool forceDraw = false)
        {
            base.drawBoundsHandles(consumerM, forceDraw);

            RadialRepeaterTool radialRepeaterTool = (generator as RadialRepeater).repeaterToolU as RadialRepeaterTool;

            Matrix4x4 prevHandleMatrix = Handles.matrix;

            float depth = .55f * HandleUtility.GetHandleSize(Vector3.zero);

            Matrix4x4 context = Matrix4x4.TRS(new Vector3(0, -depth, 0), Quaternion.identity, Vector3.one) * parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;

            Handles.matrix = context;

            if (radialRepeaterTool != null)
            {
                // REPEATER TOOL HANDLER
                GeneratorHandler gh = getGeneratorHandler(radialRepeaterTool.parametricObject);

                if (gh != null)
                {
                    //Handles.matrix *= Matrix4x4.TRS(new Vector3(parametricObject.bounds.extents.x, radialRepeaterTool.size/2, 0), Quaternion.Euler(0, 0, 90), Vector3.one);
                    gh.drawBoundsHandles(consumerM * parametricObject.getAxisRotationMatrix() * parametricObject.getLocalAlignMatrix(), true);

                    List <string> visited = new List <string>();
                    gh.drawControlHandles(ref visited, consumerM * parametricObject.getAxisRotationMatrix() * parametricObject.getLocalAlignMatrix(), true);
                }
            }

            Handles.matrix = prevHandleMatrix;
        }
예제 #2
0
        public override void drawBoundsHandles(Matrix4x4 consumerM, bool forceDraw = false)
        {
            RadialRepeaterTool gener = generator as RadialRepeaterTool;


            Matrix4x4 prevHandlesMatrix = Handles.matrix;



            float y = .5f * HandleUtility.GetHandleSize(Vector3.zero);

            Handles.matrix *= Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, Vector3.one);

            Vector3 pos;

            Color lightLineColor = new Color(1, .8f, .6f, .7f);
            Color brightOrange   = new Color(1, .5f, 0, .9f);


            // RADIUS //

            Handles.color = brightOrange;

            Handles.DrawLine(new Vector3(gener.radius, y, 0), new Vector3(gener.radius, -y, 0));
            Handles.DrawLine(new Vector3(0, 0, 0), new Vector3(0, -y, 0));

            Handles.DrawLine(new Vector3(0, -y * .66f, 0), new Vector3(gener.radius, -y * .66f, 0));

            // RADIUS LABEL
            GUIStyle labelStyle = new GUIStyle();

            labelStyle.alignment        = TextAnchor.MiddleCenter;
            labelStyle.normal.textColor = Color.white;

            Handles.Label(new Vector3(gener.radius / 2, -y, 0), "rad=" + System.Math.Round(gener.radius, 2), labelStyle);


            // RADIUS HANDLE
            pos = new Vector3(gener.radius, 0, 0);
            EditorGUI.BeginChangeCheck();
            pos = Handles.FreeMoveHandle(
                pos,
                Quaternion.identity,
                .15f * HandleUtility.GetHandleSize(pos),
                Vector3.zero,
                Handles.SphereCap
                );
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "Radius");
                //.parametricObject.setAltered();
                gener.P_Radius.initiateRipple_setFloatValueFromGUIChange(pos.x);
                gener.parametricObject.model.isAltered(23);

                if (generator.P_Output != null && generator.P_Output.Dependents != null)
                {
                    for (int i = 0; i < generator.P_Output.Dependents.Count; i++)
                    {
                        generator.P_Output.Dependents [i].parametricObject.generator.adjustWorldMatrices();
                    }
                }
            }



            Handles.color = new Color(1, .8f, .6f, .05f);

            Handles.DrawSolidArc(Vector3.zero,
                                 Vector3.up,
                                 Vector2.right,
                                 -gener.size,
                                 gener.radius);

            Handles.DrawSolidArc(Vector3.zero,
                                 Vector3.up,
                                 Vector2.right,
                                 -gener.actualBay,
                                 gener.radius / 2);


            Handles.color = lightLineColor;
            Handles.DrawLine(new Vector3(0, 0, 0), new Vector3(gener.radius, 0, 0));



            Handles.DrawWireArc(Vector3.zero,
                                Vector3.up,
                                Vector2.right,
                                360,
                                gener.radius);



            // BAY ANGLE SWEEP
            Handles.color = new Color(0, .5f, 1f, .1f);

            Quaternion rotb = Quaternion.Euler(0, 360 - gener.bay, 0);

            EditorGUI.BeginChangeCheck();
            rotb = Handles.Disc(rotb, Vector3.zero, Vector3.up, gener.radius / 2, false, 1);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "RadialRepeat Total Angle");

                gener.P_Bay.initiateRipple_setFloatValueFromGUIChange(360 - rotb.eulerAngles.y);

                gener.parametricObject.model.isAltered(23);
                for (int i = 0; i < generator.P_Output.Dependents.Count; i++)
                {
                    generator.P_Output.Dependents [i].parametricObject.generator.adjustWorldMatrices();
                }
            }



            // TOTAL ANGLE SWEEP DISC
            Handles.color = new Color(1, .5f, 0f, 1f);

            Quaternion rot = Quaternion.Euler(0, 360 - gener.size, 0);

            EditorGUI.BeginChangeCheck();

            rot = Handles.Disc(rot, Vector3.zero, Vector3.up, gener.radius * .9f, false, 1);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "Lathe SweepAngle");

                gener.P_Size.initiateRipple_setFloatValueFromGUIChange(360 - rot.eulerAngles.y);

                gener.parametricObject.model.isAltered(30);
                for (int i = 0; i < generator.P_Output.Dependents.Count; i++)
                {
                    generator.P_Output.Dependents [i].parametricObject.generator.adjustWorldMatrices();
                }
            }



            Matrix4x4 pushM = Handles.matrix;

            Matrix4x4 deltaM = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 360 - gener.actualBay, 0), Vector3.one);

            for (int i = 0; i < gener.cells; i++)
            {
                Handles.matrix *= deltaM;

                if (i == 0)
                {
                    Handles.color = lightLineColor;
                    Handles.DrawLine(new Vector3(0, 0, 0), new Vector3(gener.radius / 2, 0, 0));

                    Handles.color = brightOrange;
                    Handles.DrawLine(new Vector3(gener.radius / 2 - .5f, 0, 0), new Vector3(gener.radius / 2 + .5f, 0, 0));

                    Handles.SphereCap(0,
                                      new Vector3(gener.radius / 2, 0, 0),
                                      Quaternion.identity,
                                      .15f * HandleUtility.GetHandleSize(pos));
                }
                Handles.DrawLine(new Vector3(gener.radius - .5f, 0, 0), new Vector3(gener.radius + .5f, 0, 0));
            }



            // SIZE CAP
            Handles.SphereCap(0,
                              new Vector3(gener.radius * .9f, 0, 0),
                              Quaternion.identity,
                              .15f * HandleUtility.GetHandleSize(pos));


            Handles.Label(new Vector3(gener.radius, -y / 2, 0), "" + System.Math.Round(gener.size, 0) + " degs", labelStyle);



            float handleSizer = .15f * HandleUtility.GetHandleSize(Vector3.zero);



            // CELL_COUNT CLICKERS

            // (-)


            Handles.color = new Color(.7f, 1f, .7f, .9f);
            pos           = new Vector3(gener.radius, -y, -handleSizer * 2);
            if (Handles.Button(pos, Quaternion.Euler(0, 180, 0), handleSizer, handleSizer, Handles.ConeCap))
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "Cell Count");

                gener.P_Cells.initiateRipple_setIntValueFromGUIChange(gener.cells - 1);

                gener.parametricObject.model.autobuild();
                for (int i = 0; i < generator.P_Output.Dependents.Count; i++)
                {
                    generator.P_Output.Dependents [i].parametricObject.generator.adjustWorldMatrices();
                }
            }

            // [+]
            Handles.color = new Color(.7f, .7f, 1, .9f);
            pos           = new Vector3(gener.radius, -y, handleSizer * 2);
            if (Handles.Button(pos, Quaternion.Euler(0, 0, 0), handleSizer, handleSizer, Handles.ConeCap))
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "Cell Count");

                gener.P_Cells.initiateRipple_setIntValueFromGUIChange(gener.cells + 1);

                gener.parametricObject.model.autobuild();
                for (int i = 0; i < generator.P_Output.Dependents.Count; i++)
                {
                    generator.P_Output.Dependents [i].parametricObject.generator.adjustWorldMatrices();
                }
            }

            Handles.Label(new Vector3(gener.radius + .2f, 0, 0f), "" + (gener.cells) + " bays", labelStyle);

            Handles.matrix = pushM;


            // FINISH
            Handles.matrix = prevHandlesMatrix;
        }