Ejemplo n.º 1
0
    void Start()
    {
        _width    = 512;
        _height   = 424;
        _texScale = 1;
        _objs     = null;
        _hide     = false;

        _mat = Resources.Load("Materials/cloudmatDepth") as Material;

        _decoder      = new RVLDecoder();
        _colorDecoder = new Decompressor();

        initStructs();
    }
Ejemplo n.º 2
0
    public void Init()
    {
        _width    = 512;
        _height   = 424;
        _texScale = 1;
        _objs     = null;


        _mat = Resources.Load("Materials/meshmat") as Material;

        _decoder      = new RVLDecoder();
        _colorDecoder = new Decompressor();

        initStructs();
    }
Ejemplo n.º 3
0
    public void Init(bool local)
    {
        _width    = 512;
        _height   = 424;
        _texScale = 1;
        _objs     = null;

        _local = local;

        string matDescription = local ? "Materials/localmat" : "Materials/remotemat";

        _mat = Resources.Load(matDescription) as Material;

        _decoder      = new RVLDecoder();
        _colorDecoder = new Decompressor();

        initStructs();
    }
Ejemplo n.º 4
0
    public void initStructs(uint id, string colorVideo, string depthVideo, GameObject cloudGameobj, CloudVideoPlayer mainPlayer)
    {
        _id                  = id;
        _depthTex            = new Texture2D(_width, _height, TextureFormat.BGRA32, false);
        _depthTex.filterMode = FilterMode.Point;
        _depthBytes          = new byte[_width * _height * 4];
        _cloudGameobj        = cloudGameobj;
        _mainPlayer          = mainPlayer;
        //Setup color
        // VideoClip clip = Resources.Load<VideoClip>(colorVideo) as VideoClip;
        VideoPlayer play = cloudGameobj.AddComponent <VideoPlayer>();

        play.playOnAwake = false;
        //play.clip = clip;
        play.url                  = colorVideo;
        play.targetTexture        = new RenderTexture(_width, _height, 24, RenderTextureFormat.BGRA32);
        play.sendFrameReadyEvents = true;
        play.frameReady          += this.OnNewFrame;
        play.errorReceived       += this.errorReceived;
        // play.seekCompleted += this.VideoSeekCompleted;
        play.skipOnDrop = false;
        _player         = play;
        _player.Prepare();

        //setup depth
        _decoder = new RVLDecoder(depthVideo, _width, _height);

        // StartCoroutine(_decoder.Prepare());
        _decoder.Prepare();
        if (_objs != null)
        {
            foreach (GameObject g in _objs)
            {
                GameObject.Destroy(g);
            }
        }
        _objs = new List <GameObject>();

        List <Vector3> points = new List <Vector3>();
        List <int>     ind    = new List <int>();
        int            n      = 0;
        int            i      = 0;

        for (float w = 0; w < _width; w++)
        {
            for (float h = 0; h < _height; h++)
            {
                Vector3 p = new Vector3(w / _width, h / _height, 0);
                points.Add(p);
                ind.Add(n);
                n++;

                if (n == 65000)
                {
                    GameObject   a  = new GameObject("cloud" + i);
                    MeshFilter   mf = a.AddComponent <MeshFilter>();
                    MeshRenderer mr = a.AddComponent <MeshRenderer>();
                    mr.material = _mat;
                    mr.material.SetTexture("_ColorTex", play.targetTexture);
                    mf.mesh          = new Mesh();
                    mf.mesh.vertices = points.ToArray();
                    mf.mesh.SetIndices(ind.ToArray(), MeshTopology.Points, 0);
                    mf.mesh.bounds            = new Bounds(new Vector3(0, 0, 4.5f), new Vector3(5, 5, 5));
                    a.transform.parent        = cloudGameobj.transform;
                    a.transform.localPosition = Vector3.zero;
                    a.transform.localRotation = Quaternion.identity;
                    a.transform.localScale    = new Vector3(1, 1, 1);
                    n = 0;
                    i++;
                    _objs.Add(a);
                    points = new List <Vector3>();
                    ind    = new List <int>();
                }
            }
        }
        GameObject   afinal  = new GameObject("cloud" + i);
        MeshFilter   mfinal  = afinal.AddComponent <MeshFilter>();
        MeshRenderer mrfinal = afinal.AddComponent <MeshRenderer>();

        mrfinal.material     = _mat;
        mfinal.mesh          = new Mesh();
        mfinal.mesh.vertices = points.ToArray();
        mfinal.mesh.SetIndices(ind.ToArray(), MeshTopology.Points, 0);
        afinal.transform.parent        = cloudGameobj.transform;
        afinal.transform.localPosition = Vector3.zero;
        afinal.transform.localRotation = Quaternion.identity;
        afinal.transform.localScale    = new Vector3(1, 1, 1);
        n = 0;
        i++;
        _objs.Add(afinal);
        points = new List <Vector3>();
        ind    = new List <int>();
    }