示例#1
0
    private void oeObjChart()
    {
        objMatrix = new GameObject[sizeX, sizeX];

        int ii = 0;

        for (int y = 0; y < sizeX; y++)
        {
            for (int x = 0; x < sizeX; x++)
            {
                switch (primitiveType.ToString())
                {
                case "Cube":
                    objMatrix[x, y] = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    break;

                case "Sphere":
                    objMatrix[x, y] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    break;

                case "Cylinder":
                    objMatrix[x, y] = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                    break;


                default:
                    objMatrix[x, y] = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    break;
                }
                //objMatrix[x, y] = go;

                //Rigidbody gameObjectsRigidBody = go.AddComponent<Rigidbody>(); // Add the rigidbody.
                //gameObjectsRigidBody.mass = oeMass; // Set the GO's mass to 5 via the Rigidbod
                //go.GetComponent<Rigidbody>().useGravity = true;
                objMatrix[x, y].name = nameObj + matrixIndex + "." + ii;
                //cubeMatrix2[i, j]

                float xi = (x + 1) / distanceDivide;
                float yi = (y + 1) / distanceDivide;
                float zi = 0;

                switch (chartType.ToString())
                {
                case "G1":
                    zi = (10) / distanceDivide;
                    break;

                case "G2":
                    zi = (x + y) / distanceDivide;
                    break;

                case "G3":
                    //zi = (Mathf.Sin(x/10) * Mathf.Cos(y/10)) / distanceDivide*5;
                    zi = (Mathf.Sin((float)x / 10) * Mathf.Cos((float)y / 10)) / distanceDivide * 5;
                    break;

                case "G4":
                    //zi = (Mathf.Sin(x/10) * Mathf.Cos(y/10)) / distanceDivide*5;
                    zi = (Mathf.Sin((float)x / 10) * Mathf.Cos((float)y / 10)) / distanceDivide * 5;
                    break;

                case "G5":
                    //zi = (Mathf.Sin(x/10) * Mathf.Cos(y/10)) / distanceDivide*5;
                    zi = (Mathf.Sin((float)x / 10) * Mathf.Cos((float)y / 10)) / distanceDivide * 5;
                    break;

                default:
                    zi = (x + y) / distanceDivide;
                    break;
                }

                if (transformXZ)
                {
                    float tempi = zi; zi = xi; xi = tempi;
                }
                if (transformYZ)
                {
                    tempi = zi; zi = yi; yi = tempi;
                }

                if (debugList)
                {
                    Debug.Log(objMatrix[x, y].name + ": " + xi + ", " + yi + ", " + zi);
                }
                objMatrix[x, y].transform.position   = new Vector3(startVector.x + xi, startVector.y + yi, startVector.z + zi);
                objMatrix[x, y].transform.localScale = new Vector3(scaleSize, scaleSize, scaleSize);

                //}
                //catch {  Debug.Log("Err: try Parse...");  }
                rend = objMatrix[x, y].GetComponent <Renderer>();
                rend.material.color = mainColor;
            }
            ii++;
        }
    }