コード例 #1
0
    public void AddLine()
    {
        int i;

        SelectedLine = Spirographe.GetActiveSpiroFormule();
        SelectedLine.profondeur++;
        i = SelectedLine.profondeur - 1;     //avant dernière ligne avant le crayon
        TextNumeroDisque.GetComponent <Text>().text = (i + 1).ToString();
        int NbLignesCrees = PanelLignes.transform.childCount;

        if (NbLignesCrees < SelectedLine.profondeur)
        {
            IFR.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().index = i;
            IFR.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().RefreshContent();
            IFF.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().index = i;
            IFF.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().RefreshContent();
            IFRO.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().index = i;
            IFRO.GetComponent <InputField>().GetComponent <InputFieldPanelDisques>().RefreshContent();
            ToggleActiveDisque.GetComponent <ToggleRotAxe>().index = i;
            ToggleActiveDisque.GetComponent <ToggleRotAxe>().RefreshContent();
            GameObject NewLine = Instantiate(LigneSpiro);
            NewLine.name = "Ligne" + (i).ToString();
            NewLine.SetActive(true);
            NewLine.transform.SetParent(PanelLignes.transform, false);
        }
        else
        {
            PanelLignes.transform.GetChild(i).gameObject.SetActive(true);
        }
        RefreshPanel();
        //PanelOptionTousDisques.GetComponent<PanelOptionTousDisques>().BuildPanel(); //refresh panel tous disques too
        Spirographe.ValueChange();         //Call ValueChange Event
    }
コード例 #2
0
 void Start()
 {
     SelectedLine   = Spirographe.GetActiveSpiroFormule();
     lineRenderer   = SelectedLine.GetComponent <LineRenderer>();
     HeaderFileName = string.Format("{0}/SVG/", Application.dataPath) + HeaderFileName;
     FooterFileName = string.Format("{0}/SVG/", Application.dataPath) + FooterFileName;
 }
コード例 #3
0
    public void DeleteLine(GameObject TextNameLineToDelete)
    {
        int        NbChildren, LineToActivate;
        GameObject NewTextNameLine;
        bool       isSelected;

        GetActiveLine();

        NbChildren = GameObject.Find("ListSpiro").transform.childCount;
        if (NbChildren > 1)
        {
            NameLine   = TextNameLineToDelete.transform.Find("TextName").GetComponent <Text>();
            isSelected = (NameLine.color == selected);
            if (TextNameLineToDelete.transform.GetSiblingIndex() == (NbChildren - 1))
            {
                LineToActivate = NbChildren - 2;
            }
            else
            {
                LineToActivate = NbChildren - 1;
            }
            SelectedLine = GameObject.Find(GameObject.Find("ListSpiro").transform.GetChild(NbChildren - 1).transform.Find("TextName").GetComponent <Text>().text).GetComponent <SpiroFormule>();
            Destroy(GameObject.Find(NameLine.text));
            Destroy(TextNameLineToDelete);
            NewTextNameLine = GameObject.Find("ListSpiro").transform.GetChild(LineToActivate).gameObject;
            if (isSelected)
            {
                NewTextNameLine.transform.Find("SelectButton").gameObject.GetComponent <SelectButton>().SelectLine();
            }
        }
    }
コード例 #4
0
ファイル: MultiSpiro.cs プロジェクト: nicolas-oss/Spirographe
    void Start()
    {
        Line1         = Spiro1.GetComponent <LineRenderer>();
        Line2         = Spiro2.GetComponent <LineRenderer>();
        spiroFormule1 = Spiro1.GetComponent <SpiroFormule>();
        spiroFormule2 = Spiro2.GetComponent <SpiroFormule>();
        N1            = Line1.positionCount;
        N2            = Line2.positionCount;
        if (Line1.positionCount < Line2.positionCount)
        {
            NbrPts = Line2.positionCount;
        }
        else
        {
            NbrPts = Line1.positionCount;
        }
        Line = GetComponent <LineRenderer>();
        Line.positionCount = NbrPts * multiple;

        if (L1 == 0)
        {
            L1 = 1.0f;
        }
        if (L2 == 0)
        {
            L2 = 1.0f;
        }
    }
コード例 #5
0
 public static void Selection()
 {
     //Debug.Log("Calling event SelectionLine");
     if (onSelectionLine != null)
     {
         SelectedLine        = GetActiveSpiroFormule();
         SelectedAspect      = GetActiveAspect();
         SelectedMultiSpiro  = GetActiveMultiSpiro();
         ActiveObjectInScene = GetActiveObject();
         onSelectionLine();
     }
 }
コード例 #6
0
    public void DeleteLine()
    {
        GameObject LastLine;

        SelectedLine = Spirographe.GetActiveSpiroFormule();
        if (SelectedLine.profondeur > 3)
        {
            SelectedLine.profondeur--;
            LastLine = PanelLignes.transform.GetChild(SelectedLine.profondeur).gameObject;
            //RemoveEventsFromLine(LastLine);
            //Destroy(LastLine);
            LastLine.SetActive(false);
        }
        RefreshPanel();
        //PanelOptionTousDisques.GetComponent<PanelOptionTousDisques>().BuildPanel(); //refresh panel tous disques too
        Spirographe.ValueChange();         //Call ValueChange Event
    }
コード例 #7
0
    public void RefreshPanel()
    {
        SelectedLine = Spirographe.GetActiveSpiroFormule();
        InputFieldPanelDisques[] ZOB;
        ToggleRotAxe[]           BIT;
        ZOB = PanelLignes.GetComponentsInChildren <InputFieldPanelDisques>();            //Get all InputFieldPanelDisques in PanelLignes
        foreach (InputFieldPanelDisques IF in ZOB)
        {
            IF.gameObject.GetComponent <InputFieldPanelDisques>().RefreshContent();  //RefreshContent of all InputFieldPanelDisques in PanelLignes
        }

        BIT = PanelLignes.GetComponentsInChildren <ToggleRotAxe>();                                             //Get all ToggleRotAxe in PanelLignes
        foreach (ToggleRotAxe TRA in BIT)
        {
            TRA.gameObject.GetComponent <ToggleRotAxe>().RefreshContent();                       //RefreshContent of all ToggleRotAxe in PanelLignes
        }
        int        profondeur    = SelectedLine.profondeur;
        int        NbLignesCrees = PanelLignes.transform.childCount;
        GameObject LineCurr      = PanelLignes.transform.GetChild(0).gameObject;

        for (int i = 0; i < NbLignesCrees; i++)                                                                                         // on n'affiche que les lignes d'indice inférieur à profondeur
        {
            LineCurr = PanelLignes.transform.GetChild(i).gameObject;
            if (i < profondeur)
            {
                LineCurr.SetActive(true);
            }
            else
            {
                LineCurr.SetActive(false);
            }
        }

        RefreshCochesActivation();
        RefreshFacteurTransmission();
        PanelOptionTousDisques.GetComponent <PanelOptionTousDisques>().BuildPanel();        //refresh panel tous disques too
    }
コード例 #8
0
 public void GetActiveLine()
 {
     ActiveObjectInScene = Spirographe.GetActiveObject();
     SelectedLine        = Spirographe.GetActiveSpiroFormule();
 }
コード例 #9
0
    public void BuildPanel()
    {
        int profondeur;

        SpiroParametrableActive = Spirographe.GetActiveObject();
        SelectedLine            = Spirographe.GetActiveSpiroFormule();
        if (SelectedLine == null)
        {
            profondeur = 0;
        }
        else
        {
            profondeur = SelectedLine.profondeur;
        }
        int NbLignesCrees = PanelLignes.transform.childCount;

        for (int i = 0; i < profondeur; i++)
        {
            if (i < NbLignesCrees)
            {
                LineCurr = PanelLignes.transform.GetChild(i).gameObject;
                LineCurr.SetActive(true);
            }
            else
            {
                TextNumeroDisque.GetComponent <Text>().text = (i + 1).ToString();
                InitField(ref IFR, i);
                InitField(ref IFRO, i);
                InitField(ref IFA, i);
                InitField(ref IFV, i);
                InitField(ref IFP, i);
                InitField(ref IFF, i);
                ToggleAnimation.GetComponent <ToggleAnimRayon>().index = i;
                ToggleAnimation.GetComponent <ToggleAnimRayon>().RefreshContent();
                ToggleActiveDisque.GetComponent <ToggleRotAxe>().index = i;
                ToggleActiveDisque.GetComponent <ToggleRotAxe>().RefreshContent();
                GameObject NewLine = Instantiate(LigneSpiro);
                NewLine.name = "Ligne" + (i).ToString();
                NewLine.SetActive(true);
                NewLine.transform.SetParent(PanelLignes.transform, false);
            }
        }
        //Reste à cacher les lignes restantes éventuelles :
        if (profondeur <= NbLignesCrees)
        {
            for (int i = profondeur; i < NbLignesCrees; i++)
            {
                PanelLignes.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        //Gestion affichage des coches RotAxe

        for (int i = 1; i < profondeur - 1; i++)
        {
            GetBackgroundActivation(i).SetActive(true);                 //on l'affiche
        }
        GetBackgroundActivation(0).SetActive(false);                    //on le cache
        GetBackgroundActivation(profondeur - 1).SetActive(false);       //on le cache

        RefreshFacteurTransmission();
    }
コード例 #10
0
    public void BuildPanel()
    {
        int        profondeur;
        GameObject LineCurr;         //

        //SpiroParametrableActive=Spirographe.GetActiveObject();
        SelectedLine = Spirographe.GetActiveSpiroFormule();
        if (SelectedLine == null)
        {
            profondeur = 0;
        }
        else
        {
            profondeur = SelectedLine.profondeur;
        }
        int NbLignesCrees = PanelLignes.transform.childCount;

        for (int i = 0; i < profondeur; i++)
        {
            if (i < NbLignesCrees)
            {
                LineCurr = PanelLignes.transform.GetChild(i).gameObject;
                LineCurr.SetActive(true);
            }
            else
            {
                TextNumeroDisque.GetComponent <Text>().text       = (i + 1).ToString();
                IFR.GetComponent <InputFieldPanelDisques>().index = i;
                IFR.GetComponent <InputFieldPanelDisques>().RefreshContent();
                IFR.GetComponent <InputFieldPanelDisques>().Start();
                IFF.GetComponent <InputFieldPanelDisques>().index = i;
                IFF.GetComponent <InputFieldPanelDisques>().RefreshContent();
                IFF.GetComponent <InputFieldPanelDisques>().Start();
                IFRO.GetComponent <InputFieldPanelDisques>().index = i;
                IFRO.GetComponent <InputFieldPanelDisques>().RefreshContent();
                IFRO.GetComponent <InputFieldPanelDisques>().Start();
                ToggleActiveDisque.GetComponent <ToggleRotAxe>().index = i;
                ToggleActiveDisque.GetComponent <ToggleRotAxe>().RefreshContent();
                GameObject NewLine = Instantiate(LigneSpiro);
                NewLine.name = "Ligne" + (i).ToString();
                NewLine.SetActive(true);
                NewLine.transform.SetParent(PanelLignes.transform, false);
            }
        }
        GetComponent <RectTransform>().ForceUpdateRectTransforms();
        //Debug.Log("Building Panel big");
        //Reste à cacher les lignes restantes éventuelles :
        if (profondeur <= NbLignesCrees)
        {
            for (int i = profondeur; i < NbLignesCrees; i++)
            {
                PanelLignes.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        //Gestion affichage des coches RotAxe

        /*if (profondeur>0)
         * {
         *      RefreshCochesActivation();
         *      RefreshFacteurTransmission();
         * }*/
        RefreshPanel();
    }
コード例 #11
0
ファイル: MultiSpiro.cs プロジェクト: nicolas-oss/Spirographe
    public void CalculeMultiSpiro()
    {
        //for (int j = 0; j<10;j++)
        //{
        //Start();
        if ((Line1 == null) || (Line2 == null))
        {
            return;
        }

        Line1         = Spiro1.GetComponent <LineRenderer>();
        Line2         = Spiro2.GetComponent <LineRenderer>();
        spiroFormule1 = Spiro1.GetComponent <SpiroFormule>();
        spiroFormule2 = Spiro2.GetComponent <SpiroFormule>();
        N1            = Line1.positionCount;
        N2            = Line2.positionCount;
        if (Line1.positionCount < Line2.positionCount)
        {
            NbrPts = Line2.positionCount;
        }
        else
        {
            NbrPts = Line1.positionCount;
        }
        Line = GetComponent <LineRenderer>();
        Line.positionCount = NbrPts * multiple;

        for (int i = 0; i < NbrPts * multiple; i++)
        {
            Root1.transform.position = Spiro1.transform.TransformPoint(Line1.GetPosition(i % (N1 - 1)));
            Root2.transform.position = Spiro2.transform.TransformPoint(Line2.GetPosition((int)(i * vitesseRelative % (N2 - 1))));
            A1   = Root1.transform.position;
            A2   = Root2.transform.position;
            L    = Vector3.Distance(A1, A2);
            A    = A2 - A1;
            beta = Mathf.Acos(A.x / L);

            if (L == 0.0f)
            {
                beta = 90;
            }
            else
            {
                beta *= 57.296f;
            }                                                         //conversion radian vers degres
            if (A.z < 0.0f)
            {
                beta = -beta;
            }

            if (L == 0.0f)
            {
                Debug.Log("WARNING DIVISION");
                L = 1.0f;
            }

            quotient = CalculQuotient();
            if (quotient > 1)
            {
                Debug.Log("WARNING ACOS trop grand");
                while (quotient > 1)
                {
                    L2      += 0.001f;
                    quotient = CalculQuotient();
                }
            }
            if (quotient < -1)
            {
                Debug.Log("WARNING ACOS trop petit");
                while (quotient < -1)
                {
                    L2      -= 0.01f;
                    quotient = CalculQuotient();
                }
            }
            alpha  = Mathf.Acos(quotient);
            alpha *= 57.296f;           //conversion radian vers degres

            position.x = L1;
            position.y = 0.0f;
            position.z = 0.0f;

            rotation.x = 0.0f;
            rotation.y = 0.0f;
            rotation.z = 0.0f;

            Root1.transform.localEulerAngles = rotation;                        //on applique la rotation de la contrainte Aim sur Root1
            Root1.transform.Rotate(0.0f, beta, 0.0f, Space.Self);

            Root1Rotation.transform.localEulerAngles = rotation;
            Root1Rotation.transform.Rotate(0.0f, alpha, 0.0f, Space.Self);
            Root1Rotation.transform.localPosition = position;
            globalPosition = Crayon.transform.position;
            if (profondeur)
            {
                globalPosition += 1.0f * i * facteur_profondeur * Vector3.up;
            }
            Line.SetPosition(i, globalPosition);
        }
    }