當前位置: 首頁>>代碼示例>>C#>>正文


C# Effect.CommitChanges方法代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Effect.CommitChanges方法的典型用法代碼示例。如果您正苦於以下問題:C# Effect.CommitChanges方法的具體用法?C# Effect.CommitChanges怎麽用?C# Effect.CommitChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Xna.Framework.Graphics.Effect的用法示例。


在下文中一共展示了Effect.CommitChanges方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: m000001

 public static void m000001()
 {
     f000058 = new SpriteBatch(c000074.m0000d4());
     f0000c1 = c000074.f0000b0.Load<Effect>("Blur");
     f0000e0 = f0000c1.Parameters["pixelSize"];
     f0000e0.SetValue(new Vector2(1f / ((float) c000074.m00000f()), 1f / ((float) c000074.m000010())));
     f0000c1.CommitChanges();
     f00000a = true;
 }
開發者ID:bing2008,項目名稱:CastNetGame,代碼行數:9,代碼來源:c00008b.cs

示例2: Draw

 public void Draw(Effect effect)
 {
     this.graphics.Vertices[0].SetSource(this.vertBuffer, 0, 28);
     for (int i = 0; i < 16; i++)
     {
         for (int j = 0; j < 16; j++)
         {
             effect.Parameters["Texture1"].SetValue(this.zon.GetBottomTexture(this.til.GetTile(i, j).tileID));
             effect.Parameters["Texture2"].SetValue(this.zon.GetTopTexture(this.til.GetTile(i, j).tileID));
             effect.CommitChanges();
             for (int k = 0; k < effect.CurrentTechnique.Passes.Count; k++)
             {
                 effect.CurrentTechnique.Passes[k].Begin();
                 this.graphics.DrawIndexedPrimitives(PrimitiveType.TriangleStrip, i * 400 + j * 25, 0, 25, 0, 44);
                 effect.CurrentTechnique.Passes[k].End();
             }
         }
     }
 }
開發者ID:Jiwan,項目名稱:ROSE-Camera-Editor,代碼行數:19,代碼來源:MapBlock.cs

示例3: DrawPart

        /// <summary>
        /// DrawPart draws the actual ModelMeshPart
        /// </summary>
        /// <param name="transforms"></param>
        /// <param name="animations"></param>
        /// <param name="effect"></param>
        /// <param name="part"></param>
        private void DrawPart(Matrix [] transforms, int [] animations, Effect effect, ModelMeshPart part)
        {
            for (int i = 0; i < transforms.Length; i += maxInstances)
            {
                // How many instances can we fit into this batch?
                int instanceCount = transforms.Length- i;

                if (instanceCount > maxInstances)
                    instanceCount = maxInstances;

                // Copy transform and animation data
                Array.Copy(transforms, i, tempTransforms, 0, instanceCount);
                Array.Copy(animations, i, tempAnimations, 0, instanceCount);

                // Send the transform and animation data to the shader
                effect.Parameters["InstanceTransforms"].SetValue(tempTransforms);
                effect.Parameters["InstanceAnimations"].SetValue(tempAnimations);
                effect.CommitChanges();

                // Draw maxInstances copies of our geometry in a single batch.
                this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList,
                    part.BaseVertex, 0, part.NumVertices * instanceCount,
                    part.StartIndex, part.PrimitiveCount * instanceCount);
            }
        }
開發者ID:extr0py,項目名稱:xna-skinned-model-instancing,代碼行數:32,代碼來源:InstancedSkinnedModelMesh.cs

示例4: InitializeEffects

        /// <summary>
        /// Loads all effects and initializes effect variables
        /// </summary>
        /// <remarks>
        /// This method is automatically called when FlatRedBall is Initialized if
        /// post processing is suppoted in the current build of the engine. 
        /// </remarks>
        #endregion
        internal static void InitializeEffects()
        {
#if !MONOGAME
            // Create the sprite batch
            mSpriteBatch = new SpriteBatch(FlatRedBallServices.GraphicsDevice);

            // Shared parameters
            #region Get and initialize shared parameters

            // Get the effect

            // If modifying the shaders uncomment the following file:
            //mSharedParametersEffect = FlatRedBallServices.Load<Effect>(@"Assets\Shaders\PostProcessing\Blur");
            // Otherwise, keep the following line uncommented so the .xnb files in the
            // resources are used.
            mSharedParametersEffect = FlatRedBallServices.mResourceContentManager.Load<Effect>(@"Blur");

            // Get shared effect parameters
            mPixelSize = mSharedParametersEffect.Parameters["pixelSize"];

            // Initialize shared effect parameters
            mPixelSize.SetValue(new Vector2(
                1f / (float)FlatRedBallServices.ClientWidth,
                1f / (float)FlatRedBallServices.ClientHeight));

            // Commit
#if !XNA4
            mSharedParametersEffect.CommitChanges();
#endif
            #endregion
#endif
            mIsInitialized = true;
        }
開發者ID:vchelaru,項目名稱:FlatRedBall,代碼行數:41,代碼來源:PostProcessingManager.cs

示例5: Draw

    public void Draw( GraphicsDevice device, Effect effect, EffectParameter worldParam, EffectParameter colorParam )
    {
      foreach ( MeshParticle particle in particles )
      {
        colorParam.SetValue( new Vector4( .69f, .75f, .82f, particle.Alpha ) );

        ModelBone startBone;
        Matrix originTransform = XFileUtils.GetOriginTransform( particle.Mesh.ParentBone, out startBone );
        Matrix rotate = Matrix.CreateFromAxisAngle( particle.Axis, particle.Angle );
        Matrix translate = Matrix.CreateTranslation( particle.Position );
        Matrix offsetTransform = XFileUtils.GetTransform( startBone );
        worldParam.SetValue( originTransform * rotate * translate * offsetTransform * worldTransform );

        effect.CommitChanges();

        foreach ( ModelMeshPart part in particle.Mesh.MeshParts )
        {
          device.Vertices[0].SetSource( particle.Mesh.VertexBuffer, part.StreamOffset, part.VertexStride );
          device.Indices = particle.Mesh.IndexBuffer;
          device.DrawIndexedPrimitives( PrimitiveType.TriangleList, part.BaseVertex, 0, part.NumVertices,
                                        part.StartIndex, part.PrimitiveCount );
        }
      }
    }
開發者ID:yxrkt,項目名稱:AvatarHamsterPanic,代碼行數:24,代碼來源:ModelExplosion.cs

示例6: Draw

        public void Draw(Effect effect,
                         string colorMapParamName,
                         string normalMapParamName,
                         string heightMapParamName,
                         Texture2D wallColorMap,
                         Texture2D wallNormalMap,
                         Texture2D wallHeightMap,
                         Texture2D floorColorMap,
                         Texture2D floorNormalMap,
                         Texture2D floorHeightMap,
                         Texture2D ceilingColorMap,
                         Texture2D ceilingNormalMap,
                         Texture2D ceilingHeightMap,
                         bool drawingCeiling)
        {
            graphicsDevice.VertexDeclaration = vertexDeclaration;
            graphicsDevice.Vertices[0].SetSource(vertexBuffer, 0, NormalMappedVertex.SizeInBytes);

            // Draw the scene geometry.

            effect.Begin();

            // Draw the walls.

            effect.Parameters[colorMapParamName].SetValue(wallColorMap);
            effect.Parameters[normalMapParamName].SetValue(wallNormalMap);
            effect.Parameters[heightMapParamName].SetValue(wallHeightMap);
            effect.CommitChanges();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, wallsIndex, 8);
                pass.End();
            }

            if (drawingCeiling)
            {
                // Draw the ceiling.

                effect.Parameters[colorMapParamName].SetValue(ceilingColorMap);
                effect.Parameters[normalMapParamName].SetValue(ceilingNormalMap);
                effect.Parameters[heightMapParamName].SetValue(ceilingHeightMap);
                effect.CommitChanges();

                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Begin();
                    graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, ceilingIndex, 2);
                    pass.End();
                }
            }

            // Draw the floor.

            effect.Parameters[colorMapParamName].SetValue(floorColorMap);
            effect.Parameters[normalMapParamName].SetValue(floorNormalMap);
            effect.Parameters[heightMapParamName].SetValue(floorHeightMap);
            effect.CommitChanges();

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, floorIndex, 2);
                pass.End();
            }

            effect.End();
        }
開發者ID:narfman0,項目名稱:SunshineSlashers,代碼行數:69,代碼來源:NormalMappingUtils.cs

示例7: prepare_effect

 public void prepare_effect(ref Matrix view, ref Matrix project, Effect effect)
 {
     this.matrices_combined[0] = this.world_matrix;
     this.matrices_combined[1] = (this.world_matrix * view) * project;
     this.matrices_combined[2] = this.inverse_scale_transpose;
     this.shader_matrices.SetValue(this.matrices_combined);
     this.v4colors[0] = this.colors[0].ToVector4();
     this.v4colors[1] = this.colors[1].ToVector4();
     this.v4colors[0].W = this.heat;
     this.thrust_color.SetValue(this.v4colors);
     this.effect_tick.SetValue(this.tick);
     this.effect_noise.SetValue(this.Noise);
     effect.CommitChanges();
 }
開發者ID:castroev,項目名稱:StardriveBlackBox-verRadicalElements-,代碼行數:14,代碼來源:Thruster.cs

示例8: Draw

        public void Draw(Effect effect)
        {
            Update(0);
               effect.Parameters["world"].SetValue(rot);
               effect.Parameters["k"].SetValue(k);
               effect.Parameters["uv"].SetValue(uv);
               effect.Parameters["tex"].SetValue(tex);
               effect.CommitChanges();

               foreach (ModelMesh mesh in model.Meshes)
               {
            p.gd.VertexDeclaration = mesh.MeshParts[0].VertexDeclaration;
            p.gd.Vertices[0].SetSource(mesh.VertexBuffer, 0, mesh.MeshParts[0].VertexStride);
            p.gd.Indices = mesh.IndexBuffer;

            p.gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);
               }
        }
開發者ID:zaibatsu,項目名稱:IceTower,代碼行數:18,代碼來源:mesh2D.cs

示例9: Draw

        public void Draw(Effect VertexShader, Effect PixelShader, Matrix ProjectionMatrix, Matrix ViewMatrix, Matrix WorldMatrix)
        {
            float FisoScale = (float)Math.Sqrt(0.5 * 0.5 * 2) / 5.10f; // is 5.10 on far zoom
            float ZisoScale = (float)Math.Sqrt(0.5 * 0.5 * 2) / 144f;  // currently set 144 to near zoom
            float IsoScale = (1 - m_ZoomProgress) * FisoScale + (m_ZoomProgress) * ZisoScale;

            float HB = m_GraphicsDevice.Viewport.Width * IsoScale;
            float VB = m_GraphicsDevice.Viewport.Height * IsoScale;

            ProjectionMatrix *= Matrix.CreateOrthographicOffCenter(-HB + m_ViewOffX, HB + m_ViewOffX, -VB + m_ViewOffY, VB + m_ViewOffY, 0.1f, 1000000);
            ViewMatrix *= Matrix.Identity;

            ViewMatrix *= Matrix.CreateTranslation(new Vector3(-360, 0, -512));

            ViewMatrix *= Matrix.CreateRotationX((30 / 180) * (float)Math.PI);
            ViewMatrix *= Matrix.CreateRotationY((45 / 180) * (float)Math.PI);
            ViewMatrix *= Matrix.CreateScale(new Vector3(1, 0.5f + (1 - m_ZoomProgress) / 2, 1));

            VertexShader.CurrentTechnique = VertexShader.Techniques[0];
            VertexShader.Parameters["ViewMatrix"].SetValue(ViewMatrix);
            VertexShader.Parameters["ProjectionViewMatrix"].SetValue(ProjectionMatrix);
            VertexShader.Parameters["WorldMatrix"].SetValue(WorldMatrix);
            VertexShader.CommitChanges();

            PixelShader.CurrentTechnique = PixelShader.Techniques[0];
            //PixelShader.Parameters["LightCol"].SetValue(new Vector4(0.356f, 0.451f, 0.541f, 1)); //night
            PixelShader.Parameters["LightCol"].SetValue(new Vector4(1, 1, 1, 1)); //day
            PixelShader.Parameters["VertexColorTex"].SetValue(m_VertexColor);
            PixelShader.Parameters["TextureAtlasTex"].SetValue(Atlas);
            PixelShader.Parameters["TransAtlasTex"].SetValue(TransAtlas);
            PixelShader.CommitChanges();

            VertexShader.Begin();
            VertexShader.CurrentTechnique.Passes[0].Begin();
            PixelShader.Begin();
            PixelShader.CurrentTechnique.Passes[0].Begin();

            m_GraphicsDevice.DrawUserPrimitives<MeshVertex>(PrimitiveType.TriangleFan, m_Verts, 0, m_Verts.Length / 3);

            VertexShader.CurrentTechnique.Passes[0].End();
            VertexShader.End();
            PixelShader.CurrentTechnique.Passes[0].End();
            PixelShader.End();
        }
開發者ID:Tranquill6,項目名稱:Project-Dollhouse,代碼行數:44,代碼來源:Terrain.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Effect.CommitChanges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。