Exemplo n.º 1
0
    public void OnSetup(PointCloudController pcx)
    {
        bounds = pcx.WorldBounds;

        var up = Vector3.up;
        var ul = Mathf.Max(1e2f * 5f, Mathf.Abs(Vector3.Dot(bounds.size, up)));

        var directions = new Vector3[]
        {
            Vector3.left, Vector3.forward, Vector3.right, Vector3.back
        };

        foreach (var dir in directions)
        {
            var wall = Instantiate(prefab);
            wall.transform.SetParent(transform);

            var r  = Vector3.Cross(dir, up).normalized;
            var dl = padding + Mathf.Abs(Vector3.Dot(dir, bounds.size));
            var rl = padding + Mathf.Abs(Vector3.Dot(r, bounds.size));

            var size   = up * ul + r * rl;
            var center = Vector3.ProjectOnPlane(bounds.center, up) + dir * dl * 0.5f + up * ul * 0.5f;

            wall.Texture              = Texture;
            wall.transform.position   = center;
            wall.transform.localScale = new Vector3(rl, ul, 1f);
            wall.transform.rotation   = Quaternion.LookRotation(dir, up);

            walls.Add(wall);
        }

        // build top
        {
            var wall = Instantiate(prefab);
            wall.transform.SetParent(transform);

            Vector3 f = Vector3.forward, r = Vector3.right;
            var     dl = padding + Mathf.Abs(Vector3.Dot(f, bounds.size));
            var     rl = padding + Mathf.Abs(Vector3.Dot(r, bounds.size));

            var size   = f * dl + r * rl;
            var center = Vector3.ProjectOnPlane(bounds.center, up) + up * ul;

            wall.Texture              = Texture;
            wall.transform.position   = center;
            wall.transform.localScale = new Vector3(Mathf.Abs(rl), Mathf.Abs(dl), 1f);
            wall.transform.rotation   = Quaternion.LookRotation(up);

            walls.Add(wall);
        }
    }
Exemplo n.º 2
0
    public void OnSetup(PointCloudController controller)
    {
        var bounds = controller.WorldBounds;
        var min    = bounds.min;
        var max    = bounds.max;
        var center = bounds.center;

        transform.position = new Vector3(center.x, transform.position.y, center.z);
        var scale = transform.localRotation * (bounds.size + Vector3.one * padding);

        scale.x = Mathf.Abs(scale.x);
        scale.y = Mathf.Abs(scale.y);
        scale.z = 1.0f;
        transform.localScale = scale;
    }
Exemplo n.º 3
0
 public void OnSetup(PointCloudController pcx)
 {
     worldBounds = pcx.WorldBounds;
 }