Example #1
0
    // Update is called once per frame
    void Update()
    {
        //Vector3 screenPos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10);
        //Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
        //Debug.Log($"sp : {screenPos}");
        //Debug.Log($"wp : {worldPos}");

        if (this.vineScene != null)
        {
            try
            {
                // turn vine into our scene of interest
                renderScene(vineScene);

                ProtoHello hi         = new ProtoHello();
                var        screenSize = this.vineScene.ImgSize;

                hi.ProtoMessage = $"delayed screen stuff {screenSize[0]}, {screenSize[1]}";

                this.promised.Resolve(new ProtoMessage(hi));
            }
            catch (Exception ex)
            {
                this.promised.Reject(ex);
            }

            this.promised  = null;
            this.vineScene = null;
        }
    }
Example #2
0
    public Promise <ProtoMessage> RenderVines(PCGVineView vines)
    {
        var promise = new Promise <ProtoMessage>();

        vineScene     = vines;
        this.promised = promise;

        return(promise);
    }
Example #3
0
    void renderScene(PCGVineView scene)
    {
        var screenSize = this.vineScene.ImgSize;

        Screen.SetResolution(screenSize[0], screenSize[1], false);
        Debug.Log($"Changed resolution : { Screen.width}, { Screen.height}");


        clearScene();
        Debug.Log($"Rendering : {scene.Vines.Count} objects");


        var bottomLeft = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 10));                        //Camera.main.nearClipPlane));
        var topRight   = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 10)); //Camera.main.nearClipPlane));

        // here are the actual screen widths in real points
        var swidth  = Mathf.Abs(topRight.x - bottomLeft.x);
        var sheight = Mathf.Abs(topRight.y - bottomLeft.y);

        var widthHeight    = new Vector2(swidth, sheight);
        var screenPosition = bottomLeft;

        //float vwidth = scene.Viewport.Xmax - scene.Viewport.Xmin;
        //float vheight = scene.Viewport.Ymax - scene.Viewport.Ymin;
        //var scale = new Vector2(swidth / vwidth, sheight / vheight);

        //// therefore we have a ratio between the size of the screen
        //// and the viewport
        //// I also think 0,0 is the center of the screen
        //var startPoint = new Vector3(bottomLeft.x + swidth / 2 + scene.Viewport.Xmin*scale.x,
        //bottomLeft.y + sheight / 2 + scene.Viewport.Ymin*scale.y,
        //bottomLeft.z);


        //Debug.Log($"start point {startPoint}");

        // sort by N (depth), and render
        foreach (var pcgObj in scene.Vines.OrderBy(x => x.N))
        {
            Debug.Log($"Render individual: {pcgObj.Type}");
            screenPosition = renderPCGObject(pcgObj, screenPosition, widthHeight);
        }
    }