Exemple #1
0
    public override void CreateMesh(EyeName eye)
    {
        Eye = eye;
        MeshRenderer mr = GetComponent <MeshRenderer> ();

        if (mr == null)
        {
            _internalCreateMesh(eye);
        }
        else
        {
            CameraPostRenderer r = DisplayCamera.GetComponent <CameraPostRenderer>();
            if (r == null)
            {
                r = DisplayCamera.gameObject.AddComponent <CameraPostRenderer>();
            }
            r.AddRenderer(this);
            _RenderPlane = gameObject;
            mr.material  = Mat;
        }

        /*if (eye == EyeName.LeftEye)
         *      _RenderPlane.transform.localPosition = new Vector3 (-0.03f, 0, 0);
         * else
         *      _RenderPlane.transform.localPosition = new Vector3 (0.03f, 0, 0);*/
    }
Exemple #2
0
    public override void CreateMesh(EyeName eye)
    {
        Eye = eye;

        CameraPostRenderer r = DisplayCamera.GetComponent <CameraPostRenderer>();

        if (r == null)
        {
            r = DisplayCamera.gameObject.AddComponent <CameraPostRenderer>();
        }
        r.AddRenderer(this);
        _RenderPlane = gameObject;

        Receiver.OnFrameBlitted += OnImageArrived;
    }
Exemple #3
0
    public override void CreateMesh(EyeName eye)
    {
        Eye            = eye;
        Image.material = Mat;

        CameraPostRenderer r = DisplayCamera.GetComponent <CameraPostRenderer>();

        if (r == null)
        {
            r = DisplayCamera.gameObject.AddComponent <CameraPostRenderer>();
        }
        r.AddRenderer(this);
        _RenderPlane = gameObject;
        Enable();
    }
    public override void CreateMesh(EyeName eye)
    {
        Eye = eye;
        MeshRenderer mr = GetComponent <MeshRenderer> ();

        if (mr == null)
        {
            _internalCreateMesh(eye);
        }
        else
        {
            CameraPostRenderer r = DisplayCamera.GetComponent <CameraPostRenderer>();
            if (r == null)
            {
                r = DisplayCamera.gameObject.AddComponent <CameraPostRenderer>();
            }
            r.AddRenderer(this);
            _RenderPlane = gameObject;
            mr.material  = Mat;
        }
    }
    public override void CreateMesh(EyeName eye)
    {
        Eye = eye;
        MeshRenderer mr = GetComponent <MeshRenderer> ();

        if (mr == null)
        {
            mr = _internalCreateMesh(eye);
        }

        if (mr != null)
        {
            mr.material = Mat;
        }

        _postRenderer = DisplayCamera.GetComponent <CameraPostRenderer>();
        if (_postRenderer == null)
        {
            _postRenderer = DisplayCamera.gameObject.AddComponent <CameraPostRenderer>();
        }
        _postRenderer.AddRenderer(this);
        Enable();
    }
Exemple #6
0
    void _InitCameraRenderers()
    {
        if (_camsInited)
        {
            return;
        }
        Debug.Log("Creating Renderers");
        EyeName[] eyes = new EyeName[] { EyeName.LeftEye, EyeName.RightEye };
        //TelubeeCameraRenderer[] Targets = new TelubeeCameraRenderer[]{TargetEyeRight,TargetEyeLeft};
        ICameraRenderMesh[] Targets = new ICameraRenderMesh[] { TargetEyeLeft, TargetEyeRight };

        float[] camsOffset = new float[] { -0.03f, 0.03f };
        //	if (OculusCamera != null)
        {
            Camera mainCam;

            Camera[]    cams    = new Camera[2];
            Transform[] Anchors = new Transform[2];
            if (OculusCamera != null)
            {
                cams [0]    = OculusCamera.leftEyeAnchor.GetComponent <Camera>();
                cams [1]    = OculusCamera.rightEyeAnchor.GetComponent <Camera>();
                mainCam     = OculusCamera.centerEyeAnchor.GetComponent <Camera> ();
                Anchors [0] = OculusCamera.centerEyeAnchor;
                Anchors [1] = OculusCamera.centerEyeAnchor;

                cams [0].cullingMask = (cams [0].cullingMask & ~(1 << LayerMask.NameToLayer("RightEye"))) | 1 << LayerMask.NameToLayer("LeftEye");
                cams [1].cullingMask = (cams [1].cullingMask & ~(1 << LayerMask.NameToLayer("LeftEye"))) | 1 << LayerMask.NameToLayer("RightEye");
            }
            else
            {
                cams [0] = Camera.main;
                cams [1] = Camera.main;
                mainCam  = Camera.main;

                Anchors [0] = Camera.main.transform;
                Anchors [1] = Camera.main.transform;
            }


            //_postRenderer=mainCam.GetComponent<CameraPostRenderer>();
            if (_postRenderer == null)
            {
                _postRenderer = mainCam.gameObject.AddComponent <CameraPostRenderer>();
            }
            _postRenderer.AddRenderer(this);

            //	Vector2[] pixelShift = new Vector2[] { output.Configuration.PixelShiftRight,output.Configuration.PixelShiftLeft};
            for (int i = 0; i < cams.Length; ++i)
            {
                //int i = (int)eyes[c];
                cams[i].backgroundColor = new Color(cams[i].backgroundColor.r, cams[i].backgroundColor.g, cams[i].backgroundColor.b, 1);


                //	CreateMesh ((EyeName)i);
                //	RicohThetaRenderMesh r = Targets[i] as RicohThetaRenderMesh;
                ICameraRenderMesh r = null;

                //Check camera type used.
                if (Output.Configuration.CameraType == CameraConfigurations.ECameraType.WebCamera)
                {
                    //Create A webcamera type renderer
                    r = Targets[i];
                    if (r == null)
                    {
                        if (Output.Configuration.streamCodec == CameraConfigurations.EStreamCodec.Ovrvision)
                        {
                            r = cams [i].gameObject.AddComponent <OVRVisionRenderMesh> ();
                        }
                        //	else if(Output.Configuration.streamCodec==CameraConfigurations.EStreamCodec.EyegazeRaw)
                        //		r = cams [i].gameObject.AddComponent<EyegazeWebcameraRenderMesh> ();//Eyegaze
                        else
                        {
                            r = cams [i].gameObject.AddComponent <WebcameraRenderMesh> ();
                        }
                    }
                }
                else
                {
                    r = Targets[i];
                    if (r == null)
                    {
                        r = cams [i].gameObject.AddComponent <RicohThetaRenderMesh> ();
                    }
                }
                r.Mat           = Object.Instantiate(TargetMaterial);
                r.DisplayCamera = cams[i];
                r.Src           = this;

                //r.CreateMesh(eyes[c]);
                r.CreateMesh(eyes[i]);

                _camRenderer[i] = r;

                if (eyes[i] == EyeName.RightEye)
                {
                    r._RenderPlane.layer = LayerMask.NameToLayer("RightEye");
                }
                else
                {
                    r._RenderPlane.layer = LayerMask.NameToLayer("LeftEye");
                }
                if (Targets[i] == null)
                {
                    _camRendererParents [i] = new GameObject(this.name + "_" + eyes[i].ToString());
                    //_camRendererParents[i].transform.parent=Anchors[i].transform;
                    _camRendererParents[i].transform.localRotation = Quaternion.Euler(Output.Configuration.OffsetAngle);
                    _camRendererParents[i].transform.position      = Anchors[i].transform.position;             //Vector3.zero;
                    var attachment = _camRendererParents[i].AddComponent <CameraTransformAttachment>();
                    attachment.attachedAnchor = Anchors [i].transform;

                    _camRendererParents [i].transform.parent = transform;

                    attachment.renderer = this;

                    r._RenderPlane.transform.parent        = _camRendererParents[i].transform;
                    r._RenderPlane.transform.localRotation = Quaternion.identity;
                    r._RenderPlane.transform.localPosition = new Vector3(camsOffset[i], 0, 0);


                    r.transform.localRotation = Quaternion.identity;
                    r.transform.localPosition = Vector3.zero;
                }
            }
        }

        //	_camRenderer[0].CreateMesh(EyeName.LeftEye);
        //	_camRenderer[1].CreateMesh(EyeName.RightEye);

        if (OnCameraRendererCreated != null)
        {
            OnCameraRendererCreated(this, _camRenderer);
        }

        _camsInited = true;
    }