I'm trying to display a texture on a Mesh which was generated
by the Mesh.Cylinder() method. All is working ok except for the
texture... it doesn't get displayed.
I based the app on the C# SDK example "EnhancedMesh" which displays the
tiger.x mesh. All is working except for the texture...
is there something I'm missing here...
TIA
Harvey
------------------------------------------------------------
Mesh cylinderMesh;
Direct3D.Material meshMaterial;
Texture meshTexture;
protected override void Render()
{
// Clear the viewport
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer ,
System.Drawing.Color.Blue, 1.0f, 0);
device.BeginScene();
device.Material = meshMaterial;
device.SetTexture(0, meshTexture);
cylinderMesh.DrawSubset(0);
device.EndScene();
}
protected override void InitializeDeviceObjects()
{
cylinderMesh = Mesh.Cylinder(device, 1.0f, 1.0f, 5.0f, 90, 1);
meshMaterial = new Material();
meshMaterial.Ambient = meshMaterial.Diffuse = Color.White;
meshTexture = TextureLoader.FromFile(device,
"C:\\DXSDK\\Samples\\Media\\tiger.bmp");
}
Harvey Green <nos...@somewhere.com> spake the secret code
<OH0kPVhv...@tk2msftngp13.phx.gbl> thusly:
>is there something I'm missing here...
Yes, you're missing texture coordinates. Meshes generated from the
primitive shape functions don't have texture coordinates.
--
"The Direct3D Graphics Pipeline"-- code samples, sample chapter, FAQ:
<http://www.xmission.com/~legalize/book/>
Pilgrimage: Utah's annual demoparty
<http://pilgrimage.scene.org>
Thanks,
Harvey
Harvey Green <nos...@somewhere.com> spake the secret code
<#Rc4h6rv...@TK2MSFTNGP11.phx.gbl> thusly:
>Is it easy to add texture coordinates for a generated mesh or should
>I be going about this another way?
You can:
a) clone the mesh to one with texture coordinates and compute them in
code
b) use a modelling package that lets you interactively position a
texture on a mesh
c) use automatic texture coordinate generation
Somehow, you've got to get texture coordinates on your vertices or the
texture won't be properly applied.
now if only the C# docs were complete ... ;-)
Rich [Microsoft Direct3D MVP] wrote: