// Called whenever an ImageUpdate event is received via MinVR
        void OnImageUpdate(MinVR.VREvent e)
        {
            // access the image data buffer from the event
            float[] buffer = e.GetFloatArrayData("Buffer");

            // copy data into an array of colors
            int w = 100;
            int h = 100;

            Color[] colors = new Color[w * h];
            int     bindex = 0;
            int     cindex = 0;

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    colors[cindex] = new Color(buffer[bindex + 0], buffer[bindex + 1], buffer[bindex + 2], 1.0f);
                    cindex++;
                    bindex += 3;
                }
            }

            tex.SetPixels(colors);
            tex.Apply();

            // connect texture to material of GameObject this script is attached to
            GetComponent <Renderer>().material.mainTexture = tex;
        }
示例#2
0
        void OnButtonDown()
        {
            buttonPressed = true;
            if (selected == 0)
            {
                titleBoxObj.GetComponent <Renderer>().material.color = pressColor;
            }
            else if (selected > 0)
            {
                labelBoxes[selected - 1].GetComponent <Renderer>().material.color = pressColor;

                string        eName = eventsToGenerate[selected - 1];
                MinVR.VREvent e     = new MinVR.VREvent(eName);
                e.AddData("EventType", "ButtonDown");
                MinVR.VRMain.Instance.QueueEvent(e);
            }
        }