Esempio n. 1
0
 public void Initialize(GraphicsDevice device, Color color, float angle, Vector3 positionVector, Vector3 rotationVector, Vector3 scaleVector)
 {
     _cylinder      = new CylinderPrimitive(device, _height, _diameter, _tesselation, 2);
     Color          = color;
     Angle          = angle;
     PositionVector = positionVector;
     RotationVector = rotationVector;
     ScaleVector    = scaleVector;
 }
Esempio n. 2
0
        public Cylinder(double radius1, double radius2, double height, Alignment alignment = Alignment.z, string name = "")
            : base(name)
        {
            this.height = height;
            root        = new CylinderPrimitive(radius1, radius2, height, name);
            switch (alignment)
            {
            case Alignment.x:
                root = new Rotate(root, y: MathHelper.DegreesToRadians(90));
                break;

            case Alignment.y:
                root = new Rotate(root, x: MathHelper.DegreesToRadians(90));
                break;
            }
        }
Esempio n. 3
0
		public Cylinder(double radius1, double radius2, double height, Alignment alignment = Alignment.z, string name = "")
			: base(name)
		{
			this.height = height;
			root = new CylinderPrimitive(radius1, radius2, height, name);
			switch (alignment)
			{
				case Alignment.x:
					root = new Rotate(root, y: MathHelper.DegreesToRadians(90));
					break;

				case Alignment.y:
					root = new Rotate(root, x: MathHelper.DegreesToRadians(90));
					break;
			}
		}
Esempio n. 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Font");

            sphere   = new SpherePrimitive(GraphicsDevice);
            cylinder = new CylinderPrimitive(GraphicsDevice);

            faceEffect = new BasicEffect(GraphicsDevice);
            faceEffect.PreferPerPixelLighting = true;

            vertexEffect = new BasicEffect(GraphicsDevice);
            vertexEffect.EnableDefaultLighting();
            vertexEffect.PreferPerPixelLighting = true;

            edgeEffect = new BasicEffect(GraphicsDevice);
            edgeEffect.EnableDefaultLighting();
            edgeEffect.PreferPerPixelLighting = true;
        }
        /// <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();
        }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
 internal CylinderPrimitive(CylinderPrimitive objectToCopy)
     : this(objectToCopy.radius1, objectToCopy.radius2, objectToCopy.height, objectToCopy.name)
 {
 }
Esempio n. 8
0
 internal CylinderPrimitive(CylinderPrimitive objectToCopy)
     : this(objectToCopy.Radius1, objectToCopy.Radius2, objectToCopy.Height, objectToCopy.Sides, objectToCopy.name)
 {
 }
Esempio n. 9
0
			internal CylinderPrimitive(CylinderPrimitive objectToCopy)
				: this(objectToCopy.radius1, objectToCopy.radius2, objectToCopy.height, objectToCopy.name)
			{
			}