當前位置: 首頁>>代碼示例>>C#>>正文


C# WorldRenderer.ScreenZPosition方法代碼示例

本文整理匯總了C#中OpenRA.Graphics.WorldRenderer.ScreenZPosition方法的典型用法代碼示例。如果您正苦於以下問題:C# WorldRenderer.ScreenZPosition方法的具體用法?C# WorldRenderer.ScreenZPosition怎麽用?C# WorldRenderer.ScreenZPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenRA.Graphics.WorldRenderer的用法示例。


在下文中一共展示了WorldRenderer.ScreenZPosition方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Render

		public void Render(WorldRenderer wr)
		{
			var pxOrigin = wr.ScreenPosition(pos);
			var groundZ = 0.5f*(pxOrigin.Y - wr.ScreenZPosition(pos, 0));
			var shadowOrigin = pxOrigin - groundZ*(new float2(renderProxy.ShadowDirection, 1));

			var psb = renderProxy.ProjectedShadowBounds;
			var sa = shadowOrigin + psb[0];
			var sb = shadowOrigin + psb[2];
			var sc = shadowOrigin + psb[1];
			var sd = shadowOrigin + psb[3];
			Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.ShadowSprite, sa, sb, sc, sd);
			Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.Sprite, pxOrigin - 0.5f*renderProxy.Sprite.size);
		}
開發者ID:Berzeger,項目名稱:OpenRA,代碼行數:14,代碼來源:VoxelRenderable.cs

示例2: 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);
				}
			}
開發者ID:Roger-luo,項目名稱:OpenRA,代碼行數:36,代碼來源:VoxelRenderable.cs

示例3: ScreenPosition

        float3 ScreenPosition(WorldRenderer wr)
        {
            var xy = wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.Size.XY).ToInt2();

            // HACK: The z offset needs to be applied somewhere, but this probably is the wrong place.
            return new float3(xy, sprite.Offset.Z + wr.ScreenZPosition(pos, 0) - 0.5f * scale * sprite.Size.Z);
        }
開發者ID:pchote,項目名稱:OpenRA,代碼行數:7,代碼來源:SpriteRenderable.cs


注:本文中的OpenRA.Graphics.WorldRenderer.ScreenZPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。