[英]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.