Example #1
0
        public void UpdateTrackMesh()
        {
            if (trackMesh != null)
            {
                trackMesh.Dispose();
            }
            trackMesh = null;

            tp.Clear();
            restartIdx.Clear();

            foreach (TrackSegment tStart in TrackStarts)
            {
                buildSegment(null, tStart);
            }

            if (tp.Count == 0)
            {
                return;
            }

            List <int> indices = Enumerable.Range(0, tp.Count).ToList();

            for (int i = 0; i < restartIdx.Count; i++)
            {
                indices.Insert(restartIdx [i] + i, int.MaxValue);
            }

            trackMesh = new vaoMesh(tp.ToArray(), null, indices.ToArray());
        }
        void initTestMesh()
        {
            const float tsize = 1;

            tree = new vaoMesh(
                new Vector3[] {
                new Vector3(-tsize / 2f, 0, 0),
                new Vector3(-tsize / 2f, 0, tsize),
                new Vector3(tsize / 2f, 0, 0),
                new Vector3(tsize / 2f, 0, tsize),
                //					new Vector3 (0, -tsize/2f, -tsize/2f),
                //					new Vector3 (0, -tsize/2f, tsize/2f),
                //					new Vector3 (0, tsize/2f, -tsize/2f),
                //					new Vector3 (0, tsize/2f, tsize/2f)
            },
                new Vector2[] {
                new Vector2(0, 0),
                new Vector2(0, 1),
                new Vector2(1, 0),
                new Vector2(1, 1),
                //					new Vector2 (1, 0),
                //					new Vector2 (1, 1),
                //					new Vector2 (0, 0),
                //					new Vector2 (0, 1)
            },
                new Vector3[] {
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                new Vector3(0, 1, 0),
                //					new Vector3 (1, 0, 0),
                //					new Vector3 (1, 0, 0),
                //					new Vector3 (1, 0, 0),
                //					new Vector3 (1, 0, 0)
            },
                null
                );
            //tree = new vaoMesh(0,0,tsize/2f,tsize,tsize);
            treeTex = Texture.Load("#Ottd3D.images.trees.tree1.png");

            vaoMesh tmp = vaoMesh.Load("Meshes/heolienne.obj");

            Matrix4[] modMats = new Matrix4[100 * 100];
            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    modMats [i * 100 + j] = Matrix4.CreateTranslation(i * 2, j * 2, 0);
                }
                //modMats [i] = Matrix4.Identity;
            }
            heolienne = new vaoMesh(tmp.positions, tmp.texCoords, tmp.normals, tmp.indices, modMats);
            GL.GetError();
            heolienneTex = Texture.Load("#Ottd3D.images.brownRock.dds");
            tmp.Dispose();
        }