这是我第一次做XNA项目。
我一直在关注教程(http://rbwhitaker.wikidot.com/using-3d-models),我在运行游戏时遇到了问题,并返回了相关错误。
我在这里以及网上都读过一些类似的问题,他们几乎总是与内容项目,root,自定义内容管理器等有关。现在,我并不是很熟悉其中任何一个,因为我没有修改XNA的模板代码,我只是添加了一些(来自教程)。
这是代码:
public class mainClass : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
// Below: Added as of 5/2/13 - referenced from tutorial
private Model testModel;
private Matrix testWorld = Matrix.CreateTranslation(new Vector3(0, 0, 0));
private Matrix testView = Matrix.CreateLookAt(new Vector3(0, 0, 10), new Vector3(0, 0, 0), Vector3.UnitY);
private Matrix testProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), 800f / 480f, 0.1f, 100f);
// Code ends here
public mainClass()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
testModel = Content.Load<Model>("Models/g01-12-13.fbx");
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
testModel内容加载部分出错。说它找不到模型。我试过把它放在文件夹之外,但没有用。我可以帮忙吗?感谢。
P.S。我正在使用XNA 4.0,Visual Studio 2010和Windows 8(呃)。