unit Objet;

interface

uses
  System.Collections,
  System.ComponentModel,
  System.Data,
  System.Drawing,
  System.Windows.Forms,
  System.IO,
  Microsoft.DirectX,
  Microsoft.DirectX.DirectInput,
  Microsoft.DirectX.Direct3D;

type
  TMove = record
    x, y, z, angle : real;
    saut : boolean;
  end;

  TEventHandler      = System.EventHandler;
  TEventArgs         = System.EventArgs;
  TKeyEventArgs      = System.Windows.Forms.KeyEventArgs;
  TMouseEventArgs    = System.Windows.Forms.MouseEventArgs;
  TPaintEventArgs    = System.Windows.Forms.PaintEventArgs;
  TKeys              = System.Windows.Forms.Keys;
  TForm              = System.Windows.Forms.Form;
  TColor             = System.Drawing.Color;
  TIcon              = System.Drawing.Icon;

  TPerso = class
    private
    public
      move : TMove;
      constructor create;
    private
      mesh      : Mesh;
      device    : Device;
      materials : Array of Material ;
      textures  : Array of Texture ;
      procedure CreateMesh (chemin : string; device : Device);
      procedure Drawmesh();
  end;

implementation

constructor TPerso.create;
begin
   inherited;
end;

procedure TPerso.CreateMesh (chemin : string; device : Device);
var
  meshMaterials : array of ExtendedMaterial;     // Tableau des matériaux
  i, taille : integer;

begin
  mesh := Mesh.FromFile(chemin,
                        MeshFlags.SystemMemory,
                        device,
                        meshMaterials);
  taille := high(meshMaterials);
  SetLength(textures, taille);
  SetLength(materials, taille);
  for i := 0 to taille-1 do
    begin
      if MeshMaterials[i].TextureFilename <> nil then
        begin
          Textures[i] := textureloader.FromFile(device,
                                                    'tiger'+meshMaterials[i].TextureFilename)
        end;
    end;
end;




procedure TPerso.Drawmesh();
  var
    i : integer;
  begin
    for i := 0 to high(materials) do
      begin
        device.Material := materials[i];
        if textures[i] <> nil then
          device.SetTexture(0, textures[i]);
          mesh.DrawSubset(i);
      end;
  end;

end.
