Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace GyroGUI_v3
- {
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- modelOrientation = Matrix.Identity;
- modelOrientation *= Matrix.CreateScale(1);
- base.Initialize();
- }
- Model myModel;
- float aspectRatio;
- Matrix modelOrientation;
- Vector3 modelPosition = Vector3.Zero;
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- myModel = Content.Load<Model>("Models\\p1_wedge");
- aspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
- (float)graphics.GraphicsDevice.Viewport.Height;
- }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- Vector3 position = modelOrientation.Translation;
- modelOrientation *= Matrix.CreateFromAxisAngle(new Vector3(1.0f, 1.0f, 0.0f), 0.2f);
- modelOrientation.Translation = position;
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- foreach (ModelMesh mesh in myModel.Meshes)
- {
- foreach (BasicEffect effect in mesh.Effects)
- {
- effect.EnableDefaultLighting();
- effect.World = modelOrientation;
- effect.View = Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 5000.0f), Vector3.Zero, Vector3.Up);
- effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
- aspectRatio, 1.0f, 10000.0f);
- }
- mesh.Draw();
- }
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement