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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace rush_1
{
class Mesh
{
Engine engine;
Device device;
Mesh mesh;
Material[] meshmat;
Texture[] meshtext;
public void init(ref Engine engine)
{
this.engine = engine;
ExtendedMaterial[] materials;
mesh = Mesh.FromFile(Application.StartupPath + "\\sphere.X", MeshFlags.SystemMemory, device, out materials);
meshtext = new Texture[materials.Length];
meshmat = new Material[materials.Length];
for (int i = 0 ; i < materials.Length; i++)
{
meshmat[i] = materials[i].Material3D;
meshtext[i] = TextureLoader.FromFile(device, Application.StartupPath + "\\earth.bmp");
}
}
public void rendu()
{
for (int i = 0; i < meshmat.Length; i++)
{
device.Material = meshmat[i];
device.SetTexture(0, meshtext[i]);
mesh.DrawSubset(i);
}
}
}
} |
Partager