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


C# IRenderContext.IsCurrentRenderPass方法代码示例

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


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

示例1: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            if (renderContext.IsCurrentRenderPass<I2DDirectRenderPass>())
            {
                if (_analyzerEntity.TopLeftNormalized != null && _analyzerEntity.TopRightNormalized != null &&
                    _analyzerEntity.BottomLeftNormalized != null && _analyzerEntity.BottomRightNormalized != null)
                {
                    _cachedTopLeft = _analyzerEntity.TopLeftNormalized;
                    _cachedTopRight = _analyzerEntity.TopRightNormalized;
                    _cachedBottomLeft = _analyzerEntity.BottomLeftNormalized;
                    _cachedBottomRight = _analyzerEntity.BottomRightNormalized;
                }

                if (_cachedTopLeft != null && _cachedTopRight != null &&
                    _cachedBottomLeft != null && _cachedBottomRight != null)
                { 
                    _warpFromPolygonEffect.Effect.Parameters["TopLeft"].SetValue(_cachedTopLeft.Value);
                    _warpFromPolygonEffect.Effect.Parameters["TopRight"].SetValue(_cachedTopRight.Value);
                    _warpFromPolygonEffect.Effect.Parameters["BottomLeft"].SetValue(_cachedBottomLeft.Value);
                    _warpFromPolygonEffect.Effect.Parameters["BottomRight"].SetValue(_cachedBottomRight.Value);
                    _warpFromPolygonEffect.Effect.Parameters["Alpha"].SetValue(_alpha);

                    _graphicsBlit.Blit(
                        renderContext,
                        _webcamEntity.VideoCaptureFrame,
                        null,
                        _warpFromPolygonEffect.Effect,
                        BlendState.AlphaBlend);
                }
            }
        }
开发者ID:hach-que,项目名称:Augmented-Board-Game,代码行数:33,代码来源:BoardRendererEntity.cs

示例2: QueueRequest

        public void QueueRequest(IRenderContext renderContext, IRenderRequest request)
        {
            if (renderContext.IsCurrentRenderPass<I3DBatchedRenderPass>())
            {
                if (!_requestLookup.ContainsKey(request.StateHash))
                {
                    _requestLookup[request.StateHash] = request;
                }

                if (!_requestInstances.ContainsKey(request.StateHash))
                {
                    _requestInstances[request.StateHash] = new List<Matrix>();
                }

                if (request.Instances.Length > 1)
                {
                    _requestInstances[request.StateHash].AddRange(request.Instances);
                }
                else
                {
                    _requestInstances[request.StateHash].Add(request.Instances[0]);
                }
            }
            else
            {
                RenderRequestImmediate(renderContext, request);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:28,代码来源:DefaultRenderBatcher.cs

示例3: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            if (renderContext.IsCurrentRenderPass<I2DBatchedRenderPass>())
            {
                var recogArray = _currentColor.RecognisedArray;

                if (recogArray == null)
                {
                    return;
                }

                WidthScale = (int) Math.Ceiling(renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth/
                                                (float) recogArray.GetLength(0));
                HeightScale = (int) Math.Ceiling(renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight/
                                                 (float) recogArray.GetLength(1));

                for (var x = 0; x < recogArray.GetLength(0); x++)
                {
                    for (var y = 0; y < recogArray.GetLength(1); y++)
                    {
                        Color col;
                        var score = recogArray[x, y]/_currentColor.Sensitivity;

                        //var scoreCapped = MathHelper.Clamp(score, 0f, 255f) / 255f;
                        //col = new Color(scoreCapped, scoreCapped, scoreCapped);

                        if (score < 0)
                        {
                            var scoreCapped = Math.Min(255, -score);
                            col = new Color(scoreCapped/255f, scoreCapped/255f, scoreCapped/255f, 1f);
                        }
                        else
                        {
                            var scoreCapped = Math.Max(0, score);
                            col = new Color(
                                scoreCapped/255f*(_currentColor.Color.R/255f),
                                scoreCapped/255f*(_currentColor.Color.G/255f),
                                scoreCapped/255f*(_currentColor.Color.B/255f),
                                1f);
                        }

                        _renderUtilities.RenderRectangle(
                            renderContext,
                            new Rectangle(
                                (int) (X + x*WidthScale), (int) (Y + y*HeightScale), WidthScale, HeightScale),
                            col, true);
                    }
                }

                _renderUtilities.RenderText(
                    renderContext,
                    new Vector2(
                        renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth/2,
                        40),
                    "Total " + _currentColor.Name + ": " + _currentColor.TotalDetected,
                    _defaultFont);
            }
        }
开发者ID:hach-que,项目名称:Augmented-Board-Game,代码行数:60,代码来源:DetectorEntity.cs

示例4: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!CanvasesEnabled)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<ICanvasRenderPass>())
            {
                var bounds = gameContext.Window.ClientBounds;
                bounds.X = 0;
                bounds.Y = 0;

                _lastRenderBounds = bounds;

                base.Render(gameContext, renderContext);

                Canvas?.Render(renderContext, _skinLayout, _skinDelegator, bounds);

                foreach (var window in Windows.OrderBy(x => x.Order))
                {
                    window.Render(renderContext, _skinLayout, _skinDelegator, window.Bounds);
                }
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:25,代码来源:CanvasEntity.cs

示例5: Prerender

        public void Prerender(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext)
        {
            var enabled = Enabled && renderContext.IsCurrentRenderPass<I3DRenderPass>();
            var debugEnabled = DebugEnabled && renderContext.IsCurrentRenderPass<IDebugRenderPass>();
            if (enabled || DebugEnabled)
            {
                var parentFinalTransform = (_node?.Parent?.UntypedValue as IHasTransform)?.FinalTransform;
                if (parentFinalTransform == null)
                {
                    return;
                }

                var sourceLocal = HeadOffset;
                var lookAtLocal = HeadOffset + Vector3.Transform(Vector3.Forward, Transform.LocalMatrix);
                var upLocal = HeadOffset + Vector3.Up;

                var sourceAbsolute = Vector3.Transform(sourceLocal, parentFinalTransform.AbsoluteMatrix);
                var lookAtAbsolute = Vector3.Transform(lookAtLocal, parentFinalTransform.AbsoluteMatrix);
                var upAbsolute = Vector3.Transform(upLocal, parentFinalTransform.AbsoluteMatrix) -
                                 Vector3.Transform(sourceLocal, parentFinalTransform.AbsoluteMatrix);

                if (enabled)
                {
                    _firstPersonCamera.Apply(
                        renderContext,
                        sourceAbsolute,
                        lookAtAbsolute,
                        upAbsolute,
                        FieldOfView);
                }
                else if (debugEnabled)
                {
                    _debugRenderer.RenderDebugLine(
                        renderContext,
                        sourceAbsolute,
                        lookAtAbsolute,
                        Color.Cyan,
                        Color.Cyan);
                    _debugRenderer.RenderDebugLine(
                        renderContext,
                        sourceAbsolute,
                        sourceAbsolute + upAbsolute,
                        Color.Cyan,
                        Color.Lime);
                }
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:47,代码来源:FirstPersonCameraComponent.cs

示例6: RenderDebugLine

        public void RenderDebugLine(IRenderContext renderContext, Vector3 point1, Vector3 point2, Color color1, Color color2)
        {
            if (renderContext.IsCurrentRenderPass<IDebugRenderPass>())
            {
                var debugRenderPass = renderContext.GetCurrentRenderPass<IDebugRenderPass>();

                debugRenderPass.Lines.Add(new VertexPositionNormalColor(point1, Vector3.Zero, color1));
                debugRenderPass.Lines.Add(new VertexPositionNormalColor(point2, Vector3.Zero, color2));
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:10,代码来源:DefaultDebugRenderer.cs

示例7: Render

        public override void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            base.Render(gameContext, renderContext);

            if (renderContext.IsCurrentRenderPass<I2DBatchedRenderPass>())
            {
                _renderUtilities.RenderText(
                    renderContext,
                    new Vector2(this.FinalTransform.AbsolutePosition.X, this.FinalTransform.AbsolutePosition.Y),
                    _name,
                    _defaultFont);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame.Template.Blank,代码行数:13,代码来源:ExampleEntity.cs

示例8: Render

        public void Render(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext)
        {
            if (!Enabled)
            {
                return;
            }

            if (!renderContext.IsCurrentRenderPass<I3DRenderPass>() && Texture != null)
            {
                _renderUtilities.RenderTexture(
                    renderContext,
                    new Vector2(entity.Transform.LocalPosition.X, entity.Transform.LocalPosition.Y),
                    Texture);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:15,代码来源:Render2DTextureComponent.cs

示例9: Render

        public void Render(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext)
        {
            if (!Enabled)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<I3DRenderPass>())
            {
                _renderUtilities.RenderCube(
                    renderContext,
                    Effect,
                    Effect.CreateParameterSet(),
                    Matrix.CreateTranslation(-0.5f, -0.5f, -0.5f) *
                    FinalTransform.AbsoluteMatrix, 
                    Color);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:18,代码来源:Render3DCubeComponent.cs

示例10: Render

        public void Render(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext)
        {
            if (!Enabled)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<I3DRenderPass>())
            {
                var matrix = Matrix.Identity;
                var matrixComponent = _node.Parent?.UntypedValue as IHasTransform;
                if (matrixComponent != null)
                {
                    matrix *= matrixComponent.FinalTransform.AbsoluteMatrix;
                }
                _renderUtilities.RenderPlane(renderContext, Effect.Effect, Effect.Effect.CreateParameterSet(), matrix, Color);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:18,代码来源:Render3DPlaneComponent.cs

示例11: RenderLine

        public void RenderLine(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Vector3 start, Vector3 end, TextureAsset texture, Vector2 startUV, Vector2 endUV)
        {
            if (!context.IsCurrentRenderPass<I3DRenderPass>())
            {
                throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context.");
            }

            var vertexes = _renderCache.GetOrSet(
                "renderlinetex3dvb:" + start + ":" + end + ":" + startUV + ":" + endUV,
                () =>
                {
                    var vb = new VertexBuffer(context.GraphicsDevice, VertexPositionTexture.VertexDeclaration, 2,
                        BufferUsage.WriteOnly);
                    vb.SetData(new[] { new VertexPositionTexture(start, startUV), new VertexPositionTexture(end, endUV) });
                    return vb;
                });
            var indicies = _renderCache.GetOrSet(
                "renderline3dib",
                () =>
                {
                    var ib = new IndexBuffer(context.GraphicsDevice, IndexElementSize.SixteenBits, 2,
                        BufferUsage.WriteOnly);
                    ib.SetData(new short[] { 0, 1 });
                    return ib;
                });

            context.GraphicsDevice.SetVertexBuffer(vertexes);
            context.GraphicsDevice.Indices = indicies;

            var semantic = effectParameterSet.GetSemantic<ITextureEffectSemantic>();
            if (semantic.Texture != texture.Texture)
            {
                semantic.Texture = texture.Texture;
            }

            effect.LoadParameterSet(context, effectParameterSet);
            foreach (var pass in effect.NativeEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                context.GraphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, 1);
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:43,代码来源:Default3DRenderUtilities.cs

示例12: Render

        public void Render(IGameContext gameContext, IRenderContext renderContext)
        {
            if (!this.DebugRender)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<I3DRenderPass>())
            {
                return;
            }

            this.m_2DRenderUtilities.RenderLine(renderContext, this.Start, this.End, DebugRenderWallColor);

            // Show normal.
            var diff = this.End - this.Start;
            var mid = this.Start + (diff / 2);

            this.m_2DRenderUtilities.RenderLine(renderContext, mid, mid + (this.Normal * 4), DebugRenderWallNormalColor);
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:20,代码来源:Wall.cs

示例13: Render

        public void Render(ComponentizedEntity entity, IGameContext gameContext, IRenderContext renderContext)
        {
            if (!Enabled)
            {
                return;
            }

            if (renderContext.IsCurrentRenderPass<I3DRenderPass>())
            {
                if (Effect == null)
                {
                    _useDefaultEffects = true;
                }
                else
                {
                    _useDefaultEffects = false;
                }

                if (_useDefaultEffects && _uberEffectAsset == null)
                {
                    _uberEffectAsset = _assetManager.Get<UberEffectAsset>("effect.BuiltinSurface");
                }

                if (Model != null)
                {
                    var matrix = FinalTransform.AbsoluteMatrix;
                    
                    bool changedRenderRequest = _lastWorldMatrix != matrix;
                    string changedRenderRequestBy = changedRenderRequest ? "matrix" : "";

                    var material = OverrideMaterial ?? _model.Material;

                    UpdateCachedModel(material, ref changedRenderRequest, ref changedRenderRequestBy);

                    var effect = GetEffect(ref changedRenderRequest, ref changedRenderRequestBy);

                    var parameterSet = GetEffectParameterSet(material, ref changedRenderRequest, ref changedRenderRequestBy);

                    var animation = GetModelAnimation(ref changedRenderRequest, ref changedRenderRequestBy);

                    if (animation != null)
                    {
                        animation.Apply(_model, _animationTracker.ElapsedMilliseconds / 1000f, 0.5f);

                        _renderRequest = _model.CreateRenderRequest(renderContext, effect, parameterSet, matrix);
                    }
                    else if (changedRenderRequest || _renderRequest == null)
                    {
                        _renderRequest = _model.CreateRenderRequest(renderContext, effect, parameterSet, matrix);
                    }

                    _lastWorldMatrix = matrix;

                    _renderBatcher.QueueRequest(
                        renderContext,
                        _renderRequest);
                }
                else
                {
                    _lastCachedModel = null;
                    _lastCachedDiffuseTexture = null;
                }
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:64,代码来源:Render3DModelComponent.cs

示例14: RenderCircle

        public void RenderCircle(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix transform, Vector2 center, int radius, Color color, bool filled = false)
        {
            if (!context.IsCurrentRenderPass<I3DRenderPass>())
            {
                throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context.");
            }

            var points = 8;

            double angle = MathHelper.TwoPi / points;

            var vertexesList = new List<VertexPositionColor>();
            var indicesList = new List<short>();

            vertexesList.Add(new VertexPositionColor(new Vector3(center, 0), color));

            for (int i = 1; i <= points; i++)
            {
                var pos = new Vector2(
                    (float)Math.Round(Math.Sin(angle * i), 4) * radius,
                    (float)Math.Round(Math.Cos(angle * i), 4) * radius);
                
                vertexesList.Add(new VertexPositionColor(new Vector3(center + pos, 0), color));
            }

            if (filled)
            {
                for (int i = 1; i < points; i++)
                {
                    indicesList.Add(0);
                    indicesList.Add((short)(i + 1));
                    indicesList.Add((short) i);
                }
                indicesList.Add(0);
                indicesList.Add(1);
                indicesList.Add((short) points);
            }
            else
            {
                for (int i = 1; i <= points; i++)
                {
                    indicesList.Add((short) i);
                }
                indicesList.Add(1);
            }

            var vertexes = vertexesList.ToArray();
            var indicies = indicesList.ToArray();

            var world = context.World;

            context.World = transform;

            effect.LoadParameterSet(context, effectParameterSet);
            foreach (var pass in effect.NativeEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                context.GraphicsDevice.DrawUserIndexedPrimitives(
                    filled ? PrimitiveType.TriangleList : PrimitiveType.LineStrip,
                    vertexes,
                    0,
                    vertexes.Length,
                    indicies,
                    0,
                    indicies.Length / 3);
            }

            context.World = world;
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:70,代码来源:Default3DRenderUtilities.cs

示例15: RenderPlane

        public void RenderPlane(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix transform, TextureAsset texture, Vector2 topLeftUV, Vector2 bottomRightUV)
        {
            if (!context.IsCurrentRenderPass<I3DRenderPass>())
            {
                throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context.");
            }

            var vertexes = new[]
            {
                new VertexPositionNormalTexture(new Vector3(0, 0, 0), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(0, 0, 1), new Vector3(0, -1, 0), new Vector2(topLeftUV.X, bottomRightUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 0), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, topLeftUV.Y)),
                new VertexPositionNormalTexture(new Vector3(1, 0, 1), new Vector3(0, -1, 0), new Vector2(bottomRightUV.X, bottomRightUV.Y))
            };

            var indicies = new short[]
            {
                0, 2, 1,
                3, 1, 2
            };

            var semantic = effectParameterSet.GetSemantic<ITextureEffectSemantic>();
            if (semantic.Texture != texture.Texture)
            {
                semantic.Texture = texture.Texture;
            }

            var world = context.World;

            context.World = transform;

            effect.LoadParameterSet(context, effectParameterSet);
            foreach (var pass in effect.NativeEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                context.GraphicsDevice.DrawUserIndexedPrimitives(
                    PrimitiveType.TriangleList,
                    vertexes,
                    0,
                    vertexes.Length,
                    indicies,
                    0,
                    indicies.Length / 3);
            }

            context.World = world;
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:48,代码来源:Default3DRenderUtilities.cs


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