在 XNA Game 类之外加载 3D 模型
我将我的 XNA 游戏嵌入到 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”时出错。未找到文件。
我该怎么做才能加载模型?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尚未添加
Root
目录。您需要指定模型的完整路径。You haven't added the
Root
directory. You need to specify the full path to the model.