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


C# RenderContext.ThrowIfRenderPassMissing方法代码示例

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


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

示例1: Render

        public override void Render(IList<SceneNode> nodes, RenderContext context, RenderOrder order)
        {
            ThrowIfDisposed();

              if (nodes == null)
            throw new ArgumentNullException("nodes");
              if (context == null)
            throw new ArgumentNullException("context");

              int numberOfNodes = nodes.Count;
              if (numberOfNodes == 0)
            return;

              context.ThrowIfCameraMissing();
              context.ThrowIfRenderPassMissing();

              var graphicsService = context.GraphicsService;
              var graphicsDevice = graphicsService.GraphicsDevice;

              var cameraNode = context.CameraNode;

              // Update SceneNode.LastFrame for all visible nodes.
              int frame = context.Frame;
              cameraNode.LastFrame = frame;

              var savedRenderState = new RenderStateSnapshot(graphicsDevice);

              for (int i = 0; i < numberOfNodes; i++)
              {
            var node = nodes[i] as TerrainNode;
            if (node == null)
              continue;

            // Node is visible in current frame.
            node.LastFrame = frame;

            if (!node.MaterialInstance.Contains(context.RenderPass))
              continue;

            TerrainRendererMesh mesh;
            var meshKey = new Pair<int, int>(node.BaseClipmap.NumberOfLevels, node.BaseClipmap.CellsPerLevel);
            bool meshExists = _meshes.TryGetValue(meshKey, out mesh);
            if (!meshExists || mesh.IsDisposed)
            {
              // Warning: This may take a few seconds!
              mesh = new TerrainRendererMesh(graphicsDevice, node.BaseClipmap.NumberOfLevels, node.BaseClipmap.CellsPerLevel);
              _meshes[meshKey] = mesh;
            }

            // Get the EffectBindings and the Effect for the current render pass.
            EffectBinding materialInstanceBinding = node.MaterialInstance[context.RenderPass];
            EffectBinding materialBinding = node.Material[context.RenderPass];
            Effect effect = materialBinding.Effect;

            // Add this info to the render context. This info will be needed by parameter bindings.
            context.SceneNode = node;
            context.MaterialInstanceBinding = materialInstanceBinding;
            context.MaterialBinding = materialBinding;

            // Update and apply global effect parameter bindings - these bindings set the
            // effect parameter values for "global" parameters. For example, if an effect uses
            // a "ViewProjection" parameter, then a binding will compute this matrix from the
            // current CameraInstance in the render context and update the effect parameter.
            foreach (var binding in effect.GetParameterBindings())
            {
              if (binding.Description.Hint == EffectParameterHint.Global)
              {
            binding.Update(context);
            binding.Apply(context);
              }
            }

            // Update and apply material bindings - these are usually constant parameter values,
            // like textures or colors, that are defined in the fbx file or material description
            // (XML files).
            //SetHoleParameter(materialBinding, context);
            foreach (var binding in materialBinding.ParameterBindings)
            {
              binding.Update(context);
              binding.Apply(context);
            }

            // Update and apply local, per-instance, and per-pass bindings - these are bindings
            // for parameters, like the "World" matrix or lighting parameters.
            foreach (var binding in materialInstanceBinding.ParameterBindings)
            {
              if (binding.Description.Hint != EffectParameterHint.PerPass)
              {
            binding.Update(context);
            binding.Apply(context);
              }
            }

            // Select and apply technique.
            var techniqueBinding = materialInstanceBinding.TechniqueBinding;
            techniqueBinding.Update(context);
            var technique = techniqueBinding.GetTechnique(effect, context);
            effect.CurrentTechnique = technique;

            var passBinding = techniqueBinding.GetPassBinding(technique, context);
//.........这里部分代码省略.........
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:101,代码来源:TerrainRenderer.cs


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