/// <inheritdoc /> public override void Initialize() { Game.Background = Color.CornflowerBlue; Camera = new TargetCamera(GraphicsDevice.Viewport.AspectRatio, new Vector3(0, 20, 60), Vector3.Zero); Box = new CubePrimitive(GraphicsDevice, 10, Color.DarkCyan, Color.DarkMagenta, Color.DarkGreen, Color.MonoGameOrange, Color.Black, Color.DarkGray); BoxPosition = Vector3.Zero; Cylinder = new CylinderPrimitive(GraphicsDevice, 20, 10, 16); CylinderPosition = new Vector3(-20, 0, 0); Sphere = new SpherePrimitive(GraphicsDevice, 10); SpherePosition = new Vector3(0, -15, 0); Teapot = new TeapotPrimitive(GraphicsDevice, 10); TeapotPosition = new Vector3(20, 0, 0); Torus = new TorusPrimitive(GraphicsDevice, 10, 1, 16); TorusPosition = new Vector3(-20, 15, 0); Triangle = new TrianglePrimitive(GraphicsDevice, new Vector3(-10f, 10f, 0f), new Vector3(0f, 20f, 0f), new Vector3(10f, 10f, 0f), Color.Black, Color.Cyan, Color.Magenta); base.Initialize(); }
/// <summary> /// Creates a StaticModel from a GeometricPrimitive and specified dimensions. /// </summary> /// <param name="primitiveType">Type of primitive to create</param> /// <param name="height">Height of primitive, used by cubes and cylinders.</param> /// <param name="width">Width of primitive, used by cubes.</param> /// <param name="depth">Depth of primitive, used by cubes.</param> /// <param name="diameter">Diameter of primitive, used by cylinders, spheres, toruses, and teapots.</param> private void LoadModelFromPrimitive(GeometricPrimitiveType primitiveType, float height, float width, float depth, float diameter) { GeometricPrimitive primitive; switch (primitiveType) { case GeometricPrimitiveType.Box: primitive = new CubePrimitive(this.parentEntity.Game.GraphicsDevice, height, width, depth); break; case GeometricPrimitiveType.Sphere: primitive = new SpherePrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 16); break; case GeometricPrimitiveType.Cylinder: primitive = new CylinderPrimitive(this.parentEntity.Game.GraphicsDevice, height, diameter, 16); break; case GeometricPrimitiveType.Cone: primitive = new ConePrimitive(this.parentEntity.Game.GraphicsDevice, height, diameter, 16); break; case GeometricPrimitiveType.Torus: primitive = new TorusPrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 0.3333f, 16); break; case GeometricPrimitiveType.Teapot: primitive = new TeapotPrimitive(this.parentEntity.Game.GraphicsDevice, diameter, 8); break; default: throw new Exception("LoadPrimitive does not handle this type of GeometricPrimitive. Was a new primitive type made and not handled here?"); } if (null != primitive) { model = new StaticModel(primitive, this.parentEntity.Game.GraphicsDevice); } }