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


C# Effect.CommitChanges方法代码示例

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


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

示例1: RenderXMeshesWithInstancing

        private void RenderXMeshesWithInstancing(Dictionary<SlimDX.Direct3D9.Mesh, RenderMesh> meshes, Device device, Effect effect, string technique)
        {
            effect.Technique = technique;

            effect.Begin(fx);
            effect.BeginPass(0);

            int k = 0;

            device.VertexFormat = VertexFormat.None;
            device.VertexDeclaration = vd;

            foreach (SlimDX.Direct3D9.Mesh mesh in meshes.Keys)
            {
                device.Indices = meshes[mesh].IndexBuffer;

                foreach (Texture texture in meshes[mesh].Textures.Keys)
                {
                    bool first = true;
                    int numberOfInstancedDraws = 0;

                    DataStream ds = null;

                    foreach (Common.Tuple<Graphics.Content.Model9, Entity, string> renderObject in meshes[mesh].Textures[texture].RenderObjects)
                    {
                        Entity entity = renderObject.Second;

                        if (entity.ActiveInMain == Frame)
                        {
                            if (first)
                            {
                                MetaModel metaModel = GetLatestMetaModel(entity, renderObject.Third);

                                //if (Settings.PriorityRelation[metaModel.Visible] + Settings.TerrainQualityPriorityRelation[Settings.TerrainQuality] < 3)
                                //    break;

                                effect.SetTexture(EHTexture, texture);
                                ds = optimizedVB[k % optimizedVB.Length].Lock(0, meshes[mesh].Textures[texture].RenderObjects.Count * (Vector4.SizeInBytes * 4), LockFlags.None);

                                if (renderObject.First.SpecularTexture != null)
                                    effect.SetTexture(EHSpecularMap, renderObject.First.SpecularTexture);

                                UpdateEffectWithMetaModel(effect, metaModel, false);

                                effect.CommitChanges();
                                first = false;
                            }

                            Matrix worldMatrix;
                            //Matrix normalMatrix;

                            if (renderObject.First.SkinnedMesh != null)
                            {
                                Matrix[] storedMatrices =
                                    GetLatestMetaModel(renderObject.Second, renderObject.Third).StoredFrameMatrices[mesh][0];
                                worldMatrix = storedMatrices[0];
                                //normalMatrix = storedMatrices.Second[0];
                            }
                            else
                            {
                                MetaModel metaModel = GetLatestMetaModel(entity, renderObject.Third);
                                worldMatrix = metaModel.GetWorldMatrix(Scene.Camera, renderObject.Second);
                                //normalMatrix = Matrix.Transpose(Matrix.Invert(worldMatrix));
                            }

                            ds.Write(worldMatrix);

                            //ThreeTimesThreeMatrix matrix;

                            //matrix.M11 = normalMatrix.M11;
                            //matrix.M12 = normalMatrix.M12;
                            //matrix.M13 = normalMatrix.M13;
                            //matrix.M21 = normalMatrix.M21;
                            //matrix.M22 = normalMatrix.M22;
                            //matrix.M23 = normalMatrix.M23;
                            //matrix.M31 = normalMatrix.M31;
                            //matrix.M32 = normalMatrix.M32;
                            //matrix.M33 = normalMatrix.M33;
                            //ds.Write(matrix);

                            numberOfInstancedDraws++;
                        }
                    }

            #if RENDERER_STATISTICS
                    if (maxNumberOfInstancedDrawCalls < numberOfInstancedDraws)
                        maxNumberOfInstancedDrawCalls = numberOfInstancedDraws;
                    if (minNumberOfInstancedDrawCalls > numberOfInstancedDraws)
                        minNumberOfInstancedDrawCalls = numberOfInstancedDraws;
            #endif

                    if (numberOfInstancedDraws == 0)
                        continue;

                    optimizedVB[k % optimizedVB.Length].Unlock();

                    DrawInstancedIndexedPrimitives(device, mesh, meshes[mesh].VertexBuffer, optimizedVB[k % optimizedVB.Length], instancedVertexElements,
                            numberOfInstancedDraws);

                    k++;
//.........这里部分代码省略.........
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:101,代码来源:SortedTestRenderer.cs

示例2: RenderSkinnedMeshWithSkinning

        private void RenderSkinnedMeshWithSkinning(Common.Tuple<CustomFrame, CustomMeshContainer> SM, Effect effect, bool withShadows, Matrix[][] combinedTransforms)
        {
            for (int i = 0; i < combinedTransforms.Length; i++)
            {
                if (combinedTransforms[i] != null)
                {
                    effect.SetValue(EHWorldMatrices, combinedTransforms[i]);
                    effect.SetValue(EHCurrentBoneCount, SM.Second.Influences - 1);

                    //if (!withShadows)
                        //effect.SetValue(EHNormalMatrices, combinedTransforms[i].Second);

                    effect.CommitChanges();

                    SM.Second.MeshData.Mesh.DrawSubset(i);
                }
            }
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:18,代码来源:SortedTestRenderer.cs

示例3: RenderXMeshes

        private void RenderXMeshes(Dictionary<SlimDX.Direct3D9.Mesh, RenderMesh> meshes, Effect effect, Matrix viewProjection, string technique)
        {
            effect.Technique = technique;

            effect.Begin(fx);
            effect.BeginPass(0);

            foreach (SlimDX.Direct3D9.Mesh mesh in meshes.Keys)
            {
                foreach (Texture texture in meshes[mesh].Textures.Keys)
                {
                    effect.SetTexture(EHTexture, texture);
                    if (meshes[mesh].Textures[texture].RenderObjects[0].First.SpecularTexture != null)
                        effect.SetTexture(EHSpecularMap, meshes[mesh].Textures[texture].RenderObjects[0].First.SpecularTexture);

                    foreach (Common.Tuple<Graphics.Content.Model9, Entity, string> renderObject in meshes[mesh].Textures[texture].RenderObjects)
                    {
                        if (renderObject.Second.ActiveInMain == Frame)
                        {
                            Matrix worldMatrix;
                            MetaModel metaModel = GetLatestMetaModel(renderObject.Second, renderObject.Third);

                            if (renderObject.First.SkinnedMesh != null)
                            {
                                worldMatrix = metaModel.StoredFrameMatrices[mesh][0][0];
                            }
                            else
                            {
                                worldMatrix = metaModel.GetWorldMatrix(Scene.Camera, renderObject.Second);
                                worldMatrix = Matrix.Identity;
                            }
                            UpdateEffectWithMetaModel(effect, metaModel, false);

                            effect.SetValue(EHShadowWorldViewProjection, worldMatrix * ShadowMapCamera);
                            effect.SetValue(EHWorldViewProjectionMatrix, worldMatrix * viewProjection);
                            effect.SetValue(EHWorldMatrix, worldMatrix);

                            effect.CommitChanges();

                            mesh.DrawSubset(0);
                        }
                    }
                }
            }

            effect.EndPass();
            effect.End();
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:48,代码来源:SortedTestRenderer.cs

示例4: RenderSkinnedMeshWithoutSkinning

        private void RenderSkinnedMeshWithoutSkinning(Common.Tuple<CustomFrame, CustomMeshContainer> SM, Effect effect, bool withShadows, Matrix viewProjection, Matrix[][] combinedTransforms)
        {
            if (withShadows)
            {
                effect.SetValue(EHShadowWorldViewProjection, combinedTransforms[0][0] * ShadowMapCamera);
                effect.CommitChanges();
                SM.Second.MeshData.Mesh.DrawSubset(0);
            }
            else
            {
                effect.SetValue(EHShadowWorldViewProjection, combinedTransforms[0][0] * ShadowMapCamera);
                effect.SetValue(EHWorldViewProjectionMatrix, combinedTransforms[0][0] * viewProjection);
                //effect.SetValue(EHWorldMatrix, SM.First.CombinedTransform);
                effect.SetValue(EHWorldMatrix, combinedTransforms[0][0]);
                //effect.SetValue(EHNormalMatrix, combinedTransforms[0].Second[0]);

                effect.CommitChanges();
                SM.Second.MeshData.Mesh.DrawSubset(0);
            }
        }
开发者ID:ChristianMarchiori,项目名称:DeadMeetsLead,代码行数:20,代码来源:SortedTestRenderer.cs


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