Loading a 3D Model outside the XNA Game class

1.1k views Asked by At

I'm embedding my XNA Game inside a winforms' control. Because of this, I need to subclass Control, not Game.

How can I still load models from my content Project?

This is my code as I have it:

namespace KinectGraphics.XNAEmbedding {
    class XNARenderControl : GraphicsDeviceControl {
        Game selfGame;

        public XNARenderControl() {
            selfGame = new Game();
        }
        protected void LoadContent() {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

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

            model = selfGame.Content.Load<Model>("Ka-60");
            //model = Content.Load<Model>("earth");
            //model = Content.Load<Model>("3dm-tie-f-gt");

        }

However, when execution reaches the selfGame.Content.Load, it throws ContentLoadException: Error loading "Ka-60". File not found.

What can I do to load the model anyway?

1

There are 1 answers

2
Neil Knight On BEST ANSWER

You haven't added the Root directory. You need to specify the full path to the model.