Archived

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

Courtney

Help with Direct3D issue needed!

Recommended Posts

Hi, I''m new to DirectX although I have been programming for many many years. I need some thoughts on a Direct3D issue. I have gotten a bunch of 3D cubes onto the screen - getting them to fly in and being able to move them around. Now (the issue) I need to have a different bitmapped imaged on each face of each cube (this is where I am stuck). So far from my readings I seem to have found that an object (a cube) can only have one texture associated with it. I can get a texture mapped onto one side of a cube but I cant seem to find a way to map different images onto each face of the cube. Maybe I am just missing a basic API programming issue? What techinque should I look at to do this? Multi-texture layering (seems to be limited to video card compatibility), decals, or can I in fact map a different texture to each face of an indexed primitive? Or should I make a cube that is really 6 separate objects (one for each face of the cube)? Thanks, anything to point me into the right direction...

Share this post


Link to post
Share on other sites
I haven''t gotten to meshes yet, so who knows what''s possible there.

But as far as using one texture, I do this... Say you have a 256x256 texture. Well, split it into 16 different 64x64 textures (or 128x128 or whatever). Now you can put a different "texture" on each face by playing with your tu, tv values.

-M

Share this post


Link to post
Share on other sites
G''day!

When you do a SetTexture command it sets the texture that will be used for all subsequent rendering. You can do what Buster recommended, which gives a nice performance boost since there''s no texture swaps, but then you''re limiting yourself to 64x64 so quality is seriously degraded (though it may not matter depending on what you''re doing).

The other option is to load 6 different textures, and then do a SetTexture before drawing each face of the cube.
SetTexture(0,g_texture[0]);
DrawPrimitive(draw the first face);
SetTexture(0,g_texture[1]);
DrawPrimitive(draw the second face);
.
.
.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Of course, calling SetTexture all the time is going to compromise performance, so you also need to sort your triangles into groups by texture and then send them for drawing in batches with the SetTexture calls in between.

That''s assuming you''re not using D3DX meshes.

Share this post


Link to post
Share on other sites