예제 #1
0
        public static bool selectedpoints; //The point selected in order to

        //Create and show the axis
        public void Show()
        {
            L1 = new List <GameObject>();
            L2 = new List <GameObject>();
            L3 = new List <GameObject>();

            dataPoints = ScatterPlot.GetDataPoints();
            //Compute the max and min position
            foreach (DataPoint dp in dataPoints)
            {
                Min = Vector3.Min(dp.GetPos(), Min);
                Max = Vector3.Max(dp.GetPos(), Max);
            }
            Moy = (Max - Min) / 2;
            //Creation of the main axis in black
            AxeX = Instantiate(Resources.Load("Prefab/MainCylinder", typeof(GameObject)), new Vector3(Moy.x, 0, 0) + Min, Quaternion.Euler(0, 0, 90)) as GameObject;
            AxeX.transform.parent = gameObject.transform;
            AxeY = Instantiate(Resources.Load("Prefab/MainCylinder", typeof(GameObject)), new Vector3(0, Moy.y, 0) + Min, Quaternion.Euler(0, 90, 0)) as GameObject;
            AxeY.transform.parent = gameObject.transform;
            AxeZ = Instantiate(Resources.Load("Prefab/MainCylinder", typeof(GameObject)), new Vector3(0, 0, Moy.z) + Min, Quaternion.Euler(90, 0, 0)) as GameObject;
            AxeZ.transform.parent = gameObject.transform;
            Vector3 ecart  = Max - Min;
            Vector3 increm = ecart / nbGraduation;
            int     j      = 0;

            //Creation of the numbered axis in white
            while (j < nbGraduation)
            {
                L1.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(Moy.x, 0, increm.z) + Min, Quaternion.Euler(0, 0, 90)) as GameObject);
                L1.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(Moy.x, increm.y, 0) + Min, Quaternion.Euler(0, 0, 90)) as GameObject);
                L2.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(0, Moy.y, increm.z) + Min, Quaternion.Euler(0, 90, 0)) as GameObject);
                L2.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(increm.x, Moy.y, 0) + Min, Quaternion.Euler(0, 90, 0)) as GameObject);
                L3.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(increm.x, 0, Moy.z) + Min, Quaternion.Euler(90, 0, 0)) as GameObject);
                L3.Add(Instantiate(Resources.Load("Prefab/Cylinder", typeof(GameObject)), new Vector3(0, increm.y, Moy.z) + Min, Quaternion.Euler(90, 0, 0)) as GameObject);
                increm += ecart / nbGraduation;
                j++;
            }
            //Resize of the different axis
            AxeX.transform.localScale = new Vector3((float)2 * sharpness, Moy.x, (float)2 * sharpness);
            AxeY.transform.localScale = new Vector3((float)2 * sharpness, Moy.y, (float)2 * sharpness);
            AxeZ.transform.localScale = new Vector3((float)2 * sharpness, Moy.z, (float)2 * sharpness);
            foreach (GameObject i in L1)
            {
                i.transform.localScale = new Vector3((float)sharpness, Moy.x, (float)sharpness);
                i.transform.parent     = gameObject.transform;
            }
            foreach (GameObject i in L2)
            {
                i.transform.localScale = new Vector3((float)sharpness, Moy.y, (float)sharpness);
                i.transform.parent     = gameObject.transform;
            }
            foreach (GameObject i in L3)
            {
                i.transform.localScale = new Vector3((float)sharpness, Moy.z, (float)sharpness);
                i.transform.parent     = gameObject.transform;
            }
        }
예제 #2
0
        // Update is called once per frame
        void Update()
        {
            if (cMenu.GetCurrentMenu() == CurrentMenu.Menu.Statistics)
            {
                if (!StatisticsCanvas.enabled)
                {
                    // Enables the canvas
                    StatisticsCanvas.enabled = !StatisticsCanvas.enabled;

                    //Loads and displays the general statistics
                    pointCount        = pointCloud.GetLoadedPointsCount();
                    GeneralStats.text = "NUMBER OF POINTS : " + pointCount + "\n \n ";

                    //Loads and displays the dynamic statistics
                    volumes            = FindObjectsOfType <MeshDeformerMove>();
                    GeneralStats.text += "NUMBER OF MESHES : " + volumes.Length + "\n";
                    DynamicStats.text  = "THESE ARE THE MESHES YOU HAVE CREATED SO FAR :\n \n \n";
                    BoolStats.text     = "THESE ARE THE OPERATIONS YOU HAVE MADE SO FAR : \n \n \n";
                    List <List <DataPoint> > selectionSets = new List <List <DataPoint> >();
                    List <List <DataPoint> > boolSets      = new List <List <DataPoint> >();


                    for (int i = 0; i < volumes.Length; i++)
                    {
                        selectionSets.Add(ScatterPlot.GetSelectedPoints(volumes[i]));
                        DynamicStats.text += (" - Set number " + i + " contains : " + selectionSets[i].Count + " points \n");
                        DynamicStats.text += (" Average position of the points : " + AveragePosition(selectionSets[i]) + "\n");
                        DynamicStats.text += (" Position of the Mesh : " + volumes[i].transform.position + "\n");
                        DynamicStats.text += (" Dominant color : " + DominantColor(selectionSets[i]) + "\n \n");

                        //Saves a csv file
                        toCSV(selectionSets[i], "selection", i);
                    }

                    boolSets = boolOperation.GetOperationData();
                    for (int i = 0; i < boolSets.Count; i++)
                    {
                        BoolStats.text += (" - Operation number " + i + " contains : " + boolSets[i].Count + " points \n");
                        BoolStats.text += (" Average position of the points : " + AveragePosition(boolSets[i]) + "\n");
                        BoolStats.text += (" Dominant color : " + DominantColor(boolSets[i]) + "\n \n");

                        toCSV(boolSets[i], "booloperation", i);
                    }
                }
            }
            else
            {
                //Disables the canvas
                if (StatisticsCanvas.enabled)
                {
                    StatisticsCanvas.enabled = !StatisticsCanvas.enabled;
                }
            }
        }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     // Gets all the information about the points
     StatisticsCanvas = GetComponent <Canvas>();
     cMenu            = GameObject.Find("Palm UI L").GetComponent <CurrentMenu>();
     pointCloud       = GameObject.Find("ScatterPlot").GetComponent <ScatterPlot>();
     boolOperation    = GameObject.Find("BooleanOperation").GetComponent <BoolOperation>();
     GeneralStats     = GameObject.Find("GeneralStats").GetComponent <Text>();
     DynamicStats     = GameObject.Find("DynamicStats").GetComponent <Text>();
     BoolStats        = GameObject.Find("BoolStats").GetComponent <Text>();
 }
예제 #4
0
        int test;                                                 //Allow to choose only one menu at once

        //Save the first selection et the operation chosen
        private void BoolUpdate(Operator Method)
        {
            if (currentSelectedDataPoints.Count == 0)
            {
                selectedPoints = ScatterPlot.GetSelectedPoints(currentVolume);
            }
            else
            {
                foreach (DataPoint dp in currentSelectedDataPoints)
                {
                    selectedPoints.Add(dp);
                }
            }
            MethodOperator = Method;
        }
예제 #5
0
        //Update function with the Menu
        private void Update()
        {
            if (CurrentMenu.Menu.Selection == cMenu.GetCurrentMenu() && currentVolume != null)
            {
                if (CurrentMenu.Selection.SetOperation == cMenu.GetCurrentMenuSelection())
                {
                    switch (cMenu.GetCurrentMenuSetOperation())
                    {
                    case CurrentMenu.SetOperation.SetUnion:
                        if (test != 0)
                        {
                            BoolUpdate(OrBoolOperation);
                            test = 0;
                        }
                        break;

                    case CurrentMenu.SetOperation.SetIntersection:
                        if (test != 1)
                        {
                            BoolUpdate(AndBoolOperation);
                            test = 1;
                        }
                        break;

                    case CurrentMenu.SetOperation.SetRelativeComplement:
                        if (test != 2)
                        {
                            BoolUpdate(NotInBoolOperation);
                            test = 2;
                        }
                        break;

                    default:
                        if (cMenu.SetOperationIsConfirmed() && test != 3)
                        {
                            currentSelectedDataPoints = ScatterPlot.GetSelectedPoints(currentVolume);
                            currentSelectedDataPoints = BoolOperationMain(currentSelectedDataPoints);
                            OperationData.Add(new List <DataPoint>(currentSelectedDataPoints));
                            Coloration(currentSelectedDataPoints);
                            cMenu.ResetSetOperation();
                            test = 3;
                        }
                        break;
                    }
                }
            }
        }
예제 #6
0
        /**
         * Unselect all vertices
         */
        public void UnselectVertices()
        {
            //if (DetectSelfIntersection())
            //{
            //    for (int i = 0; i < vertices.Length; i++)
            //    {
            //        if (selectedVertices[i])
            //            vertices[i] = originPos[i];
            //    }
            //    Debug.Log("Self intersection detected");
            //    UpdateMeshVertices();
            //}

            for (int i = 0; i < selectedVertices.Length; i++)
            {
                selectedVertices[i] = false;
            }

            // update collider, update point selected
            meshCollider.enabled = false;
            meshCollider.enabled = true;
            ScatterPlot.GetSelectedPoints(this);
        }