Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (4 posts)

Retrieving model's texture name

Last post 10/31/2010 3:35 AM by Synthesizer. 3 replies.
  • 9/8/2010 5:47 AM

    Retrieving model's texture name

    Hello XNA world,

    I'm wondering if is it possible to retrieve a model's texture name while the game is running?

    I'm using the default content importer/processor with FBX models.

    I've already tried something similar to effect.Texture.Name, but the property is always empty.

    Is there an easy way to access this information?

    Arabian Knights
  • 9/8/2010 9:02 AM In reply to

    Re: Retrieving model's texture name


    I analyse that property with Reflector. 

    It's part of GraphicsResource Class (Texture inherit from Graphics Resource)
    Unless I miss something, the get part of Name is not use within the XNA Framework.
    The 'set' part is in few constructor for others GraphicsResource classes (like VertexDeclaration,BlendState,SamplerState) giving name like 

        VertexDeclaration = new VertexDeclaration(elements) { Name = "VertexPositionColor.VertexDeclaration" }; 

    But Texture never set that property. So you may be set it yourself.

    this.texture = Content.Load<Texture2D>("Koala"); 
    this.texture.Name = "Koala"

    Hope that will help you. 

  • 9/8/2010 7:25 PM In reply to

    Re: Retrieving model's texture name

    The default Model class loads textures directly into the parameters of effect instances, and then attaches those effects to the relevant ModelMeshPart object. Filename information is not preserved after the data has been loaded.

    If you need access to this data at runtime, you will need to extend the pipeline to store it somewhere else. For instance you could use a custom processor to store texture filenames in the ModelMeshPart.Tag property.
  • 10/31/2010 3:35 AM In reply to

    Re: Retrieving model's texture name

    So we have to build a whole new custom processor because filename information is not preserved. How nice. Much better if we are already using both a custom processor from a free (and great) component library for animated models & the default one (that does not preserve filename information).

Page 1 of 1 (4 posts) Previous Discussion Next Discussion