繁体   English   中英

在XNA Game类之外加载3D模型

[英]Loading a 3D Model outside the XNA Game class

我将XNA Game嵌入Winforms控件中。 因此,我需要继承Control,而不是Game。

我如何仍可以从内容项目中加载模型?

这是我的代码,因为我有:

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");

        }

但是,当执行到达selfGame.Content.Load时,它将引发ContentLoadException:加载“ Ka-60”时出错。 文件未找到。

无论如何我该如何加载模型?

您尚未添加Root目录。 您需要指定模型的完整路径。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM