Jump to content

  • Log In with Google      Sign In   
  • Create Account


Access texture of model


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 football94   Members   -  Reputation: 198

Like
0Likes
Like

Posted 10 November 2013 - 11:11 AM

Hi Guys

 

Ive been working with the toon shader sample from the microsoft xbox live website(link below) and wanted to apply the

effect to the skinning sample also from the website and wanted to know if there was a way to extract texture info

from a model without using the basiceffect

 

 

 

                                                                           Thankyou

 

 

 

 

 

toon shader link

http://xbox.create.msdn.com/en-US/education/catalog/sample/nonrealistic_rendering

 

animated model link

http://xbox.create.msdn.com/en-US/education/catalog/sample/skinned_model

 

 

 

 

 

portion of code wanting to modify from this:

 foreach (BasicEffect oldEffect in mesh.Effects)

To this and still be able to access the texture of the animated model

 foreach (Effect oldEffect in mesh.Effects)

complete code

  static void ChangeEffectUsedByModel(Model model, Effect replacementEffect)
        {
            // Table mapping the original effects to our replacement versions.
            Dictionary<Effect, Effect> effectMapping = new Dictionary<Effect, Effect>();

            foreach (ModelMesh mesh in model.Meshes)
            {
                // Scan over all the effects currently on the mesh.
                foreach (BasicEffect oldEffect in mesh.Effects)
                {
                    // If we haven't already seen this effect...
                    if (!effectMapping.ContainsKey(oldEffect))
                    {
                        // Make a clone of our replacement effect. We can't just use
                        // it directly, because the same effect might need to be
                        // applied several times to different parts of the model using
                        // a different texture each time, so we need a fresh copy each
                        // time we want to set a different texture into it.
                        Effect newEffect = replacementEffect.Clone(
                                                    replacementEffect.GraphicsDevice);

                        // Copy across the texture from the original effect.
                        newEffect.Parameters["Texture"].SetValue(oldEffect.Texture);

                        newEffect.Parameters["TextureEnabled"].SetValue(
                                                            oldEffect.TextureEnabled);

                        effectMapping.Add(oldEffect, newEffect);
                    }
                }

                // Now that we've found all the effects in use on this mesh,
                // update it to use our new replacement versions.
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    meshPart.Effect = effectMapping[meshPart.Effect];
                }
            }
        }




Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS