Jump to content
  • Advertisement
Sign in to follow this  
Anzipane

How to automatically load textures associated with a 3D model

This topic is 2152 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,

I'm trying to figure out how to automatically load textures (associated with a 3D model) into XNA without having to load them manually (like BasiEffect does for example, you just need to load the model).

Now, I can't use the BasicEffect class because I'm using a custom effect to draw the models, so how can I proceed with this? Do I have to make a Custom content processor or what? Thanks.

 

 

Share this post


Link to post
Share on other sites
Advertisement

As long the texture name is part of the file you can have your loader extract the name and load it. Alot of the time the texture path will point to something that is usually match whoever did the export. So the filepath will be very different then what you have on your machine. So what you can do in that case is assume that the texture needs to be in the same path as the model and just extract the name and load it in your content loader.

Edited by BornToCode

Share this post


Link to post
Share on other sites

As the saying goes, why re-invent the wheel. The default behaviour for the  ModelProcessor loads associated textures into into BasicEffect instances, so the least complicated way to load the textures and use your own effect is to load the Model then replace the effects with your own versions (copying the textures from the old BasicEffect instances). 

 

If you are writing your own ModelProcessor where you set a custom effect upon build, then I'd recommend looking at the skinned model example as that demonstrates replacing  effects in a content processor: http://xbox.create.msdn.com/en-US/education/catalog/sample/skinned_model

 

There is no need for you to do this manually, so get studying and good luck :)

 

Aimee

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!