Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cylinder mesh - texture not working

5 views
Skip to first unread message

Harvey Green

unread,
Dec 9, 2003, 12:31:08 AM12/9/03
to
Hi All,
I'm new to DirectX so if there's a basic error here please
forgive my ignorance!

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");
}

Rich [Microsoft Direct3D MVP]

unread,
Dec 9, 2003, 1:16:57 PM12/9/03
to
[Please do not mail me a copy of your followup]

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>

Harvey Green

unread,
Dec 9, 2003, 8:43:33 PM12/9/03
to
Is it easy to add texture coordinates for a generated mesh or should
I be going about this another way?

Thanks,

Harvey

Rich [Microsoft Direct3D MVP]

unread,
Dec 10, 2003, 1:46:08 AM12/10/03
to
[Please do not mail me a copy of your followup]

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.

Harvey Green

unread,
Dec 10, 2003, 2:27:42 AM12/10/03
to
Thanks I'll try option c

now if only the C# docs were complete ... ;-)

Rich [Microsoft Direct3D MVP] wrote:

0 new messages