Beispiel #1
0
    void OnGUI()
    {
        //Display tracking and selected tetrahedrons
        if (selection.Count == 1)
        {
            ui.singleTracking(trackingActive, selection[0].name);

            if (trackingActive)
            {
                if (edgeView)
                {
                    foreach (Tetrahedron tetrahedron in selection[0].tetrahedrons)
                    {
                        if (tetrahedron.type != 2)
                        {
                            foreach (Side side in tetrahedron.sides)
                            {
                                Vector3 finalPos = TetraUtil.averageVertices(side.vertices, selection[0].transform);

                                ui.numberAtPos(finalPos, side.ID, false, "s");
                            }
                        }
                    }
                }
                else
                {
                    foreach (Vertex vertex in selection[0].vertices)
                    {
                        Vector3 tempPos = selection[0].transform.TransformPoint(vertex.pos);

                        ui.numberAtPos(tempPos, vertex.ID, selection[0].newTetraVtx.Contains(vertex.ID));
                    }
                }
            }
        }
        else if (selection.Count > 1)
        {
            ui.multipleTracking(trackingActive, selection.Count);
        }

        ui.loop();

        inc.loop();
    }
Beispiel #2
0
    //Physics update, runs repeatedly
    void FixedUpdate()
    {
        //Sets center of mass
        centerMass = TetraUtil.averageVertices(vertices, this.transform);

        if (tr == null)
        {
            Start();
        }

        //Tells tetraRenderer to pick color
        if (!colorPicked)
        {
            colorPicked = true;
            tr.pickRandomColor();
        }

        //Runs setup of tetrahedrons
        if (runSetup)
        {
            runSetup = false;
            setupTetras();
        }

        //Sets side lengths in tetrahedrons
        int p = 0;

        bool          quickSetReset = false;
        HashSet <int> alreadySetIDs = new HashSet <int>();

        foreach (Tetrahedron tetrahedron in tetrahedrons)
        {
            if (tetrahedron.type != 2)
            {
                foreach (Side side in tetrahedron.sides)
                {
                    if (sideSetList.Count < p + 1)
                    {
                        sideSetList.Add(2.0f);
                    }

                    if (disphenoidMode)
                    {
                        foreach (Side tempSide in oppositeSide(tetrahedron, side))
                        {
                            if (!alreadySetIDs.Contains(tempSide.ID))
                            {
                                sideSetList[tempSide.ID] = sideSetList[side.ID];
                            }
                        }

                        alreadySetIDs.Add(side.ID);
                    }

                    if (quickSideSet)
                    {
                        quickSetReset = true;
                        side.length   = sideSetList[p];
                    }
                    else
                    {
                        side.length = Mathf.SmoothStep(side.length, sideSetList[p], 0.10f);
                    }

                    side.ID = p;

                    if (runOppositeSide && p == sideVal)
                    {
                        runOppositeSide = false;
                        Debug.Log("----------");
                        int oppositeID = oppositeSide(tetrahedron, side)[0].ID;
                        Debug.Log("Opposite side is: " + oppositeID);
                    }

                    p++;
                }
            }
        }

        if (quickSetReset)
        {
            quickSideSet = false;
        }

        //Runs loop of tetrahedrons
        foreach (Tetrahedron tetra in tetrahedrons)
        {
            tetra.loop();
        }

        //Catches if tetraRenderer does not exist
        if (tr == null)
        {
            tr = new TetraRenderer(this.gameObject);
        }

        //Loops tetraRenderer
        tr.loop();

        if (tetrahedrons.Count == 1 && walkControl)
        {
            sw.loop();
        }
    }