Right now, for my stage setup, I'm loading one giant mesh which contains all world objects. The individual objects are low poly [it's the series of pillars you can see in my last posted screenshot, in the vertex thread], and according to Lightwave, there are about 3000 triangles that compose the entire object. I'd say only about 100 or so are on screen at once, maybe 50 of those are visible at any given time.
They are untextured, only having a diffuse color set. I'm loading the mesh with the "Managed" mesh flag. Heck, here's my loading and rendering code:
Code: Select all
public terrainMesh(Device _device, string _meshName, float _center)
{
meshName = _meshName;
device = _device;
position = new Vector3(_center, 0.0f, 0.0f);
ExtendedMaterial[] prefabMaterials = null;
thisMesh = Mesh.FromFile(meshName+".x",
MeshFlags.Managed,
device,
out prefabMaterials);
if (meshTextures == null)
{
meshTextures = new Texture[prefabMaterials.Length];
meshMaterials = new Microsoft.DirectX.Direct3D.Material[prefabMaterials.Length];
for( int i=0; i<prefabMaterials.Length; i++ )
{
meshMaterials[i] = prefabMaterials[i].Material3D;
meshMaterials[i].Ambient = meshMaterials[i].Diffuse;
if(prefabMaterials[i].TextureFilename != null)
meshTextures[i] = TextureLoader.FromFile(device,
prefabMaterials[i].TextureFilename);
}
}
}
public void Render()
{
device.Transform.World = Matrix.Translation(position);
for( int i=0; i<meshMaterials.Length; i++ )
{
device.Material = meshMaterials[i];
device.SetTexture(0, meshTextures[i]);
thisMesh.DrawSubset(i);
}
}
I'm stumped!