2021-01-18 12:33:07 +00:00
|
|
|
|
using UnityEngine;
|
2021-01-05 15:56:14 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
namespace Popcron
|
2021-01-05 15:56:14 +00:00
|
|
|
|
{
|
2022-02-27 12:40:44 +00:00
|
|
|
|
internal class FrustumDrawer : Drawer
|
2021-01-05 15:56:14 +00:00
|
|
|
|
{
|
2022-02-27 12:40:44 +00:00
|
|
|
|
public FrustumDrawer()
|
|
|
|
|
{
|
2021-01-05 15:56:14 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2021-01-05 15:56:14 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
public override int Draw(ref Vector3[] buffer, params object[] values)
|
|
|
|
|
{
|
|
|
|
|
var camera = (OWCamera)values[0];
|
2021-01-05 15:56:14 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
//bottom left
|
|
|
|
|
buffer[0] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.nearClipPlane));
|
|
|
|
|
buffer[1] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane / 2));
|
|
|
|
|
//bottom right
|
|
|
|
|
buffer[2] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.nearClipPlane));
|
|
|
|
|
buffer[3] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane / 2));
|
|
|
|
|
//top left
|
|
|
|
|
buffer[4] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.nearClipPlane));
|
|
|
|
|
buffer[5] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
//top right
|
|
|
|
|
buffer[6] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.nearClipPlane));
|
|
|
|
|
buffer[7] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
//bottom left to bottom right
|
|
|
|
|
buffer[8] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane / 2));
|
|
|
|
|
buffer[9] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane / 2));
|
|
|
|
|
//bottom right to top right
|
|
|
|
|
buffer[10] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, 0, camera.farClipPlane / 2));
|
|
|
|
|
buffer[11] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
//top right to top left
|
|
|
|
|
buffer[12] = camera.ScreenToWorldPoint(new Vector3(camera.pixelWidth, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
buffer[13] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
//top left to bottom left
|
|
|
|
|
buffer[14] = camera.ScreenToWorldPoint(new Vector3(0, camera.pixelHeight, camera.farClipPlane / 2));
|
|
|
|
|
buffer[15] = camera.ScreenToWorldPoint(new Vector3(0, 0, camera.farClipPlane / 2));
|
|
|
|
|
return 16;
|
|
|
|
|
}
|
2021-01-05 15:56:14 +00:00
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|