void mitk::WiiMoteThread::MultiWiiMoteIRInput() { // testing multiple wiimotes if(m_WiiMotes[0].IR.Dot[0].bVisible && m_WiiMotes[1].IR.Dot[0].bVisible) { float inputCoordinates[2] = {m_WiiMotes[0].IR.Dot[0].RawX, m_WiiMotes[0].IR.Dot[0].RawY}; mitk::Point2D tempPoint(inputCoordinates); float inputCoordinates2[2] = {m_WiiMotes[1].IR.Dot[0].RawX, m_WiiMotes[1].IR.Dot[0].RawY}; mitk::Point2D tempPoint2(inputCoordinates2); mitk::Vector2D result = (tempPoint2 - tempPoint); MITK_INFO << "IR1 :: X: " << tempPoint[0]; MITK_INFO << "IR1 :: Y: " << tempPoint[1]; MITK_INFO << "IR2 :: X: " << tempPoint2[0]; MITK_INFO << "IR2 :: Y: " << tempPoint2[1]; } }
int main(int argc, char* argv[]) { int width = SIZE * WIDTH; int height = SIZE * HEIGHT; int size = SIZE; Mat img(height, width, CV_8UC3, Scalar(0)); namedWindow("Display Image", WINDOW_AUTOSIZE); initialPlate(plate); while (true) { LBlock b(Point2f(WIDTH / 2, 3), plate); Block& block = b; Point2f point(0, 0); time_t tick, tock; time(&tick); while (true) { //image initialize by black img = Mat::zeros(height, width, CV_8UC3); //draw whole plate for (int y = 0; y < HEIGHT; y++) { for (int x = 0; x < WIDTH; x++) { int temp = y * WIDTH + x; if (plate[temp] != 0) { Point2f tempPoint1(x * size, y * size); Point2f tempPoint2(x * size + size - 1, y * size + size - 1); Rect rect(tempPoint1, tempPoint2); rectangle(img, rect, Scalar(255, 255, 255), -1); } } } //get input int input = cvWaitKey(1); if (input == 65361) { //left block.move(-1); } else if (input == 65362) { //up block.rotate(); } else if (input == 65363) { //right block.move(1); } else if (input == 65364) { //down block.move(0); } else if (input == 32) { //space block.moveFullDown(); checkLines(plate); break; } else if (input == 27) //esc return 0;; time(&tock); if (tock - tick > 0) { int deadOrNot = block.move(0); tick = tock; if (deadOrNot == -1) { break; } } imshow("Display Image", img); } } destroyAllWindows(); cvWaitKey(); return 0; }