コード例 #1
0
    public void init()
    {
        wvr.distortion.Distortion obj = new wvr.distortion.Distortion();
        Cleft              = new wvr.distortion.Config();
        Cleft.eye          = true;
        Cleft.rect         = new Rect(0, 0, 0.5f, 1);
        Cleft.expandRatio  = 1;
        Cleft.center       = GetCenter(WVR_Eye.WVR_Eye_Left);
        Cleft.mesh         = obj.createMesh(Cleft);
        Cleft.mesh.name    = "left_eye_distortion";
        Cright             = new wvr.distortion.Config();
        Cright.eye         = false;
        Cright.rect        = new Rect(0.5f, 0, 0.5f, 1);
        Cright.expandRatio = 1;
        Cright.center      = GetCenter(WVR_Eye.WVR_Eye_Right);
        Cright.mesh        = obj.createMesh(Cright);
        Cright.mesh.name   = "right_eye_distortion";

        Shader shader = Resources.Load <Shader>("WaveVR_Distortion");

        if (shader == null)
        {
            Debug.LogError("Can't find WaveVR/Distortion shader");
        }
        var material = new Material(shader);

        Cleft.material  = material;
        Cright.material = material;

        cam = GetComponent <Camera>();
        cam.orthographic     = true;
        cam.orthographicSize = 1;
        cam.cullingMask      = 0;
        cam.backgroundColor  = Color.black;
        cam.projectionMatrix = Matrix4x4.identity;
        cam.enabled          = false;

        current = Cright;

        FlatMesh          = new Mesh();
        FlatMesh.vertices = new Vector3 [] { new Vector3(-1, 1), new Vector3(1, 1), new Vector3(1, -1), new Vector3(-1, -1) };
        FlatMesh.uv       = new Vector2[] { new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0), new Vector2(0, 0) };
        FlatMesh.SetIndices(new int[] { 0, 1, 2, 0, 2, 3 }, MeshTopology.Triangles, 0);
    }
コード例 #2
0
    public void init()
    {
        wvr.distortion.Distortion obj = new wvr.distortion.Distortion();
        Cleft              = new wvr.distortion.Config();
        Cleft.eye          = true;
        Cleft.rect         = new Rect(0, 0, 0.5f, 1);
        Cleft.expandRatio  = 1;
        Cleft.center       = GetCenter(WVR_Eye.WVR_Eye_Left);
        Cleft.mesh         = obj.createMesh(Cleft);
        Cleft.mesh.name    = "left_eye_distortion";
        Cright             = new wvr.distortion.Config();
        Cright.eye         = false;
        Cright.rect        = new Rect(0.5f, 0, 0.5f, 1);
        Cright.expandRatio = 1;
        Cright.center      = GetCenter(WVR_Eye.WVR_Eye_Right);
        Cright.mesh        = obj.createMesh(Cright);
        Cright.mesh.name   = "right_eye_distortion";

        Shader shader = Resources.Load <Shader>("WaveVR_Distortion");

        if (shader == null)
        {
            Debug.LogError("Can't find WaveVR/Distortion shader");
        }
        var material = new Material(shader);

        Cleft.material  = material;
        Cright.material = material;

        cam = GetComponent <Camera>();
        cam.orthographic     = true;
        cam.orthographicSize = 1;
        cam.cullingMask      = 0;
        cam.backgroundColor  = Color.black;
        cam.clearFlags       = CameraClearFlags.SolidColor;
        cam.projectionMatrix = Matrix4x4.identity;
        cam.enabled          = false;

        current = Cright;
    }