Exemplo n.º 1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (TEST == false)
            {
                hud.Draw(spriteBatch);
            }
            else if (TEST == true)
            {
                // Copy any parent transforms.
                Matrix[] transforms = new Matrix[myModel.Bones.Count];
                myModel.CopyAbsoluteBoneTransformsTo(transforms);

                // Draw the model. A model can have multiple meshes, so loop.
                foreach (ModelMesh mesh in myModel.Meshes)
                {
                    // This is where the mesh orientation is set, as well as our camera and projection.
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation)
                                       * Matrix.CreateTranslation(modelPosition);
                        effect.View       = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                        effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                                                                                aspectRatio, 1.0f, 10000.0f);
                    }
                    // Draw the mesh, using the effects set above.
                    mesh.Draw();
                }
            }
        }
Exemplo n.º 2
0
        public void Draw(GameTime gameTime)
        {
            device.Clear(Color.CornflowerBlue);
            device.RenderState.CullMode = CullMode.None;

            DrawLandscape(landscape, new Vector3(0, 0, 0));
            DrawModel(buggyModel);

            Vector2 FontOrigin = textFont.MeasureString("test") / 2;

            spriteBatch.Begin();
            spriteBatch.DrawString(
                textFont,
                "CameraPos: " + campos.X + " " + campos.Y + " " + campos.Z,
                new Vector2(20, 20), Color.LightGreen, 0, FontOrigin, 0.5f, SpriteEffects.None, 0.5f);
            spriteBatch.DrawString(
                textFont,
                "BuggyPos: " + buggyPosition.X + " " + buggyPosition.Y + " " + buggyPosition.Z,
                new Vector2(20, 40), Color.LightGreen, 0, FontOrigin, 0.5f, SpriteEffects.None, 0.5f);
            spriteBatch.DrawString(
                textFont,
                "BuggyAcc: " + curAcc,
                new Vector2(20, 60), Color.LightGreen, 0, FontOrigin, 0.5f, SpriteEffects.None, 0.5f);
            spriteBatch.DrawString(
                textFont,
                "BuggySpeed: " + buggySpeed,
                new Vector2(20, 80), Color.LightGreen, 0, FontOrigin, 0.5f, SpriteEffects.None, 0.5f);
            spriteBatch.End();
            hud.Draw(spriteBatch);
        }