Inheritance: TuioListener, IGrafitiClientGUIManager, IGestureListener
Example #1
0
        private float m_xm, m_ym; // mean point

        #endregion Fields

        #region Constructors

        public DemoObjectLink(Viewer viewer, DemoObject from, DemoObject to, int nFingers)
        {
            m_viewer = viewer;
            m_fromObject = from;
            m_toObject = to;
            m_nFingers = nFingers;
            Update();
            from.Links.Add(this);
            to.Links.Add(this);
        }
Example #2
0
        public DemoObject(DemoObjectManager objectManager, Viewer viewer, int fiducialId, float x, float y, float angle)
        {
            m_targetRadius = 0.4f;

            m_objectManager = objectManager;
            m_viewer = viewer;
            m_id = fiducialId++;
            m_x = x;
            m_y = y;
            m_angle = angle;

            m_color = new MyColor(s_random.NextDouble(), s_random.NextDouble(), s_random.NextDouble());

            GestureEventManager.SetPriorityNumber(typeof(BasicMultiFingerGR), m_objectManager.BasicMultiFingerGRConf, 0);
            GestureEventManager.RegisterHandler(typeof(BasicMultiFingerGR), m_objectManager.BasicMultiFingerGRConf, "Hover", OnHover);
            GestureEventManager.RegisterHandler(typeof(BasicMultiFingerGR), m_objectManager.BasicMultiFingerGRConf, "EndHover", OnEndHover);
            GestureEventManager.RegisterHandler(typeof(BasicMultiFingerGR), m_objectManager.BasicMultiFingerGRConf, "Tap", OnTap);
            //GestureEventManager.RegisterHandler(typeof(BasicMultiFingerGR), m_objectManager.BasicMultiFingerGRConf, "DoubleTap", OnDoubleTap);

            PinchingGRConfiguration m_pinchingGRConf = new PinchingGRConfiguration(true, this, false);
            GestureEventManager.SetPriorityNumber(typeof(PinchingGR), m_pinchingGRConf, 3);
            GestureEventManager.RegisterHandler(typeof(PinchingGR), m_pinchingGRConf, "Pinch", OnPinch);
        }
Example #3
0
        public DemoObjectManager(Viewer viewer)
        {
            m_viewer = viewer;
            m_tuioObjectAddedList = new List<TuioObject>();
            m_tuioObjectUpdatedList = new List<TuioObject>();
            m_tuioObjectRemovedList = new List<TuioObject>();
            m_idDemoObjectTable = new Dictionary<long,DemoObject>();

            RemovingLinkGRConfiguration removingLinkGRConf = new RemovingLinkGRConfiguration(this);
            GestureEventManager.SetPriorityNumber(typeof(RemovingLinkGR), removingLinkGRConf, 1);
            GestureEventManager.RegisterHandler(typeof(RemovingLinkGR), removingLinkGRConf, "RemoveLinks", OnRemoveLinks);

            MultiTraceGRConfiguration m_multiTraceGRConf = new MultiTraceGRConfiguration(true, MAX_SQUARE_DISTANCE_FOR_LINKING, true, false);
            GestureEventManager.SetPriorityNumber(typeof(MultiTraceGR), m_multiTraceGRConf, 3);
            GestureEventManager.RegisterHandler(typeof(MultiTraceGR), m_multiTraceGRConf, "MultiTraceFromTo", OnMultiTraceFromTo);

            LazoGRConfiguration lazoGRConf = new LazoGRConfiguration(m_currentSelectable, 1f / 20f);
            GestureEventManager.SetPriorityNumber(typeof(LazoGR), lazoGRConf, 2);
            GestureEventManager.RegisterHandler(typeof(LazoGR), lazoGRConf, "Lazo", OnLazo);
        }
Example #4
0
        static void Main(String[] argv)
        {
            float x = 0, y = 0, w = 10, h = 10, a = 0;

            int port = 3333;
            switch (argv.Length)
            {
                case 0:
                    break;

                case 1:
                    port = int.Parse(argv[0], null);
                    if (port == 0) goto default;
                    break;

                case 5:
                    x = float.Parse(argv[0], null);
                    y = float.Parse(argv[1], null);
                    w = float.Parse(argv[2], null);
                    h = float.Parse(argv[3], null);
                    a = float.Parse(argv[4], null);
                    break;

                case 6:
                    x = float.Parse(argv[1], null);
                    y = float.Parse(argv[2], null);
                    w = float.Parse(argv[3], null);
                    h = float.Parse(argv[4], null);
                    a = float.Parse(argv[5], null);
                    goto case 1;

                default:
                    Console.WriteLine("Usage: [mono] GrafitiGenericDemo [port] [x y w h a]");
                    System.Environment.Exit(0);
                    break;
            }

            // Force compilation of GR classes
            new PinchingGR();
            new BasicMultiFingerGR();
            new MultiTraceGR();
            new CircleGR();
            new LazoGR();
            new RemovingLinkGR();

            // instantiate viewer
            s_viewer = new Viewer(x, y, w, h, a);

            // instantiate Grafiti
            s_grafitiSurface = Surface.Initialize(s_viewer);

            // instantiate objects' manager
            s_demoObjectManager = new DemoObjectManager(s_viewer);

            // Tuio connections
            s_client = new TuioClient(port);
            s_client.addTuioListener(s_grafitiSurface);
            s_client.addTuioListener(s_demoObjectManager);
            s_client.addTuioListener(s_viewer);
            s_client.connect();

            // initialize glut library
            Glut.glutInit();

            // initialize viewer's graphic
            s_viewer.Init();

            // register callback functions
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(S_KeyPressed));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(S_SpecialKeyPressed));
            Glut.glutDisplayFunc(new Glut.DisplayCallback(S_Display));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(S_Reshape));
            Glut.glutTimerFunc(40, new Glut.TimerCallback(S_Timer), 0);

            // main loop
            try
            {
                Glut.glutMainLoop();
            }
            catch (ThreadAbortException e)
            {
                Exit();
            }
        }