本文整理汇总了C#中OpenRA.Graphics.WorldRenderer.ScreenVectorComponents方法的典型用法代码示例。如果您正苦于以下问题:C# WorldRenderer.ScreenVectorComponents方法的具体用法?C# WorldRenderer.ScreenVectorComponents怎么用?C# WorldRenderer.ScreenVectorComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Graphics.WorldRenderer
的用法示例。
在下文中一共展示了WorldRenderer.ScreenVectorComponents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderDebugGeometry
public void RenderDebugGeometry(WorldRenderer wr)
{
var pxOrigin = wr.ScreenPosition(voxel.pos);
var groundZ = 0.5f * (pxOrigin.Y - wr.ScreenZPosition(voxel.pos, 0));
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
// Draw sprite rect
var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size;
Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.Size, Color.Red);
// Draw transformed shadow sprite rect
var c = Color.Purple;
var psb = renderProxy.ProjectedShadowBounds;
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[1], shadowOrigin + psb[3], c);
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[3], shadowOrigin + psb[0], c);
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[0], shadowOrigin + psb[2], c);
Game.Renderer.WorldLineRenderer.DrawLine(shadowOrigin + psb[2], shadowOrigin + psb[1], c);
// Draw voxel bounding box
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
var scaleTransform = Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
var cameraTransform = Util.MakeFloatMatrix(voxel.camera.AsMatrix());
foreach (var v in draw)
{
var bounds = v.Voxel.Bounds(v.FrameFunc());
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
(x, y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix())));
float sx, sy, sz;
wr.ScreenVectorComponents(v.OffsetFunc(), out sx, out sy, out sz);
var pxPos = pxOrigin + new float2(sx, sy);
var screenTransform = Util.MatrixMultiply(cameraTransform, worldTransform);
DrawBoundsBox(pxPos, screenTransform, bounds, Color.Yellow);
}
}
示例2: ScreenBounds
public Rectangle ScreenBounds(WorldRenderer wr)
{
var pxOrigin = wr.ScreenPosition(voxel.pos);
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
var scaleTransform = Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
var cameraTransform = Util.MakeFloatMatrix(voxel.camera.AsMatrix());
var minX = float.MaxValue;
var minY = float.MaxValue;
var maxX = float.MinValue;
var maxY = float.MinValue;
foreach (var v in draw)
{
var bounds = v.Voxel.Bounds(v.FrameFunc());
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
(x, y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix())));
float sx, sy, sz;
wr.ScreenVectorComponents(v.OffsetFunc(), out sx, out sy, out sz);
var pxPos = pxOrigin + new float2(sx, sy);
var screenTransform = Util.MatrixMultiply(cameraTransform, worldTransform);
for (var i = 0; i < 8; i++)
{
var vec = new float[] { bounds[CornerXIndex[i]], bounds[CornerYIndex[i]], bounds[CornerZIndex[i]], 1 };
var screen = Util.MatrixVectorMultiply(screenTransform, vec);
minX = Math.Min(minX, pxPos.X + screen[0]);
minY = Math.Min(minY, pxPos.Y + screen[1]);
maxX = Math.Max(maxX, pxPos.X + screen[0]);
maxY = Math.Max(maxY, pxPos.Y + screen[1]);
}
}
return Rectangle.FromLTRB((int)minX, (int)minY, (int)maxX, (int)maxY);
}
示例3: RenderDebugGeometry
public void RenderDebugGeometry(WorldRenderer wr)
{
var groundPos = voxel.pos - new WVec(0, 0, wr.World.Map.DistanceAboveTerrain(voxel.pos).Length);
var groundZ = wr.World.Map.Grid.TileSize.Height * (groundPos.Z - voxel.pos.Z) / 1024f;
var pxOrigin = wr.Screen3DPosition(voxel.pos);
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
var iz = 1 / wr.Viewport.Zoom;
// Draw sprite rect
var offset = pxOrigin + renderProxy.Sprite.Offset - 0.5f * renderProxy.Sprite.Size;
Game.Renderer.WorldRgbaColorRenderer.DrawRect(offset.XY, (offset + renderProxy.Sprite.Size).XY, iz, Color.Red);
// Draw transformed shadow sprite rect
var c = Color.Purple;
var psb = renderProxy.ProjectedShadowBounds;
Game.Renderer.WorldRgbaColorRenderer.DrawPolygon(new[]
{
shadowOrigin + psb[1],
shadowOrigin + psb[3],
shadowOrigin + psb[0],
shadowOrigin + psb[2]
}, iz, c);
// Draw voxel bounding box
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
var scaleTransform = OpenRA.Graphics.Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
var cameraTransform = OpenRA.Graphics.Util.MakeFloatMatrix(voxel.camera.AsMatrix());
foreach (var v in draw)
{
var bounds = v.Voxel.Bounds(v.FrameFunc());
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
var pxPos = pxOrigin + wr.ScreenVectorComponents(v.OffsetFunc());
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
DrawBoundsBox(pxPos, screenTransform, bounds, iz, Color.Yellow);
}
}