Пример #1
0
        private void drawingSurface_Draw(object sender, DrawEventArgs e)
        {
            GraphicsDevice device = GraphicsDeviceManager.Current.GraphicsDevice;

            device.Clear(new Color(0, 0, 0));

            // This allows you to see the inside of the cube when you pass into it.
            device.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.None
            };

            // Spin the cube.
            if (rotate)
            {
                Matrix rotation = Matrix.CreateRotationY(MathHelper.PiOver4 * (float)e.DeltaTime.TotalMilliseconds / 2000f);
                cube.World = cube.World * rotation;
            }

            // Create the view for the current camera position and direction.
            cameraTarget = cameraPosition + cameraLook;
            Matrix view = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up);

            cube.View  = view;
            floor.View = view;

            // Draw the shapes.
            floor.Draw(device);
            cube.Draw(device);

            // Keep the drawing surface updated.
            e.InvalidateSurface();
        }
        private void drawingSurface_Draw(object sender, DrawEventArgs e)
        {
            GraphicsDevice device = GraphicsDeviceManager.Current.GraphicsDevice;

            device.Clear(new Color(0, 0, 0));

            cube.Draw(device);
            cube2.Draw(device);
            cube3.Draw(device);
        }