public void Update(ITimer timer)
        {
            float t = timer == null ? 0.0f : (float)timer.TotalSeconds;
            float d = timer == null ? 0.0f : (float)timer.ElapsedSeconds;

            this.worldMatrix = XMMatrix.RotationY(t);

            // Rotate the second light around the origin
            XMMatrix rotate = XMMatrix.RotationY(-2.0f * d);

            this.lightDirs[1] = XMVector3.Transform(this.lightDirs[1], rotate);
        }
        public void Update(ITimer timer)
        {
            float t = timer == null ? 0.0f : (float)timer.TotalSeconds;

            this.worldMatrix = XMMatrix.RotationY(t);

            this.meshColor = new XMVector(
                (XMScalar.Sin(t * 1.0f) + 1.0f) * 0.5f,
                (XMScalar.Cos(t * 3.0f) + 1.0f) * 0.5f,
                (XMScalar.Sin(t * 5.0f) + 1.0f) * 0.5f,
                1.0f);
        }
        public void Update(ITimer timer)
        {
            float t = timer == null ? 0.0f : (float)timer.TotalSeconds;

            this.worldMatrix1 = XMMatrix.RotationY(t);

            XMMatrix spin      = XMMatrix.RotationZ(-t);
            XMMatrix orbit     = XMMatrix.RotationY(-t * 2.0f);
            XMMatrix translate = XMMatrix.Translation(-4.0f, 0.0f, 0.0f);
            XMMatrix scale     = XMMatrix.Scaling(0.3f, 0.3f, 0.3f);

            this.worldMatrix2 = scale * spin * translate * orbit;
        }
        public void CreateDeviceDependentResources(DeviceResources resources)
        {
            this.deviceResources = resources;

            XMFloat3 vCenter = new XMFloat3(0.25767413f, -28.503521f, 111.00689f);
            XMMatrix m       = XMMatrix.Translation(-vCenter.X, -vCenter.Y, -vCenter.Z);

            m *= XMMatrix.RotationY(XMMath.PI);
            m *= XMMatrix.RotationX(XMMath.PIDivTwo);
            this.centerMesh = m;

            // Load the mesh
            this.mesh = SdkMeshFile.FromFile(
                this.deviceResources.D3DDevice,
                this.deviceResources.D3DContext,
                "Tiny\\Tiny.sdkmesh");

            // Create the shaders
            byte[] vertexShaderBytecode = File.ReadAllBytes("BasicHLSL11_VS.cso");
            this.vertexShader = this.deviceResources.D3DDevice.CreateVertexShader(vertexShaderBytecode, null);

            D3D11InputElementDesc[] layoutDesc = new D3D11InputElementDesc[]
            {
                new D3D11InputElementDesc
                {
                    SemanticName         = "POSITION",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32B32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 0,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                },
                new D3D11InputElementDesc
                {
                    SemanticName         = "NORMAL",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32B32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 12,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                },
                new D3D11InputElementDesc
                {
                    SemanticName         = "TEXCOORD",
                    SemanticIndex        = 0,
                    Format               = DxgiFormat.R32G32Float,
                    InputSlot            = 0,
                    AlignedByteOffset    = 24,
                    InputSlotClass       = D3D11InputClassification.PerVertexData,
                    InstanceDataStepRate = 0
                }
            };

            this.inputLayout = this.deviceResources.D3DDevice.CreateInputLayout(layoutDesc, vertexShaderBytecode);

            byte[] pixelShaderBytecode = File.ReadAllBytes("BasicHLSL11_PS.cso");
            this.pixelShader = this.deviceResources.D3DDevice.CreatePixelShader(pixelShaderBytecode, null);

            // Create a sampler state
            D3D11SamplerDesc samplerDesc = new D3D11SamplerDesc(
                D3D11Filter.MinMagMipLinear,
                D3D11TextureAddressMode.Wrap,
                D3D11TextureAddressMode.Wrap,
                D3D11TextureAddressMode.Wrap,
                0.0f,
                1,
                D3D11ComparisonFunction.Always,
                new float[] { 0.0f, 0.0f, 0.0f, 0.0f },
                0.0f,
                float.MaxValue);

            this.sampler = this.deviceResources.D3DDevice.CreateSamplerState(samplerDesc);

            // Setup constant buffers
            this.constantBufferVSPerObject = this.deviceResources.D3DDevice.CreateBuffer(
                new D3D11BufferDesc(ConstantBufferVSPerObject.Size, D3D11BindOptions.ConstantBuffer));

            this.constantBufferPSPerObject = this.deviceResources.D3DDevice.CreateBuffer(
                new D3D11BufferDesc(ConstantBufferPSPerObject.Size, D3D11BindOptions.ConstantBuffer));

            this.constantBufferPSPerFrame = this.deviceResources.D3DDevice.CreateBuffer(
                new D3D11BufferDesc(ConstantBufferPSPerFrame.Size, D3D11BindOptions.ConstantBuffer));
        }
Пример #5
0
        public void Update(ITimer timer)
        {
            float t = timer == null ? 0.0f : (float)timer.TotalSeconds;

            this.worldMatrix = XMMatrix.RotationY(t);
        }