Re: Rendering Texture on Mesh.XXXX

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Daniel Yankowsky (dyankowsky_at_verizon.net)
Date: 07/15/04


Date: Thu, 15 Jul 2004 01:02:23 GMT

Nothing like the blind leading the blind, but I'll take a stab at this. I'm
kinda new to DirectX as well. If indeed your torus has no texture
coordinates, then I think that you will need to create a new vertex buffer
for your mesh. This vertex buffer must contain vertices of a type that
includes texture coordinates. Thus, when you create the vertex buffer, I
think you need to OR in VertexFormats.Texture1 or greater. Then, you need
to lock both buffers and copy from one to the other, calculating texture
coordinates as you go. Once done with that, you should be able to unlock
and render as your code below indicates.

If you want to play with textures, maybe it would be easier to write a .x
file and load it. It's easy: Mesh m = Mesh.FromFile(params). Then, you can
specify tex coords very easily. Just make a nice, flat square. 4 vertices,
4 tex coords.

"rond" <rond@discussions.microsoft.com> wrote in message
news:BECFD90D-5243-488C-911E-62D59BE0C676@microsoft.com...
> Hi,
>
> I'm evaluating Managed DirectX and have a simple task (or so I thought).
>
> I want to apply the banana.bmp to a torus created with Mesh.Torus.
>
> I have the Torus rendering, it is being drawn as a solid color, it appears
that it is being drawn with a color in the banana.bmp but the actual texture
is not being rendered on the torus. I'm not fussy on how the bitmap is
applied to the torus, only that it is applied.
>
> I have read that Meshes created with Mesh.Torus have no texture
coordinates set; I assume this is what I need to do. How would one go about
setting texture coordinates on a mesh created with Mesh.Torus?
>
> My current logic is basically like this.
>
> Mesh mesh = Mesh.Torus(device,_r1,_r2,_sides,_rings);
> texture = TextureLoader.FromFile(device,strTempFile);
> _device.SetTexture(0, texture);
> _drawMesh.DrawSubset(0);
>
> Ideas?
>
> Thanks
>



Relevant Pages

  • Re: Texture on torus
    ... can anyone help me with stretching texture on torus? ... Texture coordinate generation ... Consider the torus being a cylinder, that hes been bent into a ...
    (comp.graphics.api.opengl)
  • Texture on torus
    ... can anyone help me with stretching texture on torus? ... for texture generation: ... now my torus is covered with many copies of texture, ...
    (comp.graphics.api.opengl)
  • Re: question about torus mesh
    ... Sounds like maybe you have got the normals all set wrong and you are using a ... directional light to light it. ... News and Resources for Managed DirectX ... > I have to display an object that is topologically equivalent to a torus. ...
    (microsoft.public.win32.programmer.directx.managed)