예제 #1
0
파일: Game1.cs 프로젝트: AgusRumayor/C-
        private void DibujaModelo(Model model, Matrix world)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            float aspectRatio = (float)device.Viewport.Width / device.Viewport.Height;
            //float aspectRatio = 1f;
            foreach (ModelMesh mesh in model.Meshes)
            {

                foreach (BasicEffect effect in mesh.Effects)
                {

                    effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    //effect.World = mesh.ParentBone.Transform * world;
                    effect.View = Matrix.CreateLookAt(cameraPosition, lookAt, Vector3.Up);
                    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 100000.0f);
                    //effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, 10f);

                    //effect.View = camera.View;
                    //effect.Projection = camera.Projection;
                }
                mesh.Draw();
                if (model.Equals(modeloFlecha))
                    esferaf = mesh.BoundingSphere;
                if (model.Equals(modeloBlanco))
                    esferab = mesh.BoundingSphere;
            }
        }