Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:48:59+00:00 2026-06-12T19:48:59+00:00

The following code is a complete XNA 3.1 program almost unaltered to that code

  • 0

The following code is a complete XNA 3.1 program almost unaltered to that code skeleton Visual Studio is creating when creating a new project.

The only things I have changed are

  • imported a .x model to the content folder of the VS solution.

    (the model is a simple square with a texture spanning over it – made in Google Sketchup and exported with several .x exporters)

  • in the Load() method I am loading the .x model into the game.

  • The Draw() method uses a BasicEffect to render the model.

Except these three things I haven’t added any code.

Why does the model does not show the texture ? What can I do to make the texture visible ?

This is the texture file (a standard SketchUp texture from the palette):

enter image description here

And this is what my program looks like – as you can see: No texture!

enter image description here

This is the complete source code of the program:

namespace WindowsGame1 {
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game {
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    public Game1() {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content.  Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize() {
        // TODO: Add your initialization logic here
        base.Initialize();
    }

    Model newModel;

    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent() {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);

        // TODO: usse this.Content to load your game content here

        newModel = Content.Load<Model>(@"aau3d");

        foreach (ModelMesh mesh in newModel.Meshes) {

            foreach (ModelMeshPart meshPart in mesh.MeshParts) {

                meshPart.Effect = new BasicEffect(this.GraphicsDevice, null);
            }
        }

    }

    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// all content.
    /// </summary>
    protected override void UnloadContent() {
        // TODO: Unload any non ContentManager content here
    }

    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime) {
        // Allows the game to exit
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        // TODO: Add your update logic here

        base.Update(gameTime);
    }

    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime) {

        if (newModel != null) {

            GraphicsDevice.Clear(Color.CornflowerBlue);

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

            foreach (ModelMesh mesh in newModel.Meshes) {
                foreach (BasicEffect effect in mesh.Effects) {
                    effect.EnableDefaultLighting();
                    effect.TextureEnabled = true;

                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(0)
                * Matrix.CreateTranslation(new Vector3(0, 0, 0));
                    effect.View = Matrix.CreateLookAt(new Vector3(200, 1000, 200), Vector3.Zero, Vector3.Up);
                    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                        0.75f, 1.0f, 10000.0f);
                }
                mesh.Draw();
            }
        }

        base.Draw(gameTime);
    }
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:49:00+00:00Added an answer on June 12, 2026 at 7:49 pm

    I think you’re trying to do too much. It will depend on what is in the “.x” file, but these CAN contain all the shaders needed to color and texture the model.

    I believe the problem is that after loading the model, you are overriding the model’s Effects with a BasicEffect, which doesn’t know about the texture you want to use for your Model.

    The easiest thing to do I think would be to comment out the code relating to the BasicEffect in LoadContent. The setting of “EnableDefaultLighting()” and/or “TextureEnabled” might be unnecessary too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public function Application() { loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
Following code is a pretty simple and complete JQuery Dialog. Everything works. Problem is
How is that setting a breakpoint in my code allows the following code to
I am trying to replace 1234567890123456 with ************3456 with the following code: Regex.Replace(xml,@\b\d{13,16}\b, string.Concat(new
given the following code... private enum EventTypes { WORK, BREAK, WAIT, CLOSE, COMPLETE }
The following code used to function without attempting to render a new template with
When I run following code: public ActionResult Complete() { try { VeriTabanDataContext db =
I have the following code that worked fine till now as I decided to
I have the following code: try { fi.MoveTo(getHistoryFileName()); } finally { Debug.Write(Move complete); }
I have the following code in AsyncFileUpload's upload complete event handler: Protected Sub AsyncFileUpload1_UploadedComplete(ByVal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.