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


C# RenderContext.GetCurrentCamera方法代码示例

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


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

示例1: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            var cameraState = context.GetCurrentCamera();

            if (cameraState == null)
                return;

            UpdateParameters(context, cameraState);
        }
开发者ID:RainsSoft,项目名称:paradox,代码行数:9,代码来源:CameraComponentRenderer.cs

示例2: ComputeScreenCoverage

 public float ComputeScreenCoverage(RenderContext context, Vector3 position, Vector3 direction)
 {
     var viewport = context.GraphicsDevice.Viewport;
     var camera = context.GetCurrentCamera();
     if (camera == null)
     {
         return 0.0f;
     }
     return ComputeScreenCoverage(camera, position, direction, viewport.Width, viewport.Height);
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:10,代码来源:DirectLightBase.cs

示例3: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            // If no camera, early exit
            var camera = context.GetCurrentCamera();
            if (camera == null)
            {
                return;
            }

            // Copy the ViewProjectionMatrix from the camera as it is not automatically picked up by the ModelComponentRenderer
            modelRenderer.ViewProjectionMatrix = camera.ViewProjectionMatrix;
            var sceneCameraRenderer = context.Tags.Get(SceneCameraRenderer.Current);
            var cameraRenderMode = sceneCameraRenderer != null ? sceneCameraRenderer.Mode : null;

            if (cameraRenderMode != null)
            {
                modelRenderer.RasterizerState = cameraRenderMode.GetDefaultRasterizerState(false);
                modelRenderer.RasterizerStateForInvertedGeometry = cameraRenderMode.GetDefaultRasterizerState(true);
            }                   

            modelRenderer.Prepare(context, opaqueList, transparentList);
        }
开发者ID:releed,项目名称:paradox,代码行数:22,代码来源:ModelComponentAndPickingRenderer.cs

示例4: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            spriteProcessor = SceneInstance.GetProcessor<SpriteProcessor>();
            if (spriteProcessor == null)
            {
                return;
            }

            // If no camera, early exit
            var camera = context.GetCurrentCamera();
            if (camera == null)
            {
                return;
            }
            var viewProjectionMatrix = camera.ViewProjectionMatrix;

            foreach (var spriteState in spriteProcessor.Sprites)
            {
                var sprite = spriteState.SpriteComponent.CurrentSprite;
                if(sprite == null)
                    continue;

                // Perform culling on group and accept
                if (!CurrentCullingMask.Contains(spriteState.SpriteComponent.Entity.Group))
                    continue;

                // Project the position
                // TODO: This could be done in a SIMD batch, but we need to figure-out how to plugin in with RenderMesh object
                var worldPosition = new Vector4(spriteState.TransformComponent.WorldMatrix.TranslationVector, 1.0f);

                Vector4 projectedPosition;
                Vector4.Transform(ref worldPosition, ref viewProjectionMatrix, out projectedPosition);
                var projectedZ = projectedPosition.Z / projectedPosition.W;

                var list = sprite.IsTransparent ? transparentList : opaqueList;

                list.Add(new RenderItem(this, spriteState, projectedZ));
            }
        }
开发者ID:ItayGal2,项目名称:paradox,代码行数:39,代码来源:SpriteComponentRenderer.cs

示例5: PrepareCore

        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)
        {
            spriteProcessor = SceneInstance.GetProcessor<SpriteStudioProcessor>();
            if (spriteProcessor == null)
            {
                return;
            }

            // If no camera, early exit
            var camera = context.GetCurrentCamera();
            if (camera == null)
            {
                return;
            }
            var viewProjectionMatrix = camera.ViewProjectionMatrix;

            foreach (var spriteState in spriteProcessor.Sprites)
            {
                var worldMatrix = spriteState.TransformComponent.WorldMatrix;

                var worldPosition = new Vector4(worldMatrix.TranslationVector, 1.0f);

                Vector4 projectedPosition;
                Vector4.Transform(ref worldPosition, ref viewProjectionMatrix, out projectedPosition);
                var projectedZ = projectedPosition.Z / projectedPosition.W;

                transparentList.Add(new RenderItem(this, spriteState, projectedZ));

                //for (var index = 0; index < ssSheet.Sheet.NodesInfo.Count; index++)
                //{
                //    var node = ssSheet.Sheet.NodesInfo[index];
                //    var sprite = ssSheet.Sheet.SpriteSheet.Sprites[index];

                //    if (sprite?.Texture == null || sprite.Region.Width <= 0 || sprite.Region.Height <= 0f)
                //        continue;

                //    // Perform culling on group and accept
                //    if (!CurrentCullingMask.Contains(spriteState.SpriteStudioComponent.Entity.Group))
                //        continue;

                //    var worldMatrix = node.WorldTransform * spriteState.TransformComponent.WorldMatrix;

                //    // Project the position
                //    // TODO: This could be done in a SIMD batch, but we need to figure-out how to plugin in with RenderMesh object
                //    var worldPosition = new Vector4(worldMatrix.TranslationVector, 1.0f);

                //    Vector4 projectedPosition;
                //    Vector4.Transform(ref worldPosition, ref viewProjectionMatrix, out projectedPosition);
                //    var projectedZ = projectedPosition.Z / projectedPosition.W;

                //    var list = sprite.IsTransparent ? transparentList : opaqueList;

                //    list.Add(new RenderItem(this, new SpriteItem
                //    {
                //        Sprite = sprite,
                //        Data = spriteState,
                //        Node = node
                //    }, projectedZ));
                //}
            }
        }
开发者ID:RainsSoft,项目名称:paradox,代码行数:61,代码来源:SpriteStudioRenderer.cs


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