Beispiel #1
0
        protected void parse6d(String msg)
        {
            int       id       = 0;
            ARTPoint  position = ARTPoint.Empty();
            ARTAngle  angle    = ARTAngle.Empty();
            ARTMatrix matrix   = ARTMatrix.Empty();


            msg = msg.Replace("]", "");
            msg = msg.Replace("[", "x");
            String[] tmp = msg.Split('x');
            if (tmp.Length >= 4)
            {
                numberOf6dTargets = parseInt(tmp[0]);
                String[] tmp2 = tmp[1].Split(' ');
                if (tmp2.Length >= 2)
                {
                    id = parseInt(tmp2[0]);
                }
                tmp2 = tmp[2].Split(' ');
                if (tmp2.Length >= 6)
                {
                    position = new ARTPoint(parseFloat(tmp2[0]),
                                            parseFloat(tmp2[1]), parseFloat(tmp2[2]));
                    angle = new ARTAngle(parseFloat(tmp2[3]), parseFloat(tmp2[4]),
                                         parseFloat(tmp2[5]));
                }
                tmp2 = tmp[3].Split(' ');
                if (tmp2.Length >= 9)
                {
                    matrix = new ARTMatrix(parseFloatArray(tmp2));
                }
                add6dObject(new ART6d(id, position, angle, matrix));
                for (int i = 0; i < observers.Count; i++)
                {
                    ((ARTObserver)observers[i]).on6dUpdate(this);
                }
            }
        }
Beispiel #2
0
        protected void parse6df2(String msg)
        {
            int       id = 1;
            int       numberOfButtons     = 0;
            int       numberOfControllers = 0;
            bool      visible             = false;
            ARTPoint  position            = ARTPoint.Empty();
            ARTMatrix matrix           = ARTMatrix.Empty();
            int       buttonStates     = 0;
            var       controllerStates = new float[0];


            msg = msg.Replace("]", "");
            msg = msg.Replace("[", "x");
            String[] tmp = msg.Split('x');
            if (tmp.Length >= 5)
            {
                numberOfFlysticks = parseInt(tmp[0]);
                String[] tmp2 = tmp[1].Split(' ');
                if (tmp2.Length >= 4)
                {
                    id = parseInt(tmp2[0]);
                    if (parseFloat(tmp2[1]) > 0.0F)
                    {
                        visible = true;
                    }
                    numberOfButtons     = parseInt(tmp2[2]);
                    numberOfControllers = parseInt(tmp2[3]);
                }
                tmp2 = tmp[2].Split(' ');
                if (tmp2.Length >= 3)
                {
                    position = new ARTPoint(parseFloat(tmp2[0]),
                                            parseFloat(tmp2[1]), parseFloat(tmp2[2]));
                }
                tmp2 = tmp[3].Split(' ');
                if (tmp2.Length >= 9)
                {
                    matrix = new ARTMatrix(parseFloatArray(tmp2));
                }
                tmp2 = tmp[4].Split(' ');
                if (tmp2.Length >= 1)
                {
                    if (numberOfButtons > 0)
                    {
                        buttonStates     = parseInt(tmp2[0]);
                        controllerStates = new float[tmp2.Length - 1];
                        for (int i = 0; i < controllerStates.Length; i++)
                        {
                            controllerStates[i] = parseFloat(tmp2[(i + 1)]);
                        }
                    }
                    else
                    {
                        controllerStates = new float[tmp2.Length];
                        for (int i = 0; i < controllerStates.Length; i++)
                        {
                            controllerStates[i] = parseFloat(tmp2[i]);
                        }
                    }
                }
                addFlystick(new ARTFlystick(id, visible, numberOfButtons,
                                            buttonStates, numberOfControllers, controllerStates,
                                            position, matrix));
                for (int i = 0; i < observers.Count; i++)
                {
                    ((ARTObserver)observers[i]).onFlystickUpdate(this);
                }
                foreach (IFlystickListener listener in flystickListener)
                {
                    UpdateFlystickListener(listener);
                }
            }
        }
Beispiel #3
0
 public static ART6d Empty()
 {
     return(new ART6d(-1, ARTPoint.Empty(), ARTAngle.Empty(), ARTMatrix.Empty()));
 }
Beispiel #4
0
 public static ARTFlystick Empty()
 {
     return(new ARTFlystick(-1, false, 0, 0, 0, new float[0], ARTPoint.Empty(), ARTMatrix.Empty()));
 }