Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top