D3D Shape Drawing Functions

Started by
4 comments, last by kmsixpence 22 years, 4 months ago
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?
Advertisement
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...
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.
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.
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?
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

This topic is closed to new replies.

Advertisement