void RenderingEngine1::Initialize(int width, int height) { // Create the framebuffer object and attach the color buffer. glGenFramebuffersOES(1, &m_framebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_framebuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_renderbuffer); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); // Initialize the projection matrix. const float maxX = 2; const float maxY = 3; glOrthof(-maxX, +maxX, -maxY, +maxY, -1, 1); glMatrixMode(GL_MODELVIEW); // Initialize the rotation animation state. OnRotate(DeviceOrientationPortrait); m_currentAngle = m_desiredAngle; }
void CTouchInput::handleRotation() { Pointer& primaryPointer = m_pointers[0]; Pointer& secondaryPointer = m_pointers[1]; CVector last = primaryPointer.last - secondaryPointer.last; CVector current = primaryPointer.current - secondaryPointer.current; float length = last.length() * current.length(); if (length != 0.0f) { float centerX = (primaryPointer.current.x + secondaryPointer.current.x) / 2; float centerY = (primaryPointer.current.y + secondaryPointer.current.y) / 2; float scalar = last.scalar(current); float angle = acos(scalar / length) * 180.0f / M_PI; // make sure the result of acos is a valid number if (angle == angle) { // calculate the direction of the rotation using the // z-component of the cross-product of last and current float direction = last.x * current.y - current.x * last.y; if (direction < 0.0f) m_fRotateAngle -= angle; else m_fRotateAngle += angle; OnRotate(centerX, centerY, m_fRotateAngle); } } }
void RenderingEngine2::Initialize(int width, int height) { // Create the framebuffer object and attach the color buffer. #ifdef __APPLE__ glGenFramebuffers(1, &m_framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffer); #endif #ifndef ANDROID_NDK m_framebuffer = (GLuint)0; #endif glViewport(0, 0, width, height); // m_simpleProgram = BuildProgram(gVertexShader, gFragmentShader); m_simpleProgram = BuildProgram(SimpleVertexShader, SimpleFragmentShader); glUseProgram(m_simpleProgram); // Initialize the projection matrix. ApplyOrtho(2, 3); // Initialize rotation animation state. OnRotate(DeviceOrientationPortrait); m_currentAngle = m_desiredAngle; }
// 分发控制命令 void DispatchControl(CTRL _ctrl) { switch(_ctrl) { case CTRL_ROTATE: OnRotate(); break; case CTRL_LEFT: OnLeft(); break; case CTRL_RIGHT: OnRight(); break; case CTRL_DOWN: OnDown(); break; case CTRL_SINK: OnSink(); break; case CTRL_QUIT: break; } }
void RenderingEngine1::Initialize(int width, int height) { glGenFramebuffersOES(1, &_frameBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, _frameBuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _renderBuffer); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); const float maxX = 2; const float maxY = 3; glOrthof(-maxX, +maxX, -maxY, +maxY, -1, 1); glMatrixMode(GL_MODELVIEW); OnRotate(DeviceOrientationPortrait); _currentAngle = _desiredAngle; }
bool CGenericTouchRotateDetector::OnTouchMove(unsigned int index, const Pointer &pointer) { if (index >= MAX_POINTERS) return false; if (m_done) return true; // update the internal pointers m_pointers[index] = pointer; Pointer& primaryPointer = m_pointers[0]; Pointer& secondaryPointer = m_pointers[1]; if (!primaryPointer.valid() || !secondaryPointer.valid() || (!primaryPointer.moving && !secondaryPointer.moving)) return false; CVector last = primaryPointer.last - secondaryPointer.last; CVector current = primaryPointer.current - secondaryPointer.current; float length = last.length() * current.length(); if (length != 0.0f) { float centerX = (primaryPointer.current.x + secondaryPointer.current.x) / 2; float centerY = (primaryPointer.current.y + secondaryPointer.current.y) / 2; float scalar = last.scalar(current); float angle = acos(scalar / length) * 180.0f / static_cast<float>(M_PI); // make sure the result of acos is a valid number if (angle == angle) { // calculate the direction of the rotation using the // z-component of the cross-product of last and current float direction = last.x * current.y - current.x * last.y; if (direction < 0.0f) m_angle -= angle; else m_angle += angle; OnRotate(centerX, centerY, m_angle); } } return true; }
void GizmoBar::OnNodeSelect() { switch (Gizmo::Instance()->GetOperator()) { case Gizmo::OP_MOVE: OnMove(NULL); break; case Gizmo::OP_ROTATE: OnRotate(NULL); break; case Gizmo::OP_SCALE: OnScale(NULL); break; } }
int Visor::cQMainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: OnLayout(); break; case 1: OnSliderMoved((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: OnRotate(); break; case 3: OnMove(); break; case 4: OnWatchTimer(); break; case 5: OnShot(); break; default: ; } _id -= 6; } return _id; }
BOOL CRVTrackerDrawPoly::OnUpdate(const CUIEvent &cEvent) { //see if they want to finish drawing the polygon if(m_bFinishDrawingPoly) { // Make sure we don't cancel when the focus goes away m_bAllowCancel = FALSE; // Create the brush m_pView->FinishDrawingPoly(); m_bAllowCancel = TRUE; //we are no longer drawing a poly, so we can start another one m_bFinishDrawingPoly = FALSE; return FALSE; } BOOL bCancel = FALSE; // Handle any events that happen if (m_pUndoTracker) { BOOL bOldActive = m_pUndoTracker->GetActive(); m_pUndoTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pUndoTracker->GetActive()) bCancel = OnUndo(); } if (m_pNewVertexTracker) { BOOL bOldActive = m_pNewVertexTracker->GetActive(); m_pNewVertexTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pNewVertexTracker->GetActive()) bCancel = OnNewVertex(); } if (m_pSplitTracker) { BOOL bOldActive = m_pSplitTracker->GetActive(); m_pSplitTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pSplitTracker->GetActive()) bCancel = OnSplit(); } if (m_pRotateTracker) { BOOL bOldActive = m_pRotateTracker->GetActive(); m_pRotateTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pRotateTracker->GetActive()) bCancel = OnRotate(); } if (m_pInsertEdgeTracker) { BOOL bOldActive = m_pInsertEdgeTracker->GetActive(); m_pInsertEdgeTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pInsertEdgeTracker->GetActive()) bCancel = OnNewEdge(); } if(m_pVertSnapTracker) { m_pVertSnapTracker->ProcessEvent(cEvent); m_bVertSnap = m_pVertSnapTracker->GetActive(); } if(m_pCloseTracker) { BOOL bOldActive = m_pCloseTracker->GetActive(); m_pCloseTracker->ProcessEvent(cEvent); if((bOldActive == FALSE) && m_pCloseTracker->GetActive()) bCancel = ClosePoly(); } if (bCancel) // End the tracker return FALSE; // Only update everything else on idle events if (cEvent.GetType() != UIEVENT_NONE) return TRUE; // Don't update if it hasn't moved if (m_cCurPt == m_cLastPt) return TRUE; // Do the autoscroll of the window DoAutoScroll(); switch( m_pView->m_EditState ) { case EDIT_DRAWINGPOLY: { UpdateDrawPolyVertex(m_cCurPt); break; } } // Update the views... m_pView->GetDocument()->UpdateAllViews(m_pView); m_pView->DrawRect(); m_cLastPt = m_cCurPt; return TRUE; }
void GizmoBar::OnRotationChanged() { OnRotate(NULL); }