void CFlyingCamera::rotateWithMouse() { GetCursorPos(&pCur); RECT rRect; GetWindowRect(appMain.hWnd, &rRect); int iCentX = (rRect.left+rRect.right)>>1, iCentY = (rRect.top+rRect.bottom)>>1; float deltaX = (float)(iCentX-pCur.x)*fSensitivity; float deltaY = (float)(iCentY-pCur.y)*fSensitivity; if(deltaX != 0.0f) { vView -= vEye; vView = glm::rotate(vView, deltaX, glm::vec3(0.0f, 1.0f, 0.0f)); vView += vEye; } if(deltaY != 0.0f) { glm::vec3 vAxis = glm::cross(vView-vEye, vUp); vAxis = glm::normalize(vAxis); float fAngle = deltaY; float fNewAngle = fAngle+getAngleX(); if(fNewAngle > -89.80f && fNewAngle < 89.80f) { vView -= vEye; vView = glm::rotate(vView, deltaY, vAxis); vView += vEye; } } SetCursorPos(iCentX, iCentY); }
void *run(void *ptr_shared_data) { struct shared_data *l_ptr_shared_data; float l_pitch = 0; float l_bank = 0; int l_counter = 0; l_ptr_shared_data = (struct shared_data *) ptr_shared_data; MODEL* model = createModel(); // while stop == 0 calculate position. while (l_ptr_shared_data->stop == 0) { //l_pitch = l_ptr_shared_data->pitch; //l_bank = l_ptr_shared_data->bank; l_pitch = getAngleX(l_ptr_shared_data->a_axil, l_ptr_shared_data->a_side, l_ptr_shared_data->a_nrml); l_bank = getAngleY(l_ptr_shared_data->a_axil, l_ptr_shared_data->a_side, l_ptr_shared_data->a_nrml); char Buffer[256]; sprintf(Buffer,"MPD Thread: %3.2f, %3.2f\n", l_pitch, l_bank); // XPLMDebugString(Buffer); if (l_pitch != model->pitch || l_bank != model->bank) { model->pitch = l_pitch; model->bank = l_bank; computeElongations(model); // wait 10 milliseconds printf( "thread info : thread #%d, %d - pitch: %f bank: %f / cyl1: %f - cyl2: %f\n", l_ptr_shared_data->thread_id, l_counter, model->pitch, model->bank, model->elongation1, model->elongation2); l_ptr_shared_data->elongation1 = model->elongation1; l_ptr_shared_data->elongation2 = model->elongation2; } #if IBM Sleep(10); #endif #if LIN usleep(10); #endif l_counter++; } printf("thread info : stopping thread #%d, %d!\n", l_ptr_shared_data->thread_id, l_counter); pthread_exit(NULL); return 0; }