コード例 #1
0
    void loadImage(List <Transform> transfor, List <string> fig_name_lst)
    {
        // Design: let all of the figures show as a circle
        transform_lst = new List <Transform>();   // count of figures
        a             = 360 / fig_name_lst.Count; // unit angle
        // Debug.Log("unit angle a=" + a);
        print("The num of Fig: " + fig_name_lst.Count);

        // create instances for figures and render them
        for (int i = 0; i < fig_name_lst.Count; i++)
        {
            transform_lst.Add(Instantiate(Fig));
            addTexture(fig_name_lst[i], transform_lst[i]);
        }

        for (int i = 0; i < fig_name_lst.Count; i++)
        {
            // locate the figure
            // caculate the Quaternion coordinate from vector3 coordinate system
            q = Quaternion.AngleAxis(i * a + 180F, Vector3.up);

            // quanternion --> vector3
            // print("Rotation axis" + Vector3.up);
            // print("Rotation2: " + q);

            // revolution * Quaternion * Vector3 = Vector3
            transform_lst[i].position = new Vector3(0, 1, 0) + Quaternion.AngleAxis((i + 1) * a, Vector3.up) * Vector3.forward * 3;
            // rotation
            transform_lst[i].rotation = q;

            prepPos(transform_lst[i]);
            AccessData.UpdateEntries(i + 1, pos_x, pos_y, pos_z);
        }
    }