All pastes #743408 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-20 12:38 UTC
rendered paste body
            private void DrawModel(Model m)
            {
                //camPosition = Collision.Collision(terrain, angle, camPosition, "Ground");
                //camTarget.Y = Collision.Collision(terrain, angle, camPosition, "Ground").Y;

                Matrix[] transforms = new Matrix[m.Bones.Count];
                float aspectRatio = graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height;
                m.CopyAbsoluteBoneTransformsTo(transforms);
                Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                    aspectRatio, 1.0f, 10000.0f);
                Matrix view = Matrix.CreateLookAt(camPosition, camTarget, Vector3.Up);

                foreach (ModelMesh mesh in m.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.View = view;
                        effect.Projection = projection;
                        effect.World = MyWorldRotation * transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(Position);
                    }
                    mesh.Draw();
                }
            }