当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3D.ToMatrix4x4F方法代码示例

本文整理汇总了C#中System.Windows.Media.Media3D.Matrix3D.ToMatrix4x4F方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3D.ToMatrix4x4F方法的具体用法?C# Matrix3D.ToMatrix4x4F怎么用?C# Matrix3D.ToMatrix4x4F使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Media3D.Matrix3D的用法示例。


在下文中一共展示了Matrix3D.ToMatrix4x4F方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        /// <summary>
        /// Renders the mesh with the specified transformation. This alternate render method
        /// supplements the base class rendering to provide part-by-part texturing support.
        /// </summary>
        /// <param name="modelTransform"></param>
        public void Render(Matrix3D modelTransform)
        {
            // setup rasterization
            RasterizerDescription rasterizerDescription = new RasterizerDescription()
            {
                FillMode = FillMode.Solid,
                CullMode = CullMode.Back,
                FrontCounterclockwise = false,
                DepthBias = 0,
                DepthBiasClamp = 0,
                SlopeScaledDepthBias = 0,
                DepthClipEnable = true,
                ScissorEnable = false,
                MultisampleEnable = true,
                AntiAliasedLineEnable = true
            };

            try
            {
                solidRasterizerState = this.manager.device.CreateRasterizerState(rasterizerDescription);

                rasterizerDescription.FillMode = FillMode.Wireframe;
                wireframeRasterizerState = this.manager.device.CreateRasterizerState(rasterizerDescription);

                base.Render(modelTransform.ToMatrix4x4F());
            }
            finally
            {
                if (solidRasterizerState != null)
                {
                    solidRasterizerState.Dispose();
                    solidRasterizerState = null;
                }

                if (wireframeRasterizerState != null)
                {
                    wireframeRasterizerState.Dispose();
                    wireframeRasterizerState = null;
                }

                currentRasterizerState = null;
            }
        }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:48,代码来源:Texturizer.cs

示例2: RenderPart

        private void RenderPart(Part part, Matrix3D parentMatrix, ShaderResourceView parentTextureOverride)
        {
            // set part transform
            Transform3DGroup partGroup = new Transform3DGroup();
            partGroup.Children.Add(new MatrixTransform3D(PartAnimation(part.name)));
            partGroup.Children.Add(new MatrixTransform3D(part.partTransform.ToMatrix3D()));
            partGroup.Children.Add(new MatrixTransform3D(parentMatrix));

            parentMatrix = partGroup.Value;

            ShaderResourceView textureOverride = UpdateRasterizerStateForPart(part);

            if (textureOverride == null)
            {
                textureOverride = parentTextureOverride;
            }
            else
            {
                parentTextureOverride = textureOverride;
            }

            if (part.vertexBuffer != null)
            {
                EffectTechnique technique;

                if (textureOverride != null)
                {
                    technique = this.manager.techniqueRenderTexture;
                    this.manager.diffuseVariable.Resource = textureOverride;
                }
                else if (part.material == null)
                {
                    technique = this.manager.techniqueRenderVertexColor;
                }
                else
                {
                    if (part.material.textureResource != null)
                    {
                        technique = this.manager.techniqueRenderTexture;
                        this.manager.diffuseVariable.Resource = part.material.textureResource;
                    }
                    else
                    {
                        technique = this.manager.techniqueRenderMaterialColor;
                        this.manager.materialColorVariable.FloatVector = part.material.materialColor;
                    }
                }

                this.manager.worldVariable.Matrix = parentMatrix.ToMatrix4x4F();

                //set up vertex buffer and index buffer
                uint stride = (uint)Marshal.SizeOf(typeof(XMeshVertex));
                uint offset = 0;
                this.manager.device.IA.SetVertexBuffers(0, new D3DBuffer[]
                    { part.vertexBuffer },
                    new uint[] { stride },
                    new uint[] { offset });

                //Set primitive topology
                this.manager.device.IA.PrimitiveTopology = PrimitiveTopology.TriangleList;

                TechniqueDescription techDesc = technique.Description;
                for (uint p = 0; p < techDesc.Passes; ++p)
                {
                    technique.GetPassByIndex(p).Apply();
                    PassDescription passDescription = technique.GetPassByIndex(p).Description;

                    using (InputLayout inputLayout = this.manager.device.CreateInputLayout(
                            part.dataDescription,
                            passDescription.InputAssemblerInputSignature,
                            passDescription.InputAssemblerInputSignatureSize))
                    {
                        // set vertex layout
                        this.manager.device.IA.InputLayout = inputLayout;

                        // draw part
                        this.manager.device.Draw((uint)part.vertexCount, 0);

                        // Note: In Direct3D 10, the device will not retain a reference
                        // to the input layout, so it's important to reset the device's
                        // input layout before disposing the object.  Were this code
                        // using Direct3D 11, the device would in fact retain a reference
                        // and so it would be safe to go ahead and dispose the input
                        // layout without resetting it; in that case, there could be just
                        // a single assignment to null outside the 'for' loop, or even
                        // no assignment at all.
                        this.manager.device.IA.InputLayout = null;
                    }
                }
            }

            foreach (Part childPart in part.parts)
            {
                RenderPart(childPart, parentMatrix, parentTextureOverride);
            }
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:96,代码来源:XMesh.cs


注:本文中的System.Windows.Media.Media3D.Matrix3D.ToMatrix4x4F方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。