I'm trying out XNA's 3D capabilities, and created a simple pac-man style map to test out my code. Everything displays fine, but the updates seem a bit slow.
The map consists of 800+ grid points, each of which contains a wall, a pellet, or nothing. There are actually only 4 .fbx models, each one being displayed multiple times. Each instance calls the following code to display itself:
| public static void drawModel(Model m, Matrix[] boneTransforms, float rotation, Vector3 position, float aspectRatio, Vector3 cameraPosition, Vector3 cameraLookAt) |
| { |
| m.CopyAbsoluteBoneTransformsTo(boneTransforms); |
| |
| foreach (ModelMesh mesh in m.Meshes) |
| { |
| foreach (BasicEffect effect in mesh.Effects) |
| { |
| effect.World = boneTransforms[mesh.ParentBone.Index] * Matrix.CreateRotationZ(rotation) * Matrix.CreateTranslation(position); |
| effect.View = Matrix.CreateLookAt(cameraPosition, cameraLookAt, Vector3.Up); |
| effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10000); |
| effect.EnableDefaultLighting(); |
| } |
| mesh.Draw(); |
| } |
| } |
Am I doing something stupid that's causing this to use a lot more resources than necessary? XNA's 3d graphics API kind of makes my brain melt, so there's a great deal of it that I just don't understand.
(the rest of the code is available if it'll help)