void AffecterPtsTexture() { for (int i = 0; i < PtsTexture.GetLength(0); ++i) { for (int j = 0; j < PtsTexture.GetLength(1); ++j) { PtsTexture[i, j] = new Vector2(i / (float)NbColonnes, -j / (float)NbLignes); } } }
void CréerTableauPointsTexture() { for (int j = 0; j < PtsTexture.GetLength(1); ++j) { for (int i = 0; i < PtsTexture.GetLength(0); ++i) { PtsTexture[i, j] = new Vector2((float)i / (PtsTexture.GetLength(0) - 1), (float)((PtsTexture.GetLength(1) - 1) - j) / (PtsTexture.GetLength(1) - 1)); } } }
private void CréerTableauPoints() { int indiceColor = -1; for (int i = PtsSommets.GetLength(1) - 1; i >= 0; --i) { for (int j = 0; j < PtsSommets.GetLength(0); ++j) { PtsSommets[j, i] = new Vector3(Origine.X + j * Delta.X, DataTerrain[++indiceColor].B * Delta.Y, Origine.Z + i * Delta.Z); DataTexture0[indiceColor].A = (byte)(MAX_COULEUR - DataTerrain[indiceColor].B); DataTexture1[indiceColor].A = DataTerrain[indiceColor].B; } } TextureTerrain[0].SetData(DataTexture0); TextureTerrain[1].SetData(DataTexture1); for (int i = 0; i < PtsTexture.GetLength(1); ++i) { for (int j = 0; j < PtsTexture.GetLength(0); ++j) { PtsTexture[j, i] = new Vector2((float)j / NbColonnes, 1 - (float)i / NbRangées); } } }
protected override void InitialiserSommets() { int NoSommet = -1; for (int j = 0; j < PtsSommets.GetLength(1) - 1; ++j) { for (int i = 0; i < NbColonnes; ++i) { Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i, j], PtsTexture[i, j]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i, j + 1], PtsTexture[i, j + 1]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i + 1, j], PtsTexture[i + 1, j]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i + 1, j], PtsTexture[i + 1, j]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i, j + 1], PtsTexture[i, j + 1]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i + 1, j + 1], PtsTexture[i + 1, j + 1]); } } Vector3 centreBas = new Vector3(Origine.X, PtsSommets[0, 0].Y, Origine.Z); for (int i = 0; i < NbColonnes; ++i) { Sommets[++NoSommet] = new VertexPositionTexture(centreBas, PtsTexture[PtsTexture.GetLength(0) / 2, PtsTexture.GetLength(1) - 1]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i, 0], PtsTexture[i, PtsTexture.GetLength(1) - 2]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i + 1, 0], PtsTexture[i + 1, PtsTexture.GetLength(1) - 2]); } Vector3 centreHaut = new Vector3(Origine.X, PtsSommets[0, PtsSommets.GetLength(1) - 1].Y, Origine.Z); for (int i = 0; i < NbColonnes; ++i) { Sommets[++NoSommet] = new VertexPositionTexture(centreHaut, PtsTexture[PtsTexture.GetLength(0) / 2, 0]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i + 1, PtsSommets.GetLength(1) - 1], PtsTexture[i + 1, 1]); Sommets[++NoSommet] = new VertexPositionTexture(PtsSommets[i, PtsSommets.GetLength(1) - 1], PtsTexture[i, 1]); } }