Пример #1
0
        // SHAPE_REPEATER_2D :: DRAW_CONTROL_HANDLES_OF_INPUT_PARAMETRIC_OBJECTS
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            GridRepeater2D gener2D = (generator as GridRepeater2D);

            // Draw the plan AND the section splines.


            // NODE
            if (gener2D.nodeSrc_po != null && gener2D.nodeSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener2D.nodeSrc_po);

                if (gh != null)
                {
                    Matrix4x4 localPlanM = consumerM * generator.getLocalConsumerMatrixPerInputSocket(gener2D.nodeSrc_po);

                    gh.drawTransformHandles(visited, localPlanM, true);
                    gh.drawControlHandles(ref visited, localPlanM, true);
                }
            }

            // SECTION
            if (gener2D.cellSrc_po != null && gener2D.cellSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener2D.cellSrc_po);

                if (gh != null)
                {
                    Matrix4x4 localSecM = consumerM * generator.getLocalConsumerMatrixPerInputSocket(gener2D.cellSrc_po);

                    gh.drawTransformHandles(visited, localSecM, true);
                    gh.drawControlHandles(ref visited, localSecM, true);
                }
            }
        }
Пример #2
0
        /*
         *      [MenuItem("GameObject/3D Object/Archimatix Nodes/Meshers/Polygon")]
         *      static void Init() {
         *              AXEditorUtilities.addNodeToCurrentModel("Polygon");
         *      }
         */



        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            Polygon gener = (generator as Polygon);

            // Draw the plan spline.

            if (gener != null && gener.planSrc_po != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener.planSrc_po);
                if (gh != null)
                {
                    Matrix4x4 localSecM = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.getLocalConsumerMatrixPerInputSocket(gener.planSrc_po);

                    localSecM *= parametricObject.getAxisRotationMatrix2D(Axis.Y);

                    gh.drawControlHandles(ref visited, localSecM, true);


                    if (gener.planSrc_po.is2D())
                    {
                        gh.drawTransformHandles(visited, localSecM, true);
                    }
                }
            }
        }
Пример #3
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;
        }
Пример #4
0
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            GridRepeater gener = (generator as GridRepeater);

            // Draw the plan AND the section splines.



            // BOUNDING_SHAPE
            if (gener.boundingShapeSrc_po != null && gener.boundingShapeSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener.boundingShapeSrc_po);

                if (gh != null)
                {
                    // don't pass consumerM anymore.
                    // Draw functions now use wordDisplayMatrix precacled with calls to Generator.getLocalConsumerMatrixPerInputSocket
                    Matrix4x4 localPlanM = Matrix4x4.identity;

                    //gener.worldDisplayMatrix =    localPlanM;
                    gh.drawTransformHandles(visited, localPlanM, true);
                    gh.drawControlHandles(ref visited, localPlanM, true);
                }
            }
        }
Пример #5
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Repeaters/Grid Repeater")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("GridRepeater");
         * }
         */

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

            RepeaterTool repeaterToolU = (parametricObject.generator as GridRepeater).repeaterToolU;
            RepeaterTool repeaterToolV = (parametricObject.generator as GridRepeater).repeaterToolV;



            if (repeaterToolU != null && repeaterToolV != null)
            {
                // DRAW GRID
                Handles.color = new Color(1, .5f, 0, .4f);

                Matrix4x4 prevHandleMatrix = Handles.matrix;

                Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;

                Handles.matrix = context;

                for (int i = 0; i <= repeaterToolU.cells; i++)
                {
                    Handles.DrawLine(new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, -repeaterToolV.size / 2), new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, repeaterToolV.size / 2));
                }

                for (int k = 0; k <= repeaterToolV.cells; k++)
                {
                    Handles.DrawLine(new Vector3(-repeaterToolU.size / 2, 0, -repeaterToolV.size / 2 + k * repeaterToolV.actualBay), new Vector3(repeaterToolU.size / 2, 0, -repeaterToolV.size / 2 + k * repeaterToolV.actualBay));
                }



                // ASK RepeaterTools to DRAW

                // - U TOOL
                GeneratorHandler gh = getGeneratorHandler(repeaterToolU.parametricObject);
                if (gh != null)
                {
                    //Handles.matrix = context *   Matrix4x4.TRS(new Vector3(0, 0, 1f*repeaterToolV.bay+repeaterToolV.size/2), Quaternion.Euler(-90, 0, 0), Vector3.one);
                    Handles.matrix = context * Matrix4x4.TRS(new Vector3(0, 0, repeaterToolV.size / 2), Quaternion.Euler(-90, 0, 0), Vector3.one);

                    gh.drawBoundsHandles(context, true);
                    List <string> visited = new List <string>();
                    gh.drawControlHandles(ref visited, parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * parametricObject.getAxisRotationMatrix() * parametricObject.getLocalAlignMatrix(), true);
                }

                // - V TOOL
                gh = getGeneratorHandler(repeaterToolV.parametricObject);
                if (gh != null)
                {
                    Handles.matrix = context * Matrix4x4.TRS(new Vector3(repeaterToolU.size / 2, 0, 0), Quaternion.Euler(90, -90, 0), Vector3.one);
                    gh.drawBoundsHandles(context, true);

                    List <string> visited = new List <string>();
                    gh.drawControlHandles(ref visited, parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * parametricObject.getAxisRotationMatrix() * parametricObject.getLocalAlignMatrix(), true);
                }

                Handles.matrix = prevHandleMatrix;
            }
        }
Пример #6
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Repeaters/Linear Repeater")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("FloorRepeater");
         * }
         */
        public override void drawBoundsHandles(Matrix4x4 consumerM, bool forceDraw = false)
        {
            base.drawBoundsHandles(consumerM, forceDraw);

            RepeaterTool repeaterTool = (parametricObject.generator as FloorRepeater).repeaterTool;


            Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;

            Handles.matrix = context;

            if (repeaterTool != null)
            {
                GeneratorHandler gh = getGeneratorHandler(repeaterTool.parametricObject);

                if (gh != null)
                {
                    Handles.matrix *= Matrix4x4.TRS(new Vector3(parametricObject.bounds.extents.x, repeaterTool.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);
                }
            }
        }
Пример #7
0
        // L :: DRAW_CONTROL_HANDLES_OF_INPUT_PARAMETRIC_OBJECTS
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            Lofter gener = (generator as Lofter);


            //if (alreadyVisited(ref visited, "LofterHandler"))
            //	return;

            Matrix4x4 prevHandlesMatrix = Handles.matrix;


            foreach (AXParameter input in gener.inputs)
            {
                if (input.DependsOn != null)
                {
                    GeneratorHandler gh = getGeneratorHandler(input.DependsOn.parametricObject);

                    //Debug.Log(input.DependsOn.parametricObject.Name);

                    Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, 0), Vector3.one);

                    if (gh != null)
                    {
                        Handles.matrix = context * Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0), Vector3.one);

                        gh.drawBoundsHandles(context, true);

                        //List<string> _visited = new List<string>();
                        gh.drawControlHandles(ref visited, consumerM, true);
                    }
                }
            }
        }
        //public override void drawControlHandlesofInputParametricObjects(ref List<string> visited, Matrix4x4 consumerM)
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            List <AXParameter> inputPs = parametricObject.generator.AllInput_Ps;



            foreach (AXParameter input_p in inputPs)
            {
                if (input_p != null && input_p.DependsOn != null)
                {
                    AXParametricObject src_po = input_p.DependsOn.parametricObject;

                    GeneratorHandler gh = getGeneratorHandler(src_po);

                    if (gh != null)
                    {
                        //Debug.Log(src_po.Name);
                        //Debug.Log(src_po.generator.parametricObject.worldDisplayMatrix);

                        gh.drawControlHandles(ref visited, consumerM, false);
                        //gh.drawTransformHandles(visited, consumerM);
                    }
                }
            }
        }
Пример #9
0
            public GeneratorThunk(GeneratorHandler client, object arg)
            {
                this.OnGenerator = client;
                this.arg         = arg;

                this.gencb.ver = 2;
                this.gencb.arg = IntPtr.Zero;
                this.gencb.cb  = this.OnGeneratorThunk;
            }
Пример #10
0
        // PLAN_SWEEP :: DRAW_CONTROL_HANDLES_OF_INPUT_PARAMETRIC_OBJECTS
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            PlanSweep gener = (generator as PlanSweep);

            // Draw the plan AND the section splines.

            // PLAN first, since the section needsplan information to position itself.
            if (gener.planSrc_po != null && gener.planSrc_po.generator != null)
            {
                // Get the input PO and draw
                GeneratorHandler gh = getGeneratorHandler(gener.planSrc_po);

                if (gh != null)
                {
                    //Matrix4x4 localPlanM = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.getLocalConsumerMatrixPerInputSocket(gener.planSrc_po);
                    Matrix4x4 localPlanM = Matrix4x4.identity;
                    if (gener.planSrc_po.is2D())
                    {
                        gh.drawTransformHandles(visited, localPlanM, true);
                    }
                    gh.drawControlHandles(ref visited, localPlanM, true);
                }
            }

            // SECTION
            if (gener.sectionSrc_po != null && gener.sectionSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener.sectionSrc_po);

                if (gh != null)
                {
                    //Matrix4x4 localSecM = parametricObject.model.transform.localToWorldMatrix.inverse * generator.parametricObject.worldDisplayMatrix * generator.getLocalConsumerMatrixPerInputSocket(gener.sectionSrc_po);
                    Matrix4x4 localSecM = Matrix4x4.identity;


                    //Debug.Log("localSecM");
                    //Debug.Log(localSecM);

                    gh.drawTransformHandles(visited, localSecM, true);
                    gh.drawControlHandles(ref visited, localSecM, true);
                }
            }
        }
Пример #11
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Repeaters/Plan Repeater")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("PlanRepeater");
         * }
         */

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

            RepeaterTool repeaterTool = (parametricObject.generator as PlanRepeater).repeaterTool;

            if (repeaterTool != null)
            {
                GeneratorHandler gh = getGeneratorHandler(repeaterTool.parametricObject);

                if (gh != null)
                {
                    consumerM *= Matrix4x4.TRS(new Vector3(parametricObject.bounds.extents.x, repeaterTool.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);
                }
            }
        }
Пример #12
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Repeaters/Linear Repeater")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("LinearRepeater");
         * }
         */
        public override void drawBoundsHandles(Matrix4x4 consumerM, bool forceDraw = false)
        {
            base.drawBoundsHandles(consumerM, forceDraw);

            LinearRepeater repeater = (parametricObject.generator as LinearRepeater);

            RepeaterTool repeaterTool = repeater.repeaterToolU;

            if (repeater.zAxis)
            {
                repeaterTool = repeater.repeaterToolV;
            }



            Matrix4x4 prevHandleMatrix = Handles.matrix;

            Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;

            Handles.matrix = context;

            if (repeaterTool != null)
            {
                GeneratorHandler gh = getGeneratorHandler(repeaterTool.parametricObject);

                if (gh != null)
                {
                    if (repeater.zAxis)
                    {
                        Handles.matrix *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 90, 0), Vector3.one);
                    }

                    gh.drawBoundsHandles(context, true);

                    List <string> visited = new List <string>();
                    gh.drawControlHandles(ref visited, context, true);
                }
            }

            Handles.matrix = prevHandleMatrix;
        }
Пример #13
0
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            AXShape inputShape = (parametricObject.generator as ShapeMerger).S_InputShape;

            if (inputShape == null)
            {
                return;
            }

            for (int i = 0; i < inputShape.inputs.Count; i++)
            {
                AXParameter src = inputShape.inputs[i].DependsOn;

                if (src == null)
                {
                    continue;
                }

                AXParametricObject srcPO = src.Parent;

                GeneratorHandler src_gh = getGeneratorHandler(srcPO);

                if (src_gh != null)
                {
                    if (srcPO.generator is ShapeMerger)
                    {
                        src_gh.drawControlHandlesofInputParametricObjects(ref visited, consumerM, true);
                    }
                    else
                    {
                        src_gh.drawTransformHandles(visited, consumerM, false);
                        src_gh.drawControlHandles(ref visited, consumerM, false);
                    }
                }


                //else
                //	gh.drawTransformHandles(visited, consumerM, true);
            }
        }
        //public override void drawControlHandlesofInputParametricObjects(ref List<string> visited, Matrix4x4 consumerM)
        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            // only show the inputs for the current channel

            Channeler gener = (generator as Channeler);


            if (gener.inputs != null && gener.inputs.Count > gener.channel)
            {
                AXParameter src_p = gener.inputs[gener.channel].DependsOn;


                if (src_p != null)
                {
                    AXParametricObject src_po = src_p.parametricObject;

                    GeneratorHandler gh = getGeneratorHandler(src_po);
                    if (gh != null)
                    {
                        gh.drawControlHandles(ref visited, consumerM, false);
                    }
                }
            }
        }
Пример #15
0
//		public override void drawBoundsHandles(Matrix4x4 consumerM, bool forceDraw=false)
//		{
//			base.drawBoundsHandles(consumerM, forceDraw);
//
//			Replicator replicator = (parametricObject.generator as Replicator);
//
//			if (replicator != null)
//			{
//				GeneratorHandler gh = getGeneratorHandler(replicator.parametricObject);
//
//				if (gh != null)
//				{
//					consumerM *= Matrix4x4.TRS(new Vector3(parametricObject.bounds.extents.x, 0, 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);
//				}
//			}
//		}



        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            Replicator gener = (generator as Replicator);

            // Draw the plan AND the section splines.

            // PLAN first, since the section needsplan information to position itself.
            if (gener.planSrc_po != null && gener.planSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener.planSrc_po);

                if (gh != null)
                {
                    //Matrix4x4 localPlanM = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.getLocalConsumerMatrixPerInputSocket(gener.planSrc_po);
                    Matrix4x4 localPlanM = Matrix4x4.identity;
                    localPlanM = Matrix4x4.TRS(new Vector3(parametricObject.bounds.extents.x, 0, 0), Quaternion.Euler(0, 0, 90), Vector3.one);
                    if (gener.planSrc_po.is2D())
                    {
                        gh.drawTransformHandles(visited, localPlanM, true);
                    }
                    gh.drawControlHandles(ref visited, localPlanM, true);
                }
            }
        }
Пример #16
0
        public static void Main(string[] args)
        {
            var waitForInput            = false;
            var debugAttach             = false;
            var currentWorkingDirectory = Environment.CurrentDirectory;
            var parentProcess           = Process.GetCurrentProcess().GetParent();
            StandardStreamService streamService;
            GeneratorHandler      generatorHandler = null;
            var parseResult = CommandLineParser.ParseArgs <ParseResult>(args, (result, arg) =>
            {
            },
                                                                        (result, _switch, switchArg) =>
            {
                switch (_switch)
                {
                case SwitchCommands.DEBUG:
                    debugAttach = true;
                    break;

                case SwitchCommands.WAIT_FOR_INPUT:
                    waitForInput = true;
                    break;

                case SwitchCommands.CWD:
                    currentWorkingDirectory = switchArg;
                    break;
                }
            });

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

            if (debugAttach)
            {
                Debugger.Launch();
            }

            if (waitForInput)
            {
                var url = ConfigurationManager.AppSettings["WebApiUrl"];

                webApiService = new WebApiService(url);
                streamService = new StandardStreamService(webApiService);

                streamService.Start(parentProcess, currentWorkingDirectory);
                webApiService.Start();

                streamService.Wait();
            }
            else
            {
                var packageCachePath = Environment.ExpandEnvironmentVariables(@"%APPDATA%\hydra\cache");
                var testWebApi       = Environment.CommandLine.Contains("/TestWebApi");
                var container        = new UnityContainer();
                KeyValuePair <string, IGeneratorOverrides> keyValuePair;
                IGeneratorOverrides generatorOverrides;
                string argumentsKind;

                AppDomain.CurrentDomain.SetData("UnityContainer", container);

                generatorHandler = new GeneratorHandler();
                keyValuePair     = generatorHandler.GetOverrides().LastOrDefault();

                argumentsKind      = keyValuePair.Key;
                generatorOverrides = keyValuePair.Value;

                if (testWebApi)
                {
                    var url = ConfigurationManager.AppSettings["WebApiUrl"];

                    webApiService = new WebApiService(url);
                    webApiService.GeneratorHandler       = generatorHandler;
                    generatorHandler.SuppressDebugOutput = true;

                    Console.WriteLine($"Starting WebAPI Service at '{ url }'");

                    webApiService.Start();
                }

                if (RUN_UNIT_TESTS)
                {
                    UnitTests.RunUnitTests();
                }

                if (argumentsKind != null)
                {
                    var arguments = generatorOverrides.GetHandlerArguments(packageCachePath, argumentsKind);

                    if (arguments.ContainsKey("GeneratorKinds"))
                    {
                        var generatorKinds = ((string)arguments["GeneratorKinds"]).Split(',').Select(k => k.Trim());

                        foreach (var kind in generatorKinds)
                        {
                            arguments = generatorOverrides.GetHandlerArguments(packageCachePath, kind);

                            generatorHandler.Execute(arguments);
                        }
                    }
                    else
                    {
                        generatorHandler.Execute(arguments);
                    }
                }
                else
                {
                    Console.WriteLine("This program was not intended to be run directly");
                }
            }
        }
Пример #17
0
        public override void drawControlHandles(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            if (alreadyVisited(ref visited, "GridRepeater2DHandler"))
            {
                return;
            }

            Matrix4x4 prevHandlesMatrix = Handles.matrix;

            base.drawControlHandles(ref visited, consumerM, beingDrawnFromConsumer);


            RepeaterTool repeaterToolU = (parametricObject.generator as GridRepeater2D).repeaterToolU;
            RepeaterTool repeaterToolV = (parametricObject.generator as GridRepeater2D).repeaterToolV;



            if (repeaterToolU != null && repeaterToolV != null)
            {
                // DRAW GRID
                Handles.color = new Color(1, .5f, 0, .4f);


                if (!beingDrawnFromConsumer)
                {
                    consumerM *= generator.parametricObject.getLocalMatrix().inverse;
                    consumerM *= parametricObject.getAxisRotationMatrix();
                }

                consumerM *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);

                //consumerM *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(90, 0, 0), Vector3.one);


                Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);

                Handles.matrix = context;

                for (int i = 0; i <= repeaterToolU.cells; i++)
                {
                    Handles.DrawLine(new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, -repeaterToolV.size / 2), new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, repeaterToolV.size / 2));
                }

                for (int k = 0; k <= repeaterToolV.cells; k++)
                {
                    Handles.DrawLine(new Vector3(-repeaterToolU.size / 2, 0, -repeaterToolV.size / 2 + k * repeaterToolV.actualBay), new Vector3(repeaterToolU.size / 2, 0, -repeaterToolV.size / 2 + k * repeaterToolV.actualBay));
                }


                // ASK RepeaterTools to DRAW
                GeneratorHandler gh = getGeneratorHandler(repeaterToolU.parametricObject);

                if (gh != null)
                {
                    Handles.matrix = context * Matrix4x4.TRS(new Vector3(0, 0, -1.3f * repeaterToolV.size / 2), Quaternion.Euler(90, 0, 0), Vector3.one);

                    gh.drawBoundsHandles(context, true);
                    gh.drawControlHandles(ref visited, consumerM, true);
                }
                gh = getGeneratorHandler(repeaterToolV.parametricObject);
                if (gh != null)
                {
                    Handles.matrix = context * Matrix4x4.TRS(new Vector3(1.3f * repeaterToolU.size / 2, 0, 0), Quaternion.Euler(90, -90, 0), Vector3.one);
                    gh.drawBoundsHandles(context, true);
                    gh.drawControlHandles(ref visited, consumerM, true);
                }
            }


            // MATRIX
            //Matrix4x4 inputsM = consumerM;

            //if (beingDrawnFromConsumer)
            //	inputsM *= generator.parametricObject.getLocalMatrix();

            drawControlHandlesofInputParametricObjects(ref visited, consumerM * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(90, 0, 0), Vector3.one), true);


            /*
             * // DRAW THE FINAL MERGED SHAPE
             *
             * if (! beingDrawnFromConsumer)
             *      consumerM *= generator.parametricObject.getLocalMatrix().inverse;
             *
             * AXShape inputShape = (parametricObject.generator as ShapeMerger).InputShape;
             * AXParameter out_p = inputShape.getSelectedOutputParameter();
             *
             *
             * if(! inputShape.hasOutputConnected())
             *      consumerM *= generator.parametricObject.getAxisRotationMatrix();
             *
             * Handles.matrix = generator.parametricObject.worldDisplayMatrix;;
             *
             * Color mergeShapeColor = Color.cyan;
             * mergeShapeColor.a *= .75f;
             * Handles.color = mergeShapeColor;
             *
             * drawPaths(out_p);
             */
            Handles.matrix = prevHandlesMatrix;
        }
Пример #18
0
//		public override int customNodeGUIZone_2(int cur_y, AXNodeGraphEditorWindow editor, AXParametricObject po)
//		{
//
//			int     gap         = ArchimatixUtils.gap;
//			int     lineHgt     = ArchimatixUtils.lineHgt;
//			float     winMargin     = ArchimatixUtils.indent;
//			float     innerWidth     = po.rect.width - 2*winMargin;
//
//			Rect pRect = new Rect(winMargin, cur_y, innerWidth, lineHgt);
//			EditorGUI.TextField(pRect, "YUBBA");
//			//GUI.Button(pRect, "HALLO");
//
//			cur_y += lineHgt;
//
//			return cur_y;
//		}



        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            Extrude gener = (generator as Extrude);



            if (gener.P_Plan == null || gener.planSrc_p == null)
            {
                return;
            }

            if (gener.parametricObject == null || !gener.parametricObject.isActive)
            {
                return;
            }



            GeneratorHandler gh = getGeneratorHandler(gener.planSrc_po);

            if (gh != null)
            {
                Matrix4x4 localSecM = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * generator.getLocalConsumerMatrixPerInputSocket(gener.planSrc_po);


                gh.drawControlHandles(ref visited, localSecM, true);



                if (gener.planSrc_po != null && gener.planSrc_po.is2D() || gener.planSrc_po.generator is Grouper)
                {
                    gh.drawTransformHandles(visited, localSecM, true);
                }



                // BEVEL HANDLE
                Matrix4x4 prevHM    = Handles.matrix;
                Color     prevColor = Handles.color;

                Handles.matrix = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * AXGeometryTools.Utilities.getFirstSegmentHandleMatrix(gener.P_Plan.getPaths());

                float handlesMatrixScaleAdjuster = AXEditorUtilities.getHandlesMatrixScaleAdjuster();


                if (!gener.bevelOut)
                {
                    //float bevelMax = (gener.bevelTop > gener.bevelBottom) ? gener.bevelTop : gener.bevelBottom;
                    //Handles.matrix *= Matrix4x4.TRS(new Vector3(-bevelMax, 0, 0), Quaternion.identity, Vector3.one);
                }
                float x = 0;                 //(gener.bevelOut) ? gener.bevelTop : 0;

                x += gener.P_Plan.thickness + gener.P_Plan.offset;



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



                Vector3 posR1 = new Vector3((gener.bevelBottom > gener.bevelTop)? 0 :gener.bevelTop - gener.bevelBottom, gener.bevelBottom, 0);

                posR1.x += gener.P_Plan.offset;



                float r2X = (gener.bevelBottom > gener.bevelTop) ? (gener.bevelBottom - gener.bevelTop - gener.taper) : -gener.taper;

                Vector3 posR2 = new Vector3(r2X, (gener.extrude - gener.bevelTop), 0);
                posR2.x += gener.P_Plan.offset;


                // WIRE DISCS
                Handles.color = Color.red;
                Handles.DrawWireDisc(posR1, Vector3.forward, gener.bevelBottom);
                Handles.DrawWireDisc(posR2, Vector3.forward, gener.bevelTop);
                Handles.color = Color.green;



                // BEVEL RADIUS 1

                // R1
                EditorGUI.BeginChangeCheck();
                posR1 = Handles.FreeMoveHandle(
                    posR1,
                    Quaternion.identity,
                    .1f * HandleUtility.GetHandleSize(posR1),
                    Vector3.zero,
                    (controlID, positione, rotation, size) =>
                {
                    if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                    {
                        ArchimatixEngine.mouseDownOnSceneViewHandle();
                    }
                    Handles.SphereCap(controlID, positione, rotation, size);
                });


                if (EditorGUI.EndChangeCheck())
                {
                    parametricObject.initiateRipple_setFloatValueFromGUIChange("Bevel Bottom", posR1.y);

                    if (Event.current.alt && gener.bevelsUnified)
                    {
                        gener.P_Bevels_Unified.boolval = false;
                    }


                    // OFFSET
                    float ox = posR1.x;

                    if (gener.bevelBottom < gener.bevelTop)
                    {
                        ox -= (gener.bevelTop - gener.bevelBottom);
                    }

                    gener.P_Plan.offset = (Math.Abs(ox) < (.08f) * HandleUtility.GetHandleSize(posR1)) ? 0 : ox;


                    parametricObject.model.isAltered(32);
                }



                // R2 & TAPER

                EditorGUI.BeginChangeCheck();

                posR2 = Handles.FreeMoveHandle(
                    posR2,
                    Quaternion.identity,
                    .1f * HandleUtility.GetHandleSize(posR2),
                    Vector3.zero,
                    (controlID, positione, rotation, size) =>
                {
                    if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                    {
                        ArchimatixEngine.mouseDownOnSceneViewHandle();
                    }
                    Handles.SphereCap(controlID, positione, rotation, size);
                });

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RegisterCompleteObjectUndo(parametricObject.model, "Bevel Radius Changed");

                    if (Event.current.alt)
                    {
                        parametricObject.initiateRipple_setFloatValueFromGUIChange("Extrude", "Height", (gener.bevelTop + posR2.y));
                        gener.taper = (gener.bevelBottom > gener.bevelTop) ?  gener.bevelBottom - gener.bevelTop - posR2.x : -posR2.x;

                        gener.taper = (Math.Abs(gener.taper) < (.08f) * HandleUtility.GetHandleSize(posR2) * handlesMatrixScaleAdjuster) ? 0 : gener.taper;

                        parametricObject.initiateRipple_setFloatValueFromGUIChange("Taper", gener.taper + gener.P_Plan.offset);
                    }
                    else
                    {
                        parametricObject.initiateRipple_setFloatValueFromGUIChange("Bevel Top", (gener.extrude - posR2.y));
                    }



                    //parametricObject.model.latestEditedParameter = gener.P_Taper;
                    parametricObject.model.isAltered(32);
                }



                /*
                 * EditorGUI.BeginChangeCheck();
                 * pos1 = Handles.Slider(pos1, Vector3.down,  .6f*HandleUtility.GetHandleSize(pos1), Handles.ArrowCap, 0);
                 *
                 * if(EditorGUI.EndChangeCheck())
                 * {
                 *      parametricObject.intiateRipple_setFloatValueFromGUIChange("Bevel Radius Bottom", pos1.y);
                 *      parametricObject.model.isAltered(32);
                 * }
                 */
                Handles.color = Color.cyan;



                /*
                 *                             // TAPER
                 *                             EditorGUI.BeginChangeCheck();
                 *                             //Vector3 taperV =  Handles.Slider(new Vector3(-gener.taper, gener.extrude-gener.bevelTop, 0), Vector3.right,  .6f*HandleUtility.GetHandleSize(pos1), Handles.ArrowCap, 0);
                 *
                 *                             Vector3 taperV =  Handles.Slider(new Vector3(gener.P_Plan.offset, gener.extrude-gener.bevelTop, 0), Vector3.right,  .6f*HandleUtility.GetHandleSize(pos1), Handles.ArrowCap, 0);
                 *                             if(EditorGUI.EndChangeCheck())
                 *                             {
                 *
                 *
                 *                                     // TAPER
                 *                                     //float px = (Math.Abs(taperV.x) < (.08f)*HandleUtility.GetHandleSize(posR2)) ? 0 : -taperV.x;
                 *
                 *                                     Undo.RegisterCompleteObjectUndo (parametricObject.model, "Offset parameter changed");
                 *
                 *                                     float px = (Math.Abs(taperV.x) < (.08f)*HandleUtility.GetHandleSize(posR2)) ? 0 : taperV.x;
                 *                                     //parametricObject.intiateRipple_setFloatValueFromGUIChange("Taper", px);
                 *                                     //parametricObject.intiateRipple_setFloatValueFromGUIChange("Taper", px);
                 *                                     gener.P_Plan.offset = px;
                 *
                 *                                     parametricObject.model.isAltered(32);
                 *
                 *
                 *                             }
                 */

                /*
                 *      // BEVEL_RADIUS_1 ANGLED
                 *      float c45 = .70710678f;
                 *      EditorGUI.BeginChangeCheck();
                 *      Vector3 bevel2V =  Handles.Slider(new Vector3(-gener.taper - (gener.bevelTop*c45),    gener.extrude-gener.bevelTop - (gener.bevelTop*c45),   0), new Vector3(-1, -1, 0),  .6f*HandleUtility.GetHandleSize(pos1), Handles.ArrowCap, 0);
                 *      if(EditorGUI.EndChangeCheck())
                 *      {
                 *
                 *              float px = (-bevel2V.x - gener.taper)/c45;
                 *              parametricObject.intiateRipple_setFloatValueFromGUIChange("Bevel Radius Top", px);
                 *              parametricObject.model.isAltered(32);
                 *      }
                 */

                /*
                 *
                 * // BEVEL TOP RADIUS
                 * EditorGUI.BeginChangeCheck();
                 * GUI.SetNextControlName("Bevel Top Radius");
                 * Vector3 r2V =  Handles.Slider(new Vector3(-gener.taper, gener.extrude-gener.bevelTop, 0), Vector3.up,  .6f*HandleUtility.GetHandleSize(pos1), Handles.ArrowCap, 0);
                 * //Vector3 r2V =  Handles.Slider(new Vector3(-gener.taper, gener.extrude-gener.bevelTop, 0), Vector3.up);
                 * if(EditorGUI.EndChangeCheck())
                 * {
                 *      // TAPER
                 *      parametricObject.intiateRipple_setFloatValueFromGUIChange("Bevel Radius Top", gener.extrude-r2V.y);
                 *      parametricObject.model.isAltered(32);
                 *
                 *
                 * }
                 *
                 */

                // BEVEL SEGS

                if (gener.bevelTop > 0)
                {
                    float handleSize = .55f * HandleUtility.GetHandleSize(posR1) * handlesMatrixScaleAdjuster;

                    float adjustedSegs = (gener.bevelHardEdge && gener.bevelSegs == 1) ? 0 : gener.bevelSegs;


                    //Vector3 posSegs = new Vector3(-gener.taper,      gener.extrude - gener.bevelTop +handleSize + (.025f*HandleUtility.GetHandleSize(posR1)* gener.bevelSegs), 0);
                    Vector3 posSegs = new Vector3(-gener.taper + handleSize + (.04f * HandleUtility.GetHandleSize(posR1) * adjustedSegs * handlesMatrixScaleAdjuster), gener.extrude - gener.bevelTop, 0);

                    Handles.DrawLine(posR2, posSegs);

                    EditorGUI.BeginChangeCheck();
                    posSegs = Handles.FreeMoveHandle(
                        posSegs,
                        Quaternion.identity,
                        .1f * HandleUtility.GetHandleSize(posSegs),
                        Vector3.zero,
                        (controlID, positione, rotation, size) =>
                    {
                        if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                        {
                            ArchimatixEngine.mouseDownOnSceneViewHandle();
                        }
                        Handles.SphereCap(controlID, positione, rotation, size);
                    });



                    if (EditorGUI.EndChangeCheck())
                    {
                        // BEVEL_TOP_RADIUS
                        //int conv =  Mathf.CeilToInt(   (posSegs.y + gener.bevelTop - gener.extrude - handleSize) / (.025f*HandleUtility.GetHandleSize(posR1)));
                        Undo.RegisterCompleteObjectUndo(parametricObject.model, "Bevel Segs Changed");



                        int conv = Mathf.CeilToInt((posSegs.x + gener.taper - handleSize) / (.04f * HandleUtility.GetHandleSize(posR2)));

                        if (conv <= 0)
                        {
                            conv = 1;

                            gener.bevelHardEdge           = true;
                            gener.P_BevelHardEdge.boolval = true;
                        }
                        else
                        {
                            gener.bevelHardEdge           = false;
                            gener.P_BevelHardEdge.boolval = false;
                        }


                        if (gener.bevelTop == 0)
                        {
                            parametricObject.initiateRipple_setFloatValueFromGUIChange("Bevel Segs", .02f);
                        }
                        parametricObject.initiateRipple_setIntValueFromGUIChange("Bevel Segs", conv);
                        parametricObject.model.isAltered(32);
                    }
                }



                /*
                 *
                 * // LIP_TOP
                 * Handles.color = Color.magenta;
                 *
                 * EditorGUI.BeginChangeCheck();
                 * Vector3 lipTopV =  Handles.Slider(new Vector3(-gener.taper-gener.lipTop, gener.extrude, 0), Vector3.left,  .6f*HandleUtility.GetHandleSize(posR2), Handles.ArrowCap, 0);
                 * if(EditorGUI.EndChangeCheck())
                 * {
                 *      parametricObject.intiateRipple_setFloatValueFromGUIChange("Lip Top", -lipTopV.x-gener.taper);
                 *      parametricObject.model.isAltered(32);
                 * }
                 *
                 * // LIP_EDGE
                 * EditorGUI.BeginChangeCheck();
                 * lipTopV =  Handles.Slider(new Vector3(-gener.taper-gener.lipTop, gener.extrude-gener.lipEdge, 0), Vector3.down,  .6f*HandleUtility.GetHandleSize(posR2), Handles.ArrowCap, 0);
                 * if(EditorGUI.EndChangeCheck())
                 * {
                 *      parametricObject.intiateRipple_setFloatValueFromGUIChange("Lip Edge", -lipTopV.y+gener.extrude);
                 *      parametricObject.model.isAltered(32);
                 * }
                 *
                 */



                //drawBevelHandle(parametricObject, "Bevel Radius Top", gener.bevelTop, "Taper", gener.taper, .06f);

                Handles.matrix = prevHM;
                Handles.color  = prevColor;
            }
        }
Пример #19
0
 public static IEnumerable <KeyValuePair <string, IGeneratorOverrides> > GetOverrides(this GeneratorHandler handler)
 {
     return(GetOverrides());
 }
Пример #20
0
        /*
         * [MenuItem("GameObject/3D Object/Archimatix Nodes/Meshers/Lathe")]
         * static void Init() {
         *      AXEditorUtilities.addNodeToCurrentModel("Lathe");
         * }
         */

        public override void drawControlHandlesofInputParametricObjects(ref List <string> visited, Matrix4x4 consumerM)
        {
            Lathe gener = (generator as Lathe);

            //if (visited.Contains ("c_"+parametricObject.Guid))
            //	return;
            //visited.Add ("c_"+parametricObject.Guid);


            // SECTION
            if (gener.sectionSrc_po != null && gener.sectionSrc_po.generator != null)
            {
                GeneratorHandler gh = getGeneratorHandler(gener.sectionSrc_po);

                if (gh != null)
                {
                    Matrix4x4 localSecM = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix;                    // * generator.getLocalConsumerMatrixPerInputSocket(gener.sectionSrc_po);
                    if (gener.sectionSrc_po.is2D())
                    {
                        gh.drawTransformHandles(visited, localSecM, true);
                    }
                    gh.drawControlHandles(ref visited, localSecM, true);
                }
            }



            // PLAN

            Matrix4x4 prevHandlesMatrix = Handles.matrix;



            float y           = .5f * HandleUtility.GetHandleSize(Vector3.zero);
            float yd          = 0.5f * HandleUtility.GetHandleSize(Vector3.zero) + .2f * parametricObject.bounds.extents.y;
            float handleSizer = .15f * HandleUtility.GetHandleSize(Vector3.zero);

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

            Vector3 pos;

            Color lightLineColor = new Color(1, .8f, .6f, .7f);
            Color brightOrange   = new Color(1, .8f, 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 + handleSizer, -y / 4, 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,
                (controlID, positione, rotation, size) =>
            {
                if (GUIUtility.hotControl > 0 && controlID == GUIUtility.hotControl)
                {
                    ArchimatixEngine.mouseDownOnSceneViewHandle();
                }
                Handles.SphereCap(controlID, positione, rotation, size);
            });


            if (EditorGUI.EndChangeCheck())
            {
                Undo.RegisterCompleteObjectUndo(parametricObject.model, "Radius");
                //.parametricObject.setAltered();
                gener.P_Radius.initiateRipple_setFloatValueFromGUIChange(pos.x);
                gener.radius = pos.x;

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

                generator.adjustWorldMatrices();
            }



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

            Handles.DrawSolidArc(Vector3.zero,
                                 Vector3.up,
                                 Vector2.right,
                                 -gener.sweepAngle,
                                 gener.radius + .2f);



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



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

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

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

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


                gener.P_SweepAngle.initiateRipple_setFloatValueFromGUIChange(360 - rot.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();
                }
            }
            Handles.color = new Color(1, .5f, 0f, 1f);

            Handles.DrawWireArc(Vector3.zero, Vector3.up, Vector3.right, (-gener.sweepAngle), gener.radius);


            Handles.matrix *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 360 - gener.sweepAngle, 0), Vector3.one);



            // SEGMENT CLICKERS

            // (-)

            /*
             * Handles.color = new Color(.7f, .7f, 1, .9f);
             * pos = new Vector3(gener.radius, 0, -handleSizer*2);
             * if(Handles.Button(pos, Quaternion.Euler(0,180,0), handleSizer, handleSizer, Handles.ConeCap))
             * {
             *      Undo.RegisterCompleteObjectUndo (parametricObject.model, "Segs");
             *
             *      gener.P_Segs.intiateRipple_setIntValueFromGUIChange(gener.segs-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, 1f, .7f, .9f);
             * pos = new Vector3(gener.radius, 0, handleSizer*2);
             * if(Handles.Button(pos, Quaternion.Euler(0,0,0), handleSizer, handleSizer, Handles.ConeCap))
             * {
             *      Undo.RegisterCompleteObjectUndo (parametricObject.model, "Segs");
             *
             *      gener.P_Segs.intiateRipple_setIntValueFromGUIChange(gener.segs+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,  -y/4, -handleSizer*4), ""+(gener.segs) + " segs", labelStyle);
             */


            // ANGLESWEEP KNOB

            /*
             * Handles.color = brightOrange;
             * Handles.SphereCap(0,
             *      new Vector3(gener.radius, 0, 0),
             *      Quaternion.identity,
             *      .15f*HandleUtility.GetHandleSize(pos));
             */

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



            Handles.matrix = prevHandlesMatrix;
        }
Пример #21
0
        protected override void HandleCommand(CommandPacket commandPacket)
        {
            try
            {
                switch (commandPacket.Command)
                {
                case ServerCommands.GENERATE:
                {
                    var kind          = commandPacket.Arguments.Single(a => a.Key == "Kind").Value;
                    var generatorKind = EnumUtils.GetValue <GeneratorKind>(((string)kind).ToTitleCase());

                    if (generatorKind == GeneratorKind.App)
                    {
                        var    entitiesProjectPath = commandPacket.Arguments.Single(a => a.Key == "EntitiesProjectPath").Value;
                        var    servicesProjectPath = commandPacket.Arguments.Single(a => a.Key == "ServicesProjectPath").Value;
                        var    generatorPass       = EnumUtils.GetValue <GeneratorPass>((string)commandPacket.Arguments.Single(a => a.Key == "GeneratorPass").Value);
                        var    noFileCreation      = bool.Parse(commandPacket.Arguments.Single(a => a.Key == "NoFileCreation").Value.ToString());
                        var    projectFolderRoot   = currentWorkingDirectory;
                        object packageCachePath    = null;

                        if (commandPacket.Arguments.Any(a => a.Key == "PackageCachePath"))
                        {
                            packageCachePath = commandPacket.Arguments.Single(a => a.Key == "PackageCachePath").Value;
                        }

                        generatorHandler = new GeneratorHandler();

                        webApiService.GeneratorHandler       = generatorHandler;
                        generatorHandler.SuppressDebugOutput = true;

                        generatorHandler.Execute(new Dictionary <string, object>
                            {
                                { "GeneratorKind", generatorKind },
                                { "EntitiesProjectPath", entitiesProjectPath },
                                { "ServicesProjectPath", servicesProjectPath },
                                { "PackageCachePath", packageCachePath },
                                { "GeneratorMode", GeneratorMode.RedirectedConsole },
                                { "GeneratorOptions", new RedirectedGeneratorOptions(outputWriter, errorWriter, generatorPass, noFileCreation) }
                            });
                    }
                    else if (generatorKind == GeneratorKind.BusinessModel)
                    {
                        var generatorPass     = EnumUtils.GetValue <GeneratorPass>((string)commandPacket.Arguments.Single(a => a.Key == "GeneratorPass").Value);
                        var noFileCreation    = bool.Parse(commandPacket.Arguments.Single(a => a.Key == "NoFileCreation").Value.ToString());
                        var templateFile      = commandPacket.Arguments.Single(a => a.Key == "TemplateFile").Value.ToString();
                        var projectFolderRoot = currentWorkingDirectory;

                        generatorHandler = new GeneratorHandler();

                        webApiService.GeneratorHandler       = generatorHandler;
                        generatorHandler.SuppressDebugOutput = true;

                        generatorHandler.Execute(new Dictionary <string, object>
                            {
                                { "GeneratorKind", generatorKind },
                                { "TemplateFile", templateFile },
                                { "GeneratorMode", GeneratorMode.RedirectedConsole },
                                { "GeneratorOptions", new RedirectedGeneratorOptions(outputWriter, errorWriter, generatorPass, noFileCreation) }
                            });
                    }
                    else if (generatorKind == GeneratorKind.Entities)
                    {
                        var generatorPass       = EnumUtils.GetValue <GeneratorPass>((string)commandPacket.Arguments.Single(a => a.Key == "GeneratorPass").Value);
                        var noFileCreation      = bool.Parse(commandPacket.Arguments.Single(a => a.Key == "NoFileCreation").Value.ToString());
                        var templateFile        = commandPacket.Arguments.Single(a => a.Key == "TemplateFile").Value.ToString();
                        var jsonFile            = commandPacket.Arguments.Single(a => a.Key == "JsonFile").Value.ToString();
                        var businessModelFile   = commandPacket.Arguments.Single(a => a.Key == "BusinessModelFile").Value.ToString();
                        var entitiesProjectPath = commandPacket.Arguments.Single(a => a.Key == "EntitiesProjectPath").Value;
                        var projectFolderRoot   = currentWorkingDirectory;

                        generatorHandler = new GeneratorHandler();

                        webApiService.GeneratorHandler       = generatorHandler;
                        generatorHandler.SuppressDebugOutput = true;

                        generatorHandler.Execute(new Dictionary <string, object>
                            {
                                { "GeneratorKind", generatorKind },
                                { "TemplateFile", templateFile },
                                { "JsonFile", jsonFile },
                                { "BusinessModelFile", businessModelFile },
                                { "EntitiesProjectPath", entitiesProjectPath },
                                { "GeneratorMode", GeneratorMode.RedirectedConsole },
                                { "GeneratorOptions", new RedirectedGeneratorOptions(outputWriter, errorWriter, generatorPass, noFileCreation) }
                            });
                    }
                    else if (generatorKind == GeneratorKind.Workspace)
                    {
                        var generatorPass     = EnumUtils.GetValue <GeneratorPass>((string)commandPacket.Arguments.Single(a => a.Key == "GeneratorPass").Value);
                        var noFileCreation    = bool.Parse(commandPacket.Arguments.Single(a => a.Key == "NoFileCreation").Value.ToString());
                        var appName           = commandPacket.Arguments.Single(a => a.Key == "AppName").Value.ToString();
                        var appDescription    = commandPacket.Arguments.Single(a => a.Key == "AppDescription").Value.ToString();
                        var projectFolderRoot = currentWorkingDirectory;

                        generatorHandler = new GeneratorHandler();

                        webApiService.GeneratorHandler       = generatorHandler;
                        generatorHandler.SuppressDebugOutput = true;

                        generatorHandler.Execute(new Dictionary <string, object>
                            {
                                { "GeneratorKind", generatorKind },
                                { "AppName", appName },
                                { "AppDescription", appDescription },
                                { "GeneratorMode", GeneratorMode.RedirectedConsole },
                                { "GeneratorOptions", new RedirectedGeneratorOptions(outputWriter, errorWriter, generatorPass, noFileCreation) }
                            });
                    }
                }

                break;

                case ServerCommands.TERMINATE:
                {
                    if (generatorHandler != null)
                    {
                        var config = generatorHandler.GeneratorConfiguration;

                        commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, "Terminating");
                        outputWriter.WriteJsonCommand(commandPacket, null);

                        config.StopServices();

                        outputWriter.WriteLine(Environment.NewLine);
                    }
                    else
                    {
                        commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, "Terminating");
                        outputWriter.WriteJsonCommand(commandPacket);
                    }

                    this.Stop();
                }

                break;

                case ServerCommands.CONNECT:
                {
                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, "Connected successfully");
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.PING:
                {
                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, "Success");
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_VERSION:
                {
                    var version = Assembly.GetEntryAssembly().GetAttributes().Version;

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, version);
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FOLDER:
                {
                    var relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var config       = generatorHandler.GeneratorConfiguration;
                    var folder       = (Folder)config.FileSystem[relativePath];

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, folder);
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FILE:
                {
                    var relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var config       = generatorHandler.GeneratorConfiguration;
                    var file         = (File)config.FileSystem[relativePath];

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, file);
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FOLDERS:
                {
                    var relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var config       = generatorHandler.GeneratorConfiguration;
                    var folder       = (Folder)config.FileSystem[relativePath];

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, folder.Folders.ToArray());
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FILES:
                {
                    var relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var config       = generatorHandler.GeneratorConfiguration;
                    var folder       = (Folder)config.FileSystem[relativePath];

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, folder.Files.ToArray());
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_PACKAGE_INSTALLS:
                {
                    var config          = generatorHandler.GeneratorConfiguration;
                    var packageInstalls = config.PackageInstalls;

                    // kn todo - comment
                    // packageInstalls = packageInstalls.Randomize().Take(5).ToList();
                    // packageInstalls = new List<string> { "@gracesnoh/tiny" };

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, packageInstalls.ToArray());
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_PACKAGE_DEV_INSTALLS:
                {
                    var config             = generatorHandler.GeneratorConfiguration;
                    var packageDevInstalls = config.PackageDevInstalls;

                    // kn todo - comment
                    // packageDevInstalls = packageDevInstalls.Randomize().Take(2).ToList();
                    // packageDevInstalls = new List<string> { "@gracesnoh/tiny" };

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, packageDevInstalls.ToArray());
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_CACHE_STATUS:
                {
                    var config      = generatorHandler.GeneratorConfiguration;
                    var mode        = (string)commandPacket.Arguments.Single(a => a.Key == "mode").Value;
                    var cacheStatus = config.GetCacheStatus(mode, true);

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, cacheStatus);
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.SET_INSTALL_STATUS:
                {
                    var config = generatorHandler.GeneratorConfiguration;
                    var status = (string)commandPacket.Arguments.Single(a => a.Key == "status").Value;
                    var result = config.SetInstallStatus(status);

                    commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, result);
                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FILE_ICON:
                {
                    var relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var config       = generatorHandler.GeneratorConfiguration;
                    var file         = (File)config.FileSystem[relativePath];
                    var bitmap       = file.Icon.ToBitmap();

                    bitmap.MakeTransparent(Color.Black);

                    using (var stream = new System.IO.MemoryStream())
                    {
                        bitmap.Save(stream, ImageFormat.Gif);
                        stream.Flush();
                        stream.Rewind();

                        commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, stream.ToBase64() + Environment.NewLine.Repeat(2));
                    }

                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                case ServerCommands.GET_FILE_CONTENTS:
                {
                    var    relativePath = (string)commandPacket.Arguments.Single(a => a.Key == "relativePath").Value;
                    var    config       = generatorHandler.GeneratorConfiguration;
                    var    file         = (File)config.FileSystem[relativePath];
                    var    fileInfo     = file.SystemLocalFile;
                    byte[] contents;

                    if (fileInfo.Exists)
                    {
                        contents = System.IO.File.ReadAllBytes(fileInfo.FullName);
                    }
                    else
                    {
                        contents = file.Info.ToString().ToBytes();
                    }

                    using (var stream = new System.IO.MemoryStream())
                    {
                        stream.Write(contents, 0, contents.Length);
                        stream.Flush();
                        stream.Rewind();

                        commandPacket = new CommandPacket(commandPacket.Command, commandPacket.SentTimestamp, stream.ToBase64() + Environment.NewLine.Repeat(2));
                    }

                    outputWriter.WriteJsonCommand(commandPacket);
                }

                break;

                default:
                    DebugUtils.Break();
                    break;
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                errorWriter.Write(ex.ToString());
#else
                errorWriter.Write(ex.Message);
#endif
                errorWriter.Flush();

                Environment.Exit(1);
            }
        }
Пример #22
0
        public bool Call(List <string> parameters)
        {
            if (parameters == null)
            {
                Console.WriteLine("This command needs parameters");
                return(false);
            }

            bool   result      = false;
            string project     = null;
            string projectPath = null;

            switch (parameters[0])
            {
            case "customUI":
                CustomUIHandler.GenerateDefaultCustomUI();
                break;

            case "excel-file":
                string excel        = null;
                string excelPath    = null;
                string customUI     = null;
                string customUIPath = null;
                bool   exe          = SwitchesHandler.UsesExecutablePaths(ref parameters) == 1;
                bool   ignore       = SwitchesHandler.UsesIgnoreConfiguration(ref parameters) == 1;

                if (exe && ignore)
                {
                    Console.WriteLine("Only one switch can be used between '/e' and '/ic'");
                    return(false);
                }

                switch (parameters.Count)
                {
                case 1:
                    break;

                case 2:
                    excel = parameters[1];
                    break;

                case 3:
                    excel     = parameters[1];
                    excelPath = parameters[2];
                    break;

                case 4:
                    excel     = parameters[1];
                    excelPath = parameters[2];
                    customUI  = parameters[3];
                    break;

                case 5:
                    excel        = parameters[1];
                    excelPath    = parameters[2];
                    customUI     = parameters[3];
                    customUIPath = parameters[4];
                    break;

                default:
                    Console.WriteLine("Not valid number of parameters");
                    return(false);
                }
                result = GeneratorHandler.CreateExcelFile(exe, ignore, excel, excelPath, customUI, customUIPath);
                break;

            case "project":
                switch (parameters.Count)
                {
                // If not name is asigned, excel will try to create 'project.xlsm' file
                case 1:
                    break;

                case 2:
                    project = parameters[1];
                    break;

                case 3:
                    project     = parameters[1];
                    projectPath = parameters[2];
                    break;

                default:
                    Console.WriteLine("Not valid number of parameters");
                    return(false);
                }
                result = GeneratorHandler.CreateProject(project, projectPath);
                break;

            default:
                Console.WriteLine($"Option '{parameters[0]}' is not valid");
                result = false;
                break;
            }
            return(result);
        }
        public override void drawControlHandles(ref List <string> visited, Matrix4x4 consumerM, bool beingDrawnFromConsumer)
        {
            if (alreadyVisited(ref visited, "LinearRepeater2DHandler"))
            {
                return;
            }

            Matrix4x4 prevHandlesMatrix = Handles.matrix;

            base.drawControlHandles(ref visited, consumerM, beingDrawnFromConsumer);


            RepeaterTool repeaterToolU = (parametricObject.generator as LinearRepeater2D).repeaterToolU;



            if (repeaterToolU != null)
            {
                // DRAW GRID
                Handles.color = new Color(1, .5f, 0, .4f);


                if (!beingDrawnFromConsumer)
                {
                    consumerM *= generator.parametricObject.getLocalMatrix().inverse;
                    consumerM *= parametricObject.getAxisRotationMatrix();
                }

                consumerM *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);

                //consumerM *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(90, 0, 0), Vector3.one);


                Matrix4x4 context = parametricObject.model.transform.localToWorldMatrix * generator.parametricObject.worldDisplayMatrix * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one);



                Handles.matrix = context;

                for (int i = 0; i <= repeaterToolU.cells; i++)
                {
                    Handles.DrawLine(new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, 0), new Vector3(-repeaterToolU.size / 2 + i * repeaterToolU.actualBay, 0, 0));
                }



                // ASK RepeaterTools to DRAW
                GeneratorHandler gh = getGeneratorHandler(repeaterToolU.parametricObject);

                if (gh != null)
                {
                    Handles.matrix = context * Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.Euler(90, 0, 0), Vector3.one);

                    gh.drawBoundsHandles(context, true);

                    //List<string> _visited = new List<string>();
                    gh.drawControlHandles(ref visited, consumerM, true);
                }
            }


            // MATRIX

            drawControlHandlesofInputParametricObjects(ref visited, consumerM * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(-90, 0, 0), Vector3.one), true);

            Handles.matrix = prevHandlesMatrix;
        }