コード例 #1
0
ファイル: Game1.cs プロジェクト: Nathriel/CG3D
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

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

            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(0, 0, 0), Color.Blue);
            cubeList.Add(cube1);
            Cube cube2 = new Cube(this, new Vector3(0, 0, 0), Color.Red);
            cube2.translateCube(0, 2f, 0);
            cubeList.Add(cube2);
            Cube cube3 = new Cube(this, new Vector3(0, 0, 0), Color.Green);
            cube3.translateCube(2f, 0, 0);
            cubeList.Add(cube3);
            Cube cube4 = new Cube(this, new Vector3(0, 0, 0), Color.Purple);
            cube4.translateCube(2f, 2f, 0);
            cubeList.Add(cube4);
            this.Components.Add(cube1);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: Nathriel/CG3D
        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);
                }
            }
        }