Archived

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

kmsixpence

D3D Shape Drawing Functions

Recommended Posts

kmsixpence    134
DirectX has some really cool shape drawing functions such as D3DXCreateBox and some more. Anyway, I got a cube up on the screen and loaded a texture with the set texture function but the texture is all screwed up. It only draws the first pixel I think it is because there are no texture cooridents so how would I set them? Is there even a way?

Share this post


Link to post
Share on other sites
ipso    122
Copy the mesh VB into another VB created with diffrent VF (i.e. with D3DFVF_TEX1). Copy the mesh IB into another IB. Destroy the mesh. Set the texcoords in the VB (lock/set/unlock).

Yep, I might be wrong here...

Share this post


Link to post
Share on other sites
kmsixpence    134
Okay, that seems to make sense. Thanks, i''ll try it out. Also, was the part where you said "yep i might be wrong here" part of your signature or was it telling me that you arn''t sure if that''s correct.

Share this post


Link to post
Share on other sites
ipso    122
Yep, I meant I''m not sure. Not that it won''t work, just wether or not it''s the optimum method.

That group of methods create a C3DMESH, but with no option to define the VF for the generated vertices. So I *think* you have to clunk it like this.

Share this post


Link to post
Share on other sites
kmsixpence    134
I tried it out. I know how to copy the vertex buffers and such but I got another q. Should I use the CreateVertexBuffer function before I copy the data and how should I go about inserting the texture coorinents. Is there a way to tell how many vertices there is for the shape?

Share this post


Link to post
Share on other sites
ipso    122
The number of vertices is contained within the C3DMESH class. Use that to create a VB of the correct size using CreateVertexBuffer.

The tricky bit will be assigning the TexCoords as you will need to find out how the primitive in constructed to align the TexCoords correctly. Something like a cube should be fairly easy to work out, a sphere will be more difficult. Also you will have to decide what mapping strategy you will use.

The way I have done it is to get a 1x1x1 texture mapped sphere in a .x file. Load it into a C3DMESH and do what I described before. Once you have a VB with a 1x1x1 sphere or whatever in, you can create other VBs, and scale the primitive to whatever size you like, by multiplying the vertices by a constant.

I gave up with the CreateSphere etc functions. No good, I thought



Edited by - ipso on December 14, 2001 3:05:36 PM

Share this post


Link to post
Share on other sites