6 Replies - 6075 Views - Last Post: 02 May 2011 - 08:03 AM

#1 Ult1mat3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 11

how do i put a texture to a 3d model

Posted 15 April 2011 - 10:17 AM

i made a 3d model in 3ds max, i exported it and imported it at visual c# and i am searching for the code of putting a texture on it.

Firstly i added the picture in "images" folder and i wrote:

 Texture2D binTexture; 


and in load method:

 bin2.binTexture = Content.Load<Texture2D>(@"Images\binTexture"); 


(bin2 is the name of the 3d model, binTexture is the texture i want to put)


is the code in load method correct? and what code i have to add at the draw method?

thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: how do i put a texture to a 3d model

#2 cyan1de  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 45
  • Joined: 12-February 09

Re: how do i put a texture to a 3d model

Posted 15 April 2011 - 12:30 PM

for the draw method something like this
        Matrix world;
        Matrix view;
        Matrix projection;

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Blue);

            Matrix[] transforms = new Matrix[bin2.Bones.Count];
            bin2.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in bin2.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    effect.View = view;
                    effect.Projection = projection;
                }
                mesh.Draw();
            }
           
            base.Draw(gameTime);
        }


Was This Post Helpful? 0
  • +
  • -

#3 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 173
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: how do i put a texture to a 3d model

Posted 18 April 2011 - 12:09 PM

You don't need to load the texture yourself. UV map the model in 3DS Max and let the content pipeline take care of the rest.
Was This Post Helpful? 0
  • +
  • -

#4 Ult1mat3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 11

Re: how do i put a texture to a 3d model

Posted 19 April 2011 - 04:51 AM

View PostlesPaul456, on 18 April 2011 - 12:09 PM, said:

You don't need to load the texture yourself. UV map the model in 3DS Max and let the content pipeline take care of the rest.


Can you be more specific? cause i dont know a lot about 3ds... what do you mean "UV map the model"?

View PostlesPaul456, on 18 April 2011 - 12:09 PM, said:

You don't need to load the texture yourself. UV map the model in 3DS Max and let the content pipeline take care of the rest.


Can you be more specific? cause i dont know a lot about 3ds... what do you mean "UV map the model"?
Was This Post Helpful? 0
  • +
  • -

#5 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 173
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: how do i put a texture to a 3d model

Posted 19 April 2011 - 11:21 AM

UV mapping is just the process of applying a texture to a model.

Wikipedia: UV Mapping

Here's a 3ds Max tutorial on materials and mapping.

Once you've properly applied the texture in 3ds Max, all you need to do is make sure the image file is in the same directory as the model. Then just load and draw the model as usual.
Was This Post Helpful? 0
  • +
  • -

#6 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: how do i put a texture to a 3d model

Posted 20 April 2011 - 11:38 AM

Think of a UV Map as taking a skin of your model, and flattening it so that every single triangle/polygon is visible on a 2d plane. Doing this in 3DS Max is called unwrapping. Once you have the model completely unwrapped, you'll draw the texture over the map in a way that makes sense for the model. Obviously you don't want textures for hair that's supposed to be on the model's head showing up in the middle of the model's shirt/armor/whatever.

The UV data is stored in the file for the model, corresponding to the texture file that you've selected to use for the UV Map. The content pipeline reads that data and interprets it to apply the texture file onto the UV Map, which then pushes the texture onto the model at the appropriate locations based on how you've positioned the map. As lesPaul456 point out, you'll need both of the files in the same directly in order for everything to work properly.
Was This Post Helpful? 2
  • +
  • -

#7 Ult1mat3  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 11

Re: how do i put a texture to a 3d model

Posted 02 May 2011 - 08:03 AM

ok but why it appears white at the front side? :/


look http://img232.images.../imagexkih.jpg/

This post has been edited by Ult1mat3: 02 May 2011 - 08:04 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1