Beispiel #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 updateSelMesh()
 {
     if (selMesh != null)
     {
         selMesh.Dispose();
     }
     selMesh = new vaoMesh((float)Math.Floor(selPos.X) + 0.5f, (float)Math.Floor(selPos.Y) + 0.5f, selPos.Z, 1.0f, 1.0f);
 }
Beispiel #3
0
        void initGL()
        {
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            cube    = vaoMesh.CreateCube();
            texture = new Texture("image/textest.png");
        }
        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();
        }
Beispiel #5
0
        void initGL()
        {
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);
            //			GL.Enable(EnableCap.CullFace);
            GL.PrimitiveRestartIndex(int.MaxValue);
            GL.Enable(EnableCap.PrimitiveRestart);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            mesh = new vaoMesh(0f, 0f, 0f, 100f, 100f);
            tex  = Tetra.Texture.Load("images/test.jpg");
        }
Beispiel #6
0
        void initGL()
        {
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            cube    = vaoMesh.CreateCube();
            texture = new Texture("image/textest.png");

            projection =
                Matrix4.CreatePerspectiveFieldOfView(
                    MathHelper.PiOver4,
                    ClientRectangle.Width / (float)ClientRectangle.Height, 1.0f, 10.0f);
            modelview = Matrix4.LookAt(new Vector3(5, 5, 5), Vector3.Zero, Vector3.UnitZ);
        }
Beispiel #7
0
        void initGrid()
        {
            const float z = 0.0f;
            const int   IdxPrimitiveRestart = int.MaxValue;

            Vector3[] positionVboData;
            int[]     indicesVboData;
            Vector2[] texVboData;

            positionVboData = new Vector3[_gridSize * _gridSize];
            texVboData      = new Vector2[_gridSize * _gridSize];
            indicesVboData  = new int[(_gridSize * 2 + 1) * _gridSize];

            for (int y = 0; y < _gridSize; y++)
            {
                for (int x = 0; x < _gridSize; x++)
                {
                    positionVboData [_gridSize * y + x] = new Vector3(x, y, z);
                    texVboData [_gridSize * y + x]      = new Vector2((float)x * 1.0f, (float)y * 1.0f);

                    if (y < _gridSize - 1)
                    {
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2 + 1] = _gridSize * y + x;
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2]     = _gridSize * (y + 1) + x;
                    }

                    if (x == _gridSize - 1)
                    {
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2 + 2] = IdxPrimitiveRestart;
                    }
                }
            }

            gridMesh = new vaoMesh(positionVboData, texVboData, indicesVboData);

            Tetra.Texture.DefaultWrapMode = TextureWrapMode.Repeat;
            gridShader.DiffuseTexture     = Tetra.Texture.Load(TextureTarget.Texture2DArray, groundTextures);
            Tetra.Texture.ResetToDefaultLoadingParams();

            hmData = new byte[_hmSize * _hmSize * 4];
            getHeightMapData();
        }
        public void initGrid()
        {
            const float z = 0.0f;
            const int   IdxPrimitiveRestart = int.MaxValue;

            Vector3[] positionVboData;
            int[]     indicesVboData;
            Vector2[] texVboData;

            positionVboData = new Vector3[_gridSize * _gridSize];
            texVboData      = new Vector2[_gridSize * _gridSize];
            indicesVboData  = new int[(_gridSize * 2 + 1) * _gridSize];

            for (int y = 0; y < _gridSize; y++)
            {
                for (int x = 0; x < _gridSize; x++)
                {
                    positionVboData [_gridSize * y + x] = new Vector3(x, y, z);
                    texVboData [_gridSize * y + x]      = new Vector2((float)x * 0.5f, (float)y * 0.5f);

                    if (y < _gridSize - 1)
                    {
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2]     = _gridSize * y + x;
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2 + 1] = _gridSize * (y + 1) + x;
                    }

                    if (x == _gridSize - 1)
                    {
                        indicesVboData [(_gridSize * 2 + 1) * y + x * 2 + 2] = IdxPrimitiveRestart;
                    }
                }
            }

            grid         = new vaoMesh(positionVboData, texVboData, null);
            grid.indices = indicesVboData;

            Texture.DefaultWrapMode   = TextureWrapMode.Repeat;
            gridShader.DiffuseTexture = Texture.Load(TextureTarget.Texture2DArray, groundTextures);
            Texture.DefaultWrapMode   = TextureWrapMode.Clamp;
        }
Beispiel #9
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());
        }
Beispiel #10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            cube    = vaoMesh.CreateCube();
            texture = new Texture("image/textest.png");

            projection =
                Matrix4.CreatePerspectiveFieldOfView(
                    MathHelper.PiOver4,
                    ClientRectangle.Width / (float)ClientRectangle.Height, 1.0f, 10.0f);
            modelview = Matrix4.LookAt(new Vector3(5, 5, 5), Vector3.Zero, Vector3.UnitZ);

            AddWidget(
                new Window(this.CurrentInterface)
            {
                Caption = "Hello World"
            }
                );
        }
Beispiel #11
0
 void initCoin()
 {
     mesh    = vaoMesh.Load(@"meshes/coin.obj");
     coinTex = new Texture(@"meshes/dollar.jpg");
     coinMat = Matrix4.CreateTranslation(0, 0, coinZ);
 }
		public void initGrid()
		{
			const float z = 0.0f;
			const int IdxPrimitiveRestart = int.MaxValue;

			Vector3[] positionVboData;
			int[] indicesVboData;
			Vector2[] texVboData;

			positionVboData = new Vector3[_gridSize * _gridSize];
			texVboData = new Vector2[_gridSize * _gridSize];
			indicesVboData = new int[(_gridSize * 2 + 1) * _gridSize];

			for (int y = 0; y < _gridSize; y++) {
				for (int x = 0; x < _gridSize; x++) {				
					positionVboData [_gridSize * y + x] = new Vector3 (x, y, z);
					texVboData [_gridSize * y + x] = new Vector2 ((float)x*0.5f, (float)y*0.5f);

					if (y < _gridSize-1) {
						indicesVboData [(_gridSize * 2 + 1) * y + x*2] = _gridSize * y + x;
						indicesVboData [(_gridSize * 2 + 1) * y + x*2 + 1] = _gridSize * (y+1) + x;
					}

					if (x == _gridSize-1) {
						indicesVboData [(_gridSize * 2 + 1) * y + x*2 + 2] = IdxPrimitiveRestart;
					}
				}
			}

			grid = new vaoMesh (positionVboData, texVboData, null);
			grid.indices = indicesVboData;

			Texture.DefaultWrapMode = TextureWrapMode.Repeat;
			gridShader.DiffuseTexture = Texture.Load (TextureTarget.Texture2DArray, groundTextures);
			Texture.DefaultWrapMode = TextureWrapMode.Clamp;
		}
		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 ();			
		}
		void updateSelMesh(){
			if (selMesh != null)
				selMesh.Dispose ();
			selMesh = new vaoMesh ((float)Math.Floor(selPos.X)+0.5f, (float)Math.Floor(selPos.Y)+0.5f, selPos.Z, 1.0f, 1.0f);				
		}