Archived

This topic is now archived and is closed to further replies.

EasyGino

Another Texturing Question

Recommended Posts

*Note DirectX I was wondering how I would input more then one texture into a scene? It seems that whenever I set the texture, the whole scene gets textures, regardless If I put in texture coordinates. I was trying something like:
{ 0.0f, 0.0f, 0.0f, 0xfffffffff, },

#ifndef TEXTURE
{ 0.0f, 0.0f, 0.0f, 0xffffffff, 0.0f, 0.0f, },
#endif
  
And then under my Render() function I have something like
#ifndef TEXTURE
g_pd3dDevice->SetTexture(etc.);
#endif
 
There is more to it then that but thats the jist of it. Basically what I wanted here is to texture my "floor" but not my "walls". But the floor code is within the same code that holds my walls. [edited by - EasyGino on October 23, 2003 8:52:58 AM]

Share this post


Link to post
Share on other sites

  1. Set "floor" texture.

  2. Draw "floor".

  3. Either set the "wall" texture or 0 in place of a texture to disable previous texture.

  4. Draw "wall".



-Nik

EDIT: HTML mixed up

[edited by - Nik02 on October 23, 2003 9:23:00 AM]

Share this post


Link to post
Share on other sites
Does that mean I would almost have to get rid of my Render function and replace it with individual drawing functions? Or in the other case, your example 3, it says set the texture to 0? I'm not sure what you mean there.

[edited by - EasyGino on October 23, 2003 9:40:45 AM]

Share this post


Link to post
Share on other sites
If you pass 0 as the texture pointer in IDirect3DDevice9::SetTexture(), it will disable the texture previously set on that sampler.

If you have a mesh of data, then you should have subsets anyway, which you can draw separately.
And if drawing directly from vertex buffers, you do have the choice of which vertices to draw per one operation.

-Nik

EDIT:
And of course you can do all these steps inside your render function

[edited by - Nik02 on October 23, 2003 9:58:38 AM]

Share this post


Link to post
Share on other sites
I need some code :D

Ok so say I do a
SetTexture(0, &pointer);
DrawPrimitive(TriangleList, 0, 4);
SetTexture(0, 0);
DrawPrimitive(TriangleList, 5, 12);

and the first four is what I want textured, Will that work.

I dont have the API''s and im not sure what the 0 and 5 mean, but im assuming its the starting point.

Share this post


Link to post
Share on other sites
The second parameter of the DrawPrimitive is the index of the first vertex you want to use.
Third is the number of primitives to draw, in your case triangles.


pDev->SetTexture(0, pFloorTexture); //set the floor texture

pDev->DrawPrimitive(TriangleList, 0, 4); //draw 4 _triangles_ as floor.

pDev->SetTexture(0, 0); //discard the wall texture

pDev->DrawPrimitive(TriangleList, 6, 12);
//note the offset 6, because a 4 triangle floor probably uses at least vertices indexed 0...5.


-Nik

EDIT: You don't have the APIs? Download the sdk It'll be helpful!

[edited by - Nik02 on October 23, 2003 12:52:55 PM]

Share this post


Link to post
Share on other sites