Model apply Texture

Anyone know how to apply a texture directly to a Model via Monogame? The reason for the ask is because I am trying to have a random skin applied to a model based on certain results. (GPS, Orientation, etc.)

The texture is in the modelmesh’s Effect class, DIffuseTexture is the property I think

Sorry I don’t have anything installed right now to check exactly, but I would check for the effect file in my_model.meshes[0] (or whatever mesh number you want to have a different texture, you can check their names) and look for the effect class in there.

Currently what I am attempting to do is load the texture to a temporary placeholder and then applying it to the Model.

Here is what I have:

In the Load function I have:

        Room = Content.Load<Model>("wall");
        RoomBG = Content.Load<Texture2D>("Denimtexture");

And in the Draw function within the game:

                effect.TextureEnabled = true;
                effect.Texture = RoomBG;

The application of the texture in the draw seems to throw an exception.

**Edit
After further testing it seems the “effect.TextureEneable=true” is where it throws the error as the “effect.Texture=RoomBG;” is OK if alone.

I actually found how to do this without any issues. If you want to apply a texture directly to a model that is being rendered you need to have a UV map generated to the model before you can apply a texture. This was my main issue.

Now I just need to see about how scaling works for between blender and Monogame. It seems the scaling gets lost.

If you scale your model in Blender, you have to apply it, so that the model data gets changed. Because the model data get exported. It has been a while since I used Blender, so I hope I remembered this correctly. Hope it helps.