Пример #1
0
    //the main method for this script, used to go through all vertices (spheres) in the environment and update their positions
    private void getVertexStats()
    {
        //get all vertices (spheres)
        allVertices = GameObject.FindGameObjectsWithTag("Vertex");
        foreach (GameObject vertex in allVertices)
        {
            //get each vertexManager attached to current vertex (sphere)
            vertexManager = vertex.GetComponent <VertexManager>();

            //Set the vector variables according to the vertice (sphere) position. To do maths on later.
            xVector.Set(vertex.transform.position.x, 0f, 0f);
            yVector.Set(0f, vertex.transform.position.y, 0f);
            zVector.Set(0f, 0f, vertex.transform.position.z);

            //calculate the distance between the vertices (sphere) x, y, and z cords from the center.
            xDist = Vector3.Distance(gameObject.transform.position, xVector);
            yDist = Vector3.Distance(gameObject.transform.position, yVector);
            zDist = Vector3.Distance(gameObject.transform.position, zVector);

            if (vertexManager != null && vertexManager.getVertexID() != 0 && vertexManager.getVertexID() != vertexManager.getParentsLineManager().getNumberOfVertices() - 1)
            {
                //setting vertex volume by passing x^2 + z^2 to convert volume
                vertexManager.setVertexVolume(convertVolume((xDist * xDist) + (zDist * zDist)));

                //setting vertex timing by passing y distance.
                vertexManager.setVertexTiming(convertTiming(vertex.transform.position.y));

                //calling calculateAngle with the vertices (sphere) x and z cordinates, and then setting the vertices note accordingly.
                float vertexAngle = calculateAngle(vertexManager.transform.position.x, vertexManager.transform.position.z);
                vertexManager.setVertexAngle(vertexAngle);
                vertexManager.setVertexNote(convertAngle(vertexAngle));
            }
        }
    }
Пример #2
0
    //Method used to call drawVert(...) multiple time with the given Vector3[] of vertices
    private void drawVerts(Vector3[] currentVerts)
    {
        int vertexID = 0;

        foreach (var vert in currentVerts)
        {
            VertexManager newVert = drawVert(vert, vertexID, true).GetComponent <VertexManager>();
            if (vertexID == 0)
            {
                newVert.setVertexTiming(-1);
            }
            else if (vertexID == getNumberOfVertices() - 1)
            {
                newVert.setVertexTiming(GridManager.getYSegments());
            }
            vertexID++;
        }
    }