2011-02-14 55 views
0

我將XNA Game嵌入到WinForms控件中。正因爲如此,我需要控制子類,而不是遊戲。在XNA之外加載3D模型遊戲類

如何從我的內容項目中加載模型?

這是我的代碼,因爲我有它:

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:錯誤加載 「嘉-60」。文件未找到。

無論如何,我該如何加載模型?

回答

1

您還沒有添加Root目錄。您需要指定模型的完整路徑。

+0

找不到Ka-60 Graphic設備的錯誤。 – Malfist 2011-02-14 15:59:59