/// <summary> /// Builds the vertex buffer using vertices with position, normal, and one set of texture data. /// </summary> public void BuildVertices_PositionNormalTextured1() { GraphicsStream stream; DataCore.VertexFormats.PositionNormalTextured1[] tri = new DataCore.VertexFormats.PositionNormalTextured1[_page.TerrainPatch.NumVertices]; for (int i = 0; i < tri.Length; i++) { tri[i].Position = _page.TerrainPatch.Vertices[i].Position; tri[i].Normal = _page.TerrainPatch.Vertices[i].Normal; if (_page.TerrainPatch.NumTextures > 0) { tri[i].SetTextureCoordinates(_page.TerrainPatch.GetTextureCoordinateList(0)[i], 0); } else { tri[i].SetTextureCoordinates(new Vector2(0f, 0f), 0); } } if (_vb != null) { if (!_vb.Disposed) { _vb.Dispose(); } _vb = null; } _vb = new D3D.VertexBuffer(typeof(DataCore.VertexFormats.PositionNormalTextured1), tri.Length, _viewport.Device, D3D.Usage.WriteOnly, DataCore.VertexFormats.PositionNormalTextured1.Format, D3D.Pool.Managed); stream = _vb.Lock(0, 0, D3D.LockFlags.None); stream.Write(tri); _vb.Unlock(); _vbSize = tri.Length; }
/// <summary> /// Builds the vertex buffer using vertices with position, normal, and one set of texture data. /// </summary> public void BuildVertices_PositionNormalTextured1() { GraphicsStream stream; DataCore.VertexFormats.PositionNormalTextured1[] tri = new DataCore.VertexFormats.PositionNormalTextured1[_page.TerrainPatch.NumVertices]; for ( int i = 0; i < tri.Length; i++ ) { tri[i].Position = _page.TerrainPatch.Vertices[i].Position; tri[i].Normal = _page.TerrainPatch.Vertices[i].Normal; if ( _page.TerrainPatch.NumTextures > 0 ) tri[i].SetTextureCoordinates( _page.TerrainPatch.GetTextureCoordinateList( 0 )[i], 0 ); else tri[i].SetTextureCoordinates( new Vector2( 0f, 0f ), 0 ); } if ( _vb != null ) { if ( !_vb.Disposed ) _vb.Dispose(); _vb = null; } _vb = new D3D.VertexBuffer( typeof( DataCore.VertexFormats.PositionNormalTextured1 ), tri.Length, _viewport.Device, D3D.Usage.WriteOnly, DataCore.VertexFormats.PositionNormalTextured1.Format, D3D.Pool.Managed ); stream = _vb.Lock( 0, 0, D3D.LockFlags.None ); stream.Write( tri ); _vb.Unlock(); _vbSize = tri.Length; }