1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
CONSTRUCTEUR :
texture[1] = CreateTexture(device, "texture2.jpg");
// Chargement du fichier
using (Stream file = File.OpenRead(fichier))
{
Hauteurs = new byte[(int)file.Length];
file.Read(Hauteurs, 0, (int)file.Length);
// On va definir la hauteur la plus basse à 0
Hauteurs = Repositionner(Hauteurs);
// Obtention de la taille d'un coté (on prend la racine carré du nombre de bytes)
int cote = Convert.ToInt32(Math.Sqrt((double)file.Length));
// Calcul des dimensions (triangles, quads, indices, vertex)
calculerValeurs(cote);
}
vb = this.ChargementBuffer(device);
ib = ChargementIndices(device);
voici les definitions de methodes :
private VertexBuffer ChargementBuffer(Device device)
private IndexBuffer ChargementIndices(Device device)
la méthode pour afficher :
public void draw(Device device)
{
Matrix.Scaling(1.0f, 0.3f, 1.0f);
device.VertexFormat = CustomVertex.PositionNormalTextured.Format;
device.SetTexture(0, texture[0]);
device.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, 0, 0, nombreTotalVertex, 0, tableauIndice.Length - 2);
} |
Partager