using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Ricochet { public enum ShapeType { Sphere, Circle, Square, Cube, Cone, Triangle } public class Shape { public ShapeType Type; public Vector3 Position; public Quaternion Rotation; public Vector3 Size; public VertexPositionColor[] Vertices; public short[] Indices; public Shape(Vector3 Position, Vector3 Size) { new Shape(Position, Size, new Quaternion()); } public Shape(Vector3 Position, Vector3 Size, Vector3 Rotation) { new Shape(Position, Size, Rotation * (float.Parse(Math.PI.ToString()) / 180)); } public Shape(Vector3 Position, Vector3 Size, Quaternion Rotation) { this.Position = Position; this.Size = Size; this.Rotation = Rotation; this.Vertices = new VertexPositionColor[8]; //Vertices[0].Position = new Vector3(-2.5f, 2.5f, 2.5f); Vertices[0].Position = new Vector3(Position.X + -(Size.X / 2), Position.Y + (Size.Y / 2), Position.Z + (Size.Z / 2)); Vertices[0].Color = Color.Red; Vertices[1].Position = new Vector3(Position.X + -(Size.X / 2), Position.Y + -(Size.Y / 2), Position.Z + (Size.Z / 2)); Vertices[1].Color = Color.Green; Vertices[2].Position = new Vector3(Position.X + -(Size.X / 2), Position.Y + (Size.Y / 2), Position.Z + -(Size.Z / 2)); Vertices[2].Color = Color.Blue; Vertices[3].Position = new Vector3(Position.X + -(Size.X / 2), Position.Y + -(Size.Y / 2), Position.Z + -(Size.Z / 2)); Vertices[3].Color = Color.Black; Vertices[4].Position = new Vector3(Position.X + (Size.X / 2), Position.Y + (Size.Y / 2), Position.Z + (Size.Z / 2)); Vertices[4].Color = Color.White; Vertices[5].Position = new Vector3(Position.X + (Size.X / 2), Position.Y + -(Size.Y / 2), Position.Z + (Size.Z / 2)); Vertices[5].Color = Color.Purple; Vertices[6].Position = new Vector3(Position.X + (Size.X / 2), Position.Y + (Size.Y / 2), Position.Z + -(Size.Z / 2)); Vertices[6].Color = Color.Orange; Vertices[7].Position = new Vector3(Position.X + -(Size.X / 2), Position.Y + -(Size.Y / 2), Position.Z + -(Size.Z / 2)); Vertices[7].Color = Color.Yellow; Indices = new short[36]; Indices[0] = 0; Indices[1] = 1; Indices[2] = 2; Indices[3] = 1; Indices[4] = 3; Indices[5] = 2; Indices[6] = 0; Indices[7] = 4; Indices[8] = 1; Indices[9] = 4; Indices[10] = 5; Indices[11] = 1; Indices[12] = 4; Indices[13] = 0; Indices[14] = 2; Indices[15] = 4; Indices[16] = 2; Indices[17] = 6; Indices[18] = 4; Indices[19] = 5; Indices[20] = 7; Indices[21] = 7; Indices[22] = 6; Indices[23] = 4; Indices[24] = 1; Indices[25] = 5; Indices[26] = 3; Indices[27] = 5; Indices[28] = 7; Indices[29] = 3; Indices[30] = 2; Indices[31] = 3; Indices[32] = 7; Indices[33] = 2; Indices[34] = 7; Indices[35] = 6; } } }