Exemple #1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            assenstelsel = new _3D_axis(this);
            this.Components.Add(assenstelsel);

            random = new Random();

            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 4.0f / 3.0f, 1.0f, 10000f);
            halfprojectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 2.0f / 3.0f, 1.0f, 10000f);
            quadprojectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 2.0f / 1.5f, 1.0f, 10000f);

            camera1 = new Camera(this, quadprojectionMatrix, new Vector3(0f, 0f, 10f), Vector3.UnitY);

            camera2 = new Camera(this, quadprojectionMatrix, new Vector3(0f, 10f, 0f), Vector3.UnitZ);

            camera3 = new Camera(this, quadprojectionMatrix, new Vector3(10f, 0f, 0f), Vector3.UnitY);

            camera4 = new Camera(this, quadprojectionMatrix, new Vector3(10f, 10f, 10f), Vector3.UnitY);

            cubeList = new List<Cube>();

            Cube cube1 = new Cube(this, new Vector3(random.Next(-4, 4), random.Next(-4, 4), random.Next(-4, 4)), Color.Blue);
            cubeList.Add(cube1);
        }
Exemple #2
0
        private void drawView(Viewport viewport, Camera camera)
        {
            GraphicsDevice.Viewport = viewport;
            effect.World = Matrix.Identity;
            effect.View = camera.view;
            effect.Projection = camera.projection;
            effect.VertexColorEnabled = true;
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, assenstelsel.Vertices, 0, 3);

                foreach (Cube cube in cubeList)
                {
                    GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleStrip, cube.Points, 0, 8, cube.CubeStrip, 0, 15);
                }
            }
        }