本文整理匯總了C#中SiliconStudio.Xenko.Rendering.RenderContext.GetCurrentCamera方法的典型用法代碼示例。如果您正苦於以下問題:C# RenderContext.GetCurrentCamera方法的具體用法?C# RenderContext.GetCurrentCamera怎麽用?C# RenderContext.GetCurrentCamera使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SiliconStudio.Xenko.Rendering.RenderContext
的用法示例。
在下文中一共展示了RenderContext.GetCurrentCamera方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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 || sprite.Texture == null || sprite.Region.Width <= 0 || sprite.Region.Height <= 0f)
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));
}
}
示例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<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));
//}
}
}