public Face2D Build(CameraScene cameraScene, CirclePrimitive player, CirclePrimitive target) { // 3 steps: // 1. Make face from room bounds // 2. For each primitive make the occlusion field and cut it from the face // 3. Cut middle zone from the face, in this zone both the player and the target are visible, // but there aren't any camera angle to see them both Face2D res = MakeStartField(cameraScene.RoomBound); BooleanOperator bop = new BooleanOperator(); foreach (var circle_obstacle in cameraScene.Circles) { res = bop.Intersect(res, MakeOcclusionLoop(player, circle_obstacle, -0.1f)); } res = bop.Intersect(res, MakeOcclusionLoop(player, target, 0.0f)); foreach (var circle_obstacle in cameraScene.Circles) { res = bop.Intersect(res, MakeOcclusionLoop(target, circle_obstacle, 0.1f)); } res = bop.Intersect(res, MakeMiddleZone(player, target)); return(res); }
private void InitScene() { Cube = new Cube(); Grid.SetRow(Cube.GetViewport3D(), 1); Grid.SetColumn(Cube.GetViewport3D(), 1); SchemaGrid.Children.Add(Cube.GetViewport3D()); Camera = new CameraScene(); Cube.GetViewport3D().Camera = Camera.GetPerspectiveCamera(); }
// Use this for initialization void Start() { List <BoxPrimitive> boxes = new List <BoxPrimitive>(scene_geometry_parent.childCount); List <CirclePrimitive> circles = new List <CirclePrimitive>(scene_geometry_parent.childCount); NullableBox room_bounds = null; for (int i = 0; i < scene_geometry_parent.childCount; ++i) { GameObject child = scene_geometry_parent.GetChild(i).gameObject; BoxCollider box = child.GetComponent <BoxCollider>(); CapsuleCollider capsule = child.GetComponent <CapsuleCollider>(); if (child.name.Equals("room_bounds")) { Assert.IsNotNull(box, "room_bounds does not have box collider attached to it!"); room_bounds = new NullableBox(); room_bounds.box = CreatePrimitive(child.transform, box); } else if (!child.name.Equals("floor")) { if (box != null) { boxes.Add(CreatePrimitive(child.transform, box)); } else if (capsule != null) { circles.Add(CreatePrimitive(child.transform, capsule)); } } } Assert.IsNotNull(room_bounds, "No room_bounds object in hierarchy!"); m_scene = new CameraScene(circles, boxes, room_bounds.box); }