protected override void Initialize()
        {
            base.Initialize();

              _camera = new SimpleCamera(Graphics.GraphicsDevice);
              _camera.CameraPosition = new Vector3(0.0f, 50.0f, 5000.0f);

              float fieldOfView = MathHelper.PiOver4;
              float aspectRatio = Graphics.GraphicsDevice.Viewport.AspectRatio;
              float nearPlaneDistance = 1.0f;
              float farPlaneDistance = 10000;
              _matrixProjection = Matrix.CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, nearPlaneDistance, farPlaneDistance);

              SetWindowName("Devpro Model Viewer");
        }
Ejemplo n.º 2
0
        public void Draw(SimpleCamera camera)
        {
            if (_model == null) { return; }

              Matrix worldMatrix = Matrix.Identity
              * Matrix.CreateRotationY(Rotation.Y)
              * Matrix.CreateTranslation(Position);

              foreach (ModelMesh mesh in _model.Meshes)
              {
            foreach (BasicEffect effect in mesh.Effects)
            {
              effect.EnableDefaultLighting();
              effect.World = _transforms[mesh.ParentBone.Index] * worldMatrix;
              effect.View = camera.ViewMatrix;
              effect.Projection = camera.ProjectionMatrix;
            }
            mesh.Draw();
              }
        }