Jump to content
  • Advertisement
Sign in to follow this  
Thr3ad

Texturing a mesh

This topic is 4486 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

Is there a simple way to load a texture from a file and then attach it to a mesh? I want to create a sphere and then add a texture to it so i am setting up like this:
LPD3DXMESH  EarthMesh = NULL;
D3DXCreateSphere( pD3DDevice, 1.0f, 20, 20, &EarthMesh, NULL);
I am not sure where to go from here, do i need to make a custom vertex buffer or not? Thanks for looking.

Share this post


Link to post
Share on other sites
Advertisement
There isn't an easy way for your example...

You can use D3DXCreateTextureFromFile() to load up a texture - thats easy enough.

What's difficult is the geometry returned from D3DXCreateSphere() (and the similar functions) DON'T include texture coordinates.

You'll have to go into the vertex data and develop some sort of algorithm (many exist if you want to try it) to define texture coordinates. It can get a little involved [wink]

The alternative is to use a 3D modelling program and create the mesh (with texture) and export it to a .X file.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!