//initialize the variables
    public void initialize()
    {
        hc = GetComponent <Mesh4>(); //not sure about syntax


        force4    = new Vector4(0, 0, 0, 0);
        position4 = new Vector4(0, 0, 0, 0);
        velocity4 = new Vector4(0, 0, 0, 0);
        linAccel4 = new Vector4(0, 0, 0, 0);
        position4 = new Vector4(0, 0, 0, 0);
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        //input coordinates of verticies of 4 shape
        float[] vertexCoords =
        {
            -1.0f, -1.0f, -1.0f, -1.0f,
            1.0f,  -1.0f, -1.0f, -1.0f,
            -1.0f,  1.0f, -1.0f, -1.0f,
            1.0f,   1.0f, -1.0f, -1.0f,
            -1.0f, -1.0f,  1.0f, -1.0f,
            1.0f,  -1.0f,  1.0f, -1.0f,
            -1.0f,  1.0f,  1.0f, -1.0f,
            1.0f,   1.0f,  1.0f, -1.0f,
            -1.0f, -1.0f, -1.0f,  1.0f,
            1.0f,  -1.0f, -1.0f,  1.0f,
            -1.0f,  1.0f, -1.0f,  1.0f,
            1.0f,   1.0f, -1.0f,  1.0f,
            -1.0f, -1.0f,  1.0f,  1.0f,
            1.0f,  -1.0f,  1.0f,  1.0f,
            -1.0f,  1.0f,  1.0f,  1.0f,
            1.0f,   1.0f,  1.0f, 1.0f
        };

        //every pair shows indexes in vertexCoords that are connected by line.
        int[] edgeIndices =
        {
            0,   1,
            0,   2,
            0,   4,
            0,   8,
            1,   3,
            1,   5,
            1,   9,
            2,   3,
            2,   6,
            2,  10,
            3,   7,
            3,  11,
            4,   5,
            4,   6,
            4,  12,
            5,   7,
            5,  13,
            6,   7,
            6,  14,
            7,  15,
            8,   9,
            8,  10,
            8,  12,
            9,  11,
            9,  13,
            10, 11,
            10, 14,
            11, 15,
            12, 13,
            12, 14,
            13, 15,
            14, 15
        };

        //IN PROGRESS
        //used to darw faces for rendering
        int[] faceIndices =
        {
            0, 2, 1,
            1, 2, 3
        };


        //creating game objects and their components
        //hc = new Mesh4(vertexCoords, edgeIndices);
        GameObject mesh4_Object = new GameObject();

        mesh4_Object.transform.parent = transform;
        hc   = mesh4_Object.AddComponent <Mesh4>();
        rb4  = mesh4_Object.AddComponent <RigidBody4D>(); //Deek?
        mcon = mesh4_Object.AddComponent <movementController>();

        //calling each object or components initialization function
        hc.initialize(vertexCoords, edgeIndices);
        hc.triangles = faceIndices;
        rb4.initialize();
        mcon.initialize();
    }