我有一個項目很快就會到期,而且我有很多問題試圖加載我在3D Studio Max中製作的模型。我製作的模型就是我想要的XNA遊戲中的地形。以下是我迄今所做的:錯誤地在XNA中加載地形+第一人稱攝像頭
方法:
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Model terrainModel;
Vector3 terrainPosition = Vector3.Zero;
Vector3 cameraPosition = new Vector3(0.0f, 60.0f, 160.0f);
Vector3 cameraLookAt = new Vector3(0.0f, 60.0f, 160.0f);
Matrix cameraProjectionMatrix;
Matrix cameraViewMatrix;
LoadContent()
spriteBatch = new SpriteBatch(GraphicsDevice);
cameraViewMatrix = Matrix.CreateLookAt(
cameraPosition,
Vector3.Zero,
Vector3.Up);
cameraProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(80.0f),
graphics.GraphicsDevice.Viewport.AspectRatio,
1.0f,
1000.0f);
terrainModel = Content.Load<Model>("alphastreet");
抽獎(GameTime gameTime)
GraphicsDevice.Clear(Color.CornflowerBlue);
DrawModel(terrainModel, terrainPosition);
// TODO: Add your drawing code here
base.Draw(gameTime);
然後,我想繪製:
void DrawModel(Model model, Vector3 modelPosition)
{
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.World = Matrix.CreateTranslation(modelPosition);
effect.Projection = cameraProjectionMatrix;
effect.View = cameraViewMatrix;
}
mesh.Draw();
}
}
其他的一切都和XNA文件一樣。它自己的模型看起來像一條相當簡單的街道。但是,在XNA加載模型時,它只是加載窗口中的一個大塊。
我不知道我在做什麼,使模型像這樣加載,但它讓我拉我的頭髮。任何幫助,將不勝感激。
此外,任何人都可以指導我走路/指導或創建第一人稱射擊照相機的課程,因爲那是我要玩的遊戲。我可能不應該選那個,但現在改變已經太遲了,所以如果你能在那裏幫助,你真的會拯救我的皮膚!
謝謝,傑克!