本文整理汇总了C#中Bounds.ToPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Bounds.ToPoints方法的具体用法?C# Bounds.ToPoints怎么用?C# Bounds.ToPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds
的用法示例。
在下文中一共展示了Bounds.ToPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawObjectSelectionBorder
private void DrawObjectSelectionBorder(Bounds bounds)
{
Camera camera = RendererWorld.Instance.DefaultCamera;
GuiRenderer renderer = EngineApp.Instance.ScreenGuiRenderer;
Texture texture = TextureManager.Instance.Load("Gui\\Textures\\ObjectSelectionBorder.png");
Vec2 viewportSize = renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();
float sizeY = .08f;
Vec2 size = SnapToPixel(new Vec2(sizeY / camera.AspectRatio, sizeY), viewportSize);
float alpha = MathFunctions.Sin(Time * MathFunctions.PI) * .5f + .5f;
Rect screenRectangle = Rect.Cleared;
{
Vec3[] points = null;
bounds.ToPoints(ref points);
foreach (Vec3 point in points)
{
Vec2 screenPoint;
if (camera.ProjectToScreenCoordinates(point, out screenPoint))
{
screenPoint.Clamp(new Vec2(0, 0), new Vec2(1, 1));
screenRectangle.Add(screenPoint);
}
}
Vec2[] screenPositions = new Vec2[] {
new Vec2( 0, 0 ),
new Vec2( 1, 0 ),
new Vec2( 0, 1 ),
new Vec2( 1, 1 ) };
foreach (Vec2 screenPosition in screenPositions)
{
Ray ray = camera.GetCameraToViewportRay(screenPosition);
if (bounds.RayIntersection(ray))
screenRectangle.Add(screenPosition);
}
if (screenRectangle.GetSize().X < size.X * 2)
{
screenRectangle = new Rect(
screenRectangle.GetCenter().X - size.X, screenRectangle.Top,
screenRectangle.GetCenter().X + size.X, screenRectangle.Bottom);
}
if (screenRectangle.GetSize().Y < size.Y * 2)
{
screenRectangle = new Rect(
screenRectangle.Left, screenRectangle.GetCenter().Y - size.Y,
screenRectangle.Right, screenRectangle.GetCenter().Y + size.Y);
}
}
{
Vec2 point = screenRectangle.LeftTop;
point = SnapToPixel(point, viewportSize) + new Vec2(.25f, .25f) / viewportSize;
Rect rectangle = new Rect(point, point + size);
Rect texCoord = new Rect(0, 0, .5f, .5f);
renderer.AddQuad(rectangle, texCoord, texture, new ColorValue(1, 1, 1, alpha), true);
}
{
Vec2 point = screenRectangle.RightTop;
point = SnapToPixel(point, viewportSize) + new Vec2(.25f, .25f) / viewportSize;
Rect rectangle = new Rect(point - new Vec2(size.X, 0), point + new Vec2(0, size.Y));
Rect texCoord = new Rect(.5f, 0, 1, .5f);
renderer.AddQuad(rectangle, texCoord, texture, new ColorValue(1, 1, 1, alpha), true);
}
{
Vec2 point = screenRectangle.LeftBottom;
point = SnapToPixel(point, viewportSize) + new Vec2(.25f, .25f) / viewportSize;
Rect rectangle = new Rect(point - new Vec2(0, size.Y), point + new Vec2(size.X, 0));
Rect texCoord = new Rect(0, .5f, .5f, 1);
renderer.AddQuad(rectangle, texCoord, texture, new ColorValue(1, 1, 1, alpha), true);
}
{
Vec2 point = screenRectangle.RightBottom;
point = SnapToPixel(point, viewportSize) + new Vec2(.25f, .25f) / viewportSize;
Rect rectangle = new Rect(point - size, point);
Rect texCoord = new Rect(.5f, .5f, 1, 1);
renderer.AddQuad(rectangle, texCoord, texture, new ColorValue(1, 1, 1, alpha), true);
}
}