コード例 #1
0
        /// <summary>
        /// Create a new game.
        /// </summary>
        public Game1()
        {
            InitializeComponent();

            float aspectRatio = 640.0f / 480.0f;
            float fov         = MathHelper.PiOver4;

            // Initialize the matrices.
            this.viewTransformation       = Matrix.CreateLookAt(new Vector3(0, 0, 150), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            this.projectionTransformation = Matrix.CreatePerspectiveFieldOfView(fov, aspectRatio, 1, 600);

            // Initialize the shader.
            CompiledEffect cEffect = Effect.CompileEffectFromFile("color.fx", null, null, CompilerOptions.None, TargetPlatform.Windows);

            this.effect = new Effect(this.graphics.GraphicsDevice, cEffect.GetShaderCode(), CompilerOptions.None, null);

            // Get the parameters.
            EffectParameterCollection coll = this.effect.Parameters;

            this.transform = coll.GetParameterBySemantic("WorldViewProjection");
            this.color     = coll.GetParameterBySemantic("Color");

            // Create and add volumes.
            this.volumes = new List <BoundingVolume>();
            this.AddBoundingVolumes();
        }