Sphere.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // Sphere.cs
  4. //
  5. // Microsoft XNA Community Game Platform
  6. // Copyright (C) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #endregion
  9. using Microsoft.Xna.Framework;
  10. using Microsoft.Xna.Framework.Graphics;
  11. namespace PerformanceMeasuring
  12. {
  13. public class Sphere
  14. {
  15. private SpherePrimitive primitive;
  16. public Vector3 Position;
  17. public Vector3 Velocity;
  18. public Color Color = Color.White;
  19. public float Radius { get; private set; }
  20. public BoundingSphere Bounds
  21. {
  22. get { return new BoundingSphere(Position, Radius); }
  23. }
  24. public Sphere(GraphicsDevice graphics, float radius)
  25. {
  26. primitive = new SpherePrimitive(graphics, radius * 2f, 10);
  27. Radius = radius;
  28. }
  29. public void Update(GameTime gameTime)
  30. {
  31. Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds;
  32. }
  33. public void Draw(Matrix view, Matrix projection)
  34. {
  35. primitive.Draw(Matrix.CreateTranslation(Position), view, projection, Color);
  36. }
  37. }
  38. }