コード例 #1
0
ファイル: Octonion.cs プロジェクト: vnmone/vvvv-sdk
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FMyValueInput1.PinIsChanged || FMyValueInput2.PinIsChanged || FMyValueInput3.PinIsChanged || FMyValueInput4.PinIsChanged)
            {
                //first set slicecounts for all outputs
                //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default
                FMyValueOutput1.SliceCount = SpreadMax;
                FMyValueOutput2.SliceCount = SpreadMax;

                //the variables to fill with the input data
                double a1, a2, a3, a4;
                double b1, b2, b3, b4;
                double c1, c2, c3, c4;
                double d1, d2, d3, d4;

                Vector4D a, b, c, d, out1, out2;
                //loop for all slices
                for (int i = 0; i < SpreadMax; i++)
                {
                    //read data from inputs
                    FMyValueInput1.GetValue4D(i, out a1, out a2, out a3, out a4);
                    FMyValueInput2.GetValue4D(i, out b1, out b2, out b3, out b4);
                    FMyValueInput3.GetValue4D(i, out c1, out c2, out c3, out c4);
                    FMyValueInput4.GetValue4D(i, out d1, out d2, out d3, out d4);

                    a = new Vector4D(a1, a2, a3, a4);
                    b = new Vector4D(b1, b2, b3, b4);
                    c = new Vector4D(c1, c2, c3, c4);
                    d = new Vector4D(d1, d2, d3, d4);


                    // http://en.wikipedia.org/wiki/Octonion
                    // following the Cayley-Dickinson construction
                    // (a,b)(c,d) = (ac - db * ,da + bc * )
                    // where x * is the conjugate of x

                    out1 = new Vector4D(b1, -b2, -b3, -b4);
                    out2 = new Vector4D(c1, -c2, -c3, -c4);

                    out1 = a * c - d * out1;
                    out2 = d * a + b * out2;

                    //write data to outputs

                    FMyValueOutput1.SetValue4D(i, out1.x, out1.y, out1.z, out1.w);
                    FMyValueOutput2.SetValue4D(i, out2.x, out2.y, out2.z, out2.w);
                }
            }

            #endregion mainloop
        }
コード例 #2
0
ファイル: Octonion.cs プロジェクト: vnmone/vvvv-sdk
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FMyValueInput1.PinIsChanged || FMyValueInput2.PinIsChanged || FMyValueInput3.PinIsChanged || FMyValueInput4.PinIsChanged)
            {
                //first set slicecounts for all outputs
                //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default
                FMyValueOutput1.SliceCount = SpreadMax;
                FMyValueOutput2.SliceCount = SpreadMax;

                //the variables to fill with the input data
                double a1, a2, a3, a4;
                double b1, b2, b3, b4;
                double c1, c2, c3, c4;
                double d1, d2, d3, d4;

                Vector4D a, b, c, d, out1, out2;
                //loop for all slices
                for (int i = 0; i < SpreadMax; i++)
                {
                    //read data from inputs
                    FMyValueInput1.GetValue4D(i, out a1, out a2, out a3, out a4);
                    FMyValueInput2.GetValue4D(i, out b1, out b2, out b3, out b4);
                    FMyValueInput3.GetValue4D(i, out c1, out c2, out c3, out c4);
                    FMyValueInput4.GetValue4D(i, out d1, out d2, out d3, out d4);

                    a = new Vector4D(a1, a2, a3, a4);
                    b = new Vector4D(b1, b2, b3, b4);
                    // create c and d already inverted, then just use the same algorithm as multiplication
                    c = new Vector4D(c1, -c2, -c3, -c4) / (c1 * c1 + c2 * c2 + c3 * c3 + c4 * c4 + d1 * d1 + d2 * d2 + d3 * d3 + d4 * d4);
                    d = new Vector4D(-d1, -d2, -d3, -d4) / (c1 * c1 + c2 * c2 + c3 * c3 + c4 * c4 + d1 * d1 + d2 * d2 + d3 * d3 + d4 * d4);

                    out1 = new Vector4D(b.x, -b.y, -b.z, -b.w);
                    out2 = new Vector4D(c.x, -c.y, -c.z, -c.w);

                    out1 = a * c - d * out1;
                    out2 = d * a + b * out2;

                    //write data to outputs

                    FMyValueOutput1.SetValue4D(i, out1.x, out1.y, out1.z, out1.w);
                    FMyValueOutput2.SetValue4D(i, out2.x, out2.y, out2.z, out2.w);
                }
            }

            #endregion mainloop
        }
コード例 #3
0
ファイル: WiiMotePlugin.cs プロジェクト: vnmone/vvvv-sdk
        private void Guitar()
        {
            FPinOutputExtButtons.SliceCount = 1;
            FPinOutputExtButtons.SetValue4D(0, FRemote.WiimoteState.GuitarState.ButtonState.Plus?1d:0d, FRemote.WiimoteState.GuitarState.ButtonState.Minus?1d:0d, FRemote.WiimoteState.GuitarState.ButtonState.StrumUp?1d:0d, FRemote.WiimoteState.GuitarState.ButtonState.StrumDown?1d:0d);

            FPinOutputExtControls.SliceCount = 5;
            FPinOutputExtAccelleration.SetValue(0, FRemote.WiimoteState.GuitarState.FretButtonState.Green?1d:0d);
            FPinOutputExtAccelleration.SetValue(1, FRemote.WiimoteState.GuitarState.FretButtonState.Red?1d:0d);
            FPinOutputExtAccelleration.SetValue(2, FRemote.WiimoteState.GuitarState.FretButtonState.Yellow?1d:0d);
            FPinOutputExtAccelleration.SetValue(3, FRemote.WiimoteState.GuitarState.FretButtonState.Blue?1d:0d);
            FPinOutputExtAccelleration.SetValue(4, FRemote.WiimoteState.GuitarState.FretButtonState.Orange?1d:0d);

            FPinOutputExtJoystickLeft.SliceCount = 1;
            FPinOutputExtJoystickLeft.SetValue(0, FRemote.WiimoteState.GuitarState.WhammyBar);

            FPinOutputExtJoystickRight.SliceCount = 1;
            FPinOutputExtJoystickLeft.SetValue2D(0, FRemote.WiimoteState.GuitarState.Joystick.X * 2, FRemote.WiimoteState.GuitarState.Joystick.Y * 2);
        }