コード例 #1
0
 void Start()
 {
     WiiMote.wiimote_start();
     midY = transform.position.y;
     X    = WiiMote.wiimote_getIrX(0) * 10;
     Y    = WiiMote.wiimote_getIrY(0) * 10;
     Z    = 100f;
     if (X == -1000)
     {
         oldVec = transform.position;
     }
     else
     {
         oldVec = new Vector3(-X, -Y + 1.8f, Z);
     }
 }
コード例 #2
0
    void OnGUI()
    {
        int c = WiiMote.wiimote_count();

        for (int i = 0; i <= c - 1; i++)
        {
            float ir_x = WiiMote.wiimote_getIrX(Configuration.pointerWiiMote);
            float ir_y = WiiMote.wiimote_getIrY(Configuration.pointerWiiMote);
            if ((ir_x != -100) && (ir_y != -100))
            {
                float temp_x = ((ir_x + (float)1.0) / (float)2.0) * (float)Screen.width;
                float temp_y = (float)Screen.height - (((ir_y + (float)1.0) / (float)2.0) * (float)Screen.height);
                temp_x = Mathf.RoundToInt(temp_x);
                temp_y = Mathf.RoundToInt(temp_y);
                GUI.DrawTexture(new Rect(temp_x, temp_y, 64, 64), mira, ScaleMode.ScaleToFit, true, 1.0F);
            }
        }
    }
コード例 #3
0
    public static Vector3 getWiimoteCrosshair()
    {
        float ir_x = WiiMote.wiimote_getIrX(Configuration.pointerWiiMote);
        float ir_y = WiiMote.wiimote_getIrY(Configuration.pointerWiiMote);

        ir_x = (Screen.width / 2) + ir_x * (float)Screen.width / (float)2.0;
        ir_y = Screen.height - (ir_y * (float)Screen.height / (float)2.0);

        if (ir_x > 0 && ir_y > 0)
        {
            oldPos = Camera.main.camera.ScreenToWorldPoint(new Vector3(ir_x + 37f, Screen.height * 1.5f - ir_y - 37f, 20));
            return(Camera.main.camera.ScreenToWorldPoint(new Vector3(ir_x + 37f, Screen.height * 1.5f - ir_y - 37f, 20)));
        }
        else
        {
            return(oldPos);
        }
    }
コード例 #4
0
    void MoveCamera()
    {
        X = WiiMote.wiimote_getIrX(Configuration.cameraWiiMote) * 10;
        Y = WiiMote.wiimote_getIrY(Configuration.cameraWiiMote) * 2;
        Z = 60f;

        /* NO BORRAR
         * if (X==-1000 && Y==-200) {
         *      transform.position = oldVec;
         * }
         * else if(X>-9.5f && X<9.5f && Y<0f) {
         *      oldVec = new Vector3(-X, -Y+1.8f ,Z);
         * }
         */
        bool spaceBar = Input.GetKey(KeyCode.Space);

        if (spaceBar = true)
        {
            transform.position = new Vector3(0, 0, 0);
        }

        if (X > -10f && X < 10f && Y < 2.5f)
        {
            if (menu == true)
            {
                vec = new Vector3(-X, -Y, 0f);
                gameObject.transform.LookAt(vec);
            }
            else
            {
                oldVec             = new Vector3(-X, -Y + 1.8f, 60f);
                transform.position = oldVec;
                gameObject.transform.LookAt(center);
            }
        }
        else if (X == -1000 && Y == -200)
        {
            transform.position = oldVec;
        }
    }
コード例 #5
0
 void Start()
 {
     if (menu == true)
     {
     }
     else
     {
         WiiMote.wiimote_start();
         print(Configuration.cameraWiiMote);
         X = WiiMote.wiimote_getIrX(Configuration.cameraWiiMote) * 10;
         Y = WiiMote.wiimote_getIrY(Configuration.cameraWiiMote) * 10;
         Z = 60f;
         if (X == -1000)
         {
             oldVec = transform.position;
         }
         else
         {
             oldVec = new Vector3(-X, -Y + 1.8f, Z);
         }
     }
 }
コード例 #6
0
    void MoveCamera()
    {
        X = WiiMote.wiimote_getIrX(0) * 10;
        Y = WiiMote.wiimote_getIrY(0) * 2f;

        print(X);

        Z = 60f;


        transform.position = oldVec;
        if (X > -9.5f && X < 9.5f)
        {
            oldVec = new Vector3(-X, -Y + 1.8f, Z);
        }

        //if (X==-1000 || Y<-0){
        //        transform.position = oldVec;
        //}
        //else if(X<=9f) {
        //        vec = new Vector3(X, Y, Z);
        //        oldVec = vec;
        //        transform.position = vec;
        //}

        /*if(X<=9f){
         *      if (X==-1000 || Y<-0){
         *              transform.position += oldVec;
         *      } else {
         *              vec = new Vector3(X, Y, Z);
         *              oldVec = vec;
         *              transform.position += vec;
         *      }
         * }*/

        gameObject.transform.LookAt(center);
        debug.text = "x:" + X + " Y:" + Y;
    }