/// <summary> /// /// </summary> private void InitializeWater() { int i = 0; short p = 0; short[] indices = new short[WATER_ROWS * WATER_COLS * 6]; WaterVertexArray = new VertexPosTexNormalTanBitan[(WATER_ROWS + 1) * (WATER_COLS + 1)]; //WaterVertexArray = new VertexPositionTexture[(WATER_ROWS + 1) * (WATER_COLS + 1)]; WaterIndexBuffer = new IndexBuffer(Graphics.GraphicsDevice, typeof(short), WATER_ROWS * WATER_COLS * 6, ResourceUsage.WriteOnly, ResourceManagementMode.Automatic); for (int y = 0; y <= WATER_COLS; y++) { for (int x = 0; x <= WATER_ROWS; x++) { WaterVertexArray[p] = new VertexPosTexNormalTanBitan( new Vector3(((float)x / WATER_ROWS) * WATER_WIDTH, ((float)y / WATER_COLS) * WATER_HEIGHT, 0), new Vector2(((float)x / WATER_ROWS), (float)(WATER_COLS - y) / WATER_COLS), Vector3.UnitZ, Vector3.UnitX, Vector3.UnitY ); if (y != WATER_COLS && x != WATER_ROWS) { indices[i++] = p; indices[i++] = (short)(p + 1); indices[i++] = (short)(p + WATER_COLS + 1); indices[i++] = (short)(p + WATER_COLS + 1); indices[i++] = (short)(p + WATER_COLS + 2); indices[i++] = (short)(p + 1); } p++; } } WaterVertexBuffer = new VertexBuffer(Graphics.GraphicsDevice, typeof(VertexPosTexNormalTanBitan), WATER_ROWS * WATER_COLS * 6, ResourceUsage.WriteOnly, ResourceManagementMode.Automatic); WaterVertexBuffer.SetData <VertexPosTexNormalTanBitan>(WaterVertexArray); WaterIndexBuffer.SetData <short>(indices); }
/// <summary> /// /// </summary> private void InitializeWater() { int i = 0; short p = 0; short[] indices = new short[WATER_ROWS * WATER_COLS * 6]; WaterVertexArray = new VertexPosTexNormalTanBitan[(WATER_ROWS + 1) * (WATER_COLS + 1)]; //WaterVertexArray = new VertexPositionTexture[(WATER_ROWS + 1) * (WATER_COLS + 1)]; WaterIndexBuffer = new IndexBuffer(Graphics.GraphicsDevice, typeof(short), WATER_ROWS * WATER_COLS * 6, ResourceUsage.WriteOnly, ResourceManagementMode.Automatic); for (int y = 0; y <= WATER_COLS; y++) { for (int x = 0; x <= WATER_ROWS; x++) { WaterVertexArray[p] = new VertexPosTexNormalTanBitan( new Vector3(((float)x / WATER_ROWS) * WATER_WIDTH, ((float)y / WATER_COLS) * WATER_HEIGHT, 0), new Vector2(((float)x / WATER_ROWS), (float)(WATER_COLS - y) / WATER_COLS), Vector3.UnitZ, Vector3.UnitX, Vector3.UnitY ); if (y != WATER_COLS && x != WATER_ROWS) { indices[i++] = p; indices[i++] = (short)(p + 1); indices[i++] = (short)(p + WATER_COLS + 1); indices[i++] = (short)(p + WATER_COLS + 1); indices[i++] = (short)(p + WATER_COLS + 2); indices[i++] = (short)(p + 1); } p++; } } WaterVertexBuffer = new VertexBuffer(Graphics.GraphicsDevice, typeof(VertexPosTexNormalTanBitan), WATER_ROWS * WATER_COLS * 6, ResourceUsage.WriteOnly, ResourceManagementMode.Automatic); WaterVertexBuffer.SetData<VertexPosTexNormalTanBitan>(WaterVertexArray); WaterIndexBuffer.SetData<short>(indices); }