本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
}
示例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));
//}
}
}