コード例 #1
0
    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);
    }