Jump to content
  • Advertisement

Archived

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

Yazeed

Texturing D3DX Shapes ?

This topic is 5271 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi If I create a shape like sphere Using D3DX (8.1) how can make this mesh accept texture ?? regards

Share this post


Link to post
Share on other sites
Advertisement
You need to establish texture coordinates for the geometry, ie. assigning every vertex a corresponding point in the texture space.
I believe that none of the D3DX utility geometry functions generate the coordinates automatically, nor do they allocate even space for them in the mesh's vertex buffer.

A simple way to allocate extra room for the texcoords in an existing mesh is to clone the mesh with a declaration requesting for memory for the coords, and then just generating/loading the coordinates for the cloned mesh, whichever is more appropriate for the situation.

Google for more info, or look at the sdk

-Nik

[edited by - Nik02 on February 8, 2004 2:06:28 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi

i did search in poth sdk & google and found Nothing !

you mean that i cannot change the coords in d3dx meshes

and they are 0 for all vertex

so there is no cure ?

Share this post


Link to post
Share on other sites
I simply stated that D3DX functions do not calculate the coordinates for you automatically - therefore, if you want to texture the utility shapes, you have to add the texture coordinates yourself manually.

kind rgds,
Nik

PS. search in the sdk for "texture coordinates". I'm absolutely sure that the concept of them is explained there :D

EDIT: When you have the mesh object, it's very easy to modify the geometry afterwards. Just lock the mesh's vertex buffer to get access to the geometry data. But do note that without the cloning process (described in my previous post) the buffer doesn't have memory for the texture coords.

[edited by - Nik02 on February 8, 2004 2:47:39 PM]

Share this post


Link to post
Share on other sites

Hi

I did clone the mesh for a FVF that have UVs

so the tu and tv exist now ,, but they all 0

but my quastion is how can access to the Mesh UVs to change the 0s ?

there must be some way !

and i am a visual basic programmer so i a have DX8.1 SDK for Visual Basic which does not have any information about how can i access to D3DXMesh UVs after I cloned it to FVF that have UV utility .. !!

Share this post


Link to post
Share on other sites
Hi,

I find the D3DXCreate[SomePrimitive]() functions are more trouble than they are worth. You are better off simply creating a sphere (or whatever) in 3DS Max, exporting it as an x-file and loading it up.

Share this post


Link to post
Share on other sites
To modify the coords (or other geometry data) in VB, you need to make a copy from the vertex buffer to your own vertex array.
The steps are:
-Lock the vertex buffer, thus obtaining a pointer to it''s data.
-Copy the data to your array, using DXCopyMemory function, passing "ByVal ptr" as src parameter (where "ptr" is the name of the lock pointer variable).
-Modify your array''s data as needed.
-Copy the array back to the vertex buffer.
-Unlock the vertex buffer.

This is one of the situations where using c++ would actually be much more simple - you could just use the pointer directly without redundant copying passes

-Nik

Share this post


Link to post
Share on other sites
If you need sample code, I could write some for fun (haven''t written anything in VB6 for a long time). But it''s a good idea to try this yourself, for practice - please ask only if you absolutely need a sample!

-Nik

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!