Sphere.cs 1.2 KB

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