void idGLDrawableMaterial::mouseMove(float x, float y) { if (handleMove) { Update(); bool doScale = Sys_KeyDown(VK_MENU); bool doLight = Sys_KeyDown(VK_SHIFT); if (doScale || doLight) { // scale float *px = &x; float *px2 = &pressX; if (fDiff(y, pressY) > fDiff(x, pressX)) { px = &y; px2 = &pressY; } if (*px > *px2) { // zoom in if (doScale) { scale += 0.1f; if ( scale > 10.0f ) { scale = 10.0f; } } else { light += 0.05f; if ( light > 2.0f ) { light = 2.0f; } } } else if (*px < *px2) { // zoom out if (doScale) { scale -= 0.1f; if ( scale <= 0.001f ) { scale = 0.001f; } } else { light -= 0.05f; if ( light < 0.0f ) { light = 0.0f; } } } *px2 = *px; ::SetCursorPos(pressX, pressY); } else { // origin if (x != pressX) { xOffset += (x - pressX); pressX = x; } if (y != pressY) { yOffset -= (y - pressY); pressY = y; } //::SetCursorPos(pressX, pressY); } } }
double ClipPoint::intersect(const Vector3& point, EViewType viewtype, float scale) { int nDim1 = (viewtype == YZ) ? 1 : 0; int nDim2 = (viewtype == XY) ? 1 : 2; double screenDistanceSquared( Vector2( fDiff(_coords[nDim1], point[nDim1]) * scale, fDiff(_coords[nDim2], point[nDim2]) * scale).getLengthSquared() ); if (screenDistanceSquared < 8*8) { return screenDistanceSquared; } return FLT_MAX; }
void idGLDrawable::mouseMove(float x, float y) { if (handleMove) { Update(); if (Sys_KeyDown(VK_MENU)) { // scale float *px = &x; float *px2 = &pressX; if (fDiff(y, pressY) > fDiff(x, pressX)) { px = &y; px2 = &pressY; } if (*px > *px2) { // zoom in scale += 0.1f; if ( scale > 10.0f ) { scale = 10.0f; } } else if (*px < *px2) { // zoom out scale -= 0.1f; if ( scale <= 0.001f ) { scale = 0.001f; } } *px2 = *px; ::SetCursorPos(pressX, pressY); } else if (Sys_KeyDown(VK_SHIFT)) { // rotate } else { // origin if (x != pressX) { xOffset += (x - pressX); pressX = x; } if (y != pressY) { yOffset -= (y - pressY); pressY = y; } //::SetCursorPos(pressX, pressY); } } }
void idGLDrawableModel::mouseMove(float x, float y) { if (handleMove) { Update(); if (button == MK_LBUTTON) { float cury = ( float )( 2 * x - rect.z ) / rect.z; float curx = ( float )( 2 * y - rect.w ) / rect.w; idVec3 to( -curx, -cury, 0.0f ); to.ProjectSelfOntoSphere( radius ); lastPress.ProjectSelfOntoSphere( radius ); idVec3 axis; axis.Cross( to, lastPress ); float len = ( lastPress - to ).Length() / ( 2.0f * radius ); len = idMath::ClampFloat( -1.0f, 1.0f, len ); float phi = 2.0f * asin ( len ) ; axis.Normalize(); axis *= sin( phi / 2.0f ); idQuat rot( axis.z, axis.y, axis.x, cos( phi / 2.0f ) ); rot.Normalize(); rotation *= rot; rotation.Normalize(); lastPress = to; lastPress.z = 0.0f; } else { bool doScale = Sys_KeyDown(VK_MENU); bool doLight = Sys_KeyDown(VK_SHIFT); if (doLight) { // scale float *px = &x; float *px2 = &pressX; if (fDiff(y, pressY) > fDiff(x, pressX)) { px = &y; px2 = &pressY; } if (*px > *px2) { light += 0.05f; if ( light > 2.0f ) { light = 2.0f; } } else if (*px < *px2) { light -= 0.05f; if ( light < 0.0f ) { light = 0.0f; } } *px2 = *px; ::SetCursorPos(pressX, pressY); } else { // origin if (x != pressX) { if (doScale) { zOffset += (x - pressX); } else { xOffset += (x - pressX); } pressX = x; } if (y != pressY) { if (doScale) { zOffset -= (y - pressY); } else { yOffset -= (y - pressY); } pressY = y; } //::SetCursorPos(pressX, pressY); } } } }
/* ======================================================================================================================= ======================================================================================================================= */ void CNewTexWnd::OnMouseMove(UINT nFlags, CPoint point) { int scale = 1; if (Sys_KeyDown(VK_SHIFT)) { scale = 4; } // rbutton = drag texture origin if (Sys_KeyDown(VK_RBUTTON)) { if (point.y != cursor.y) { if (Sys_KeyDown(VK_MENU)) { long *px = &point.x; long *px2 = &cursor.x; if (fDiff(point.y, cursor.y) > fDiff(point.x, cursor.x)) { px = &point.y; px2 = &cursor.y; } if (*px > *px2) { // zoom in g_PrefsDlg.m_nTextureScale += 4; if (g_PrefsDlg.m_nTextureScale > 500) { g_PrefsDlg.m_nTextureScale = 500; } } else if (*px < *px2) { // zoom out g_PrefsDlg.m_nTextureScale -= 4; if (g_PrefsDlg.m_nTextureScale < 1) { g_PrefsDlg.m_nTextureScale = 1; } } *px2 = *px; CPoint screen = cursor; ClientToScreen(&screen); SetCursorPos(screen.x, screen.y); //Sys_SetCursorPos(cursor.x, cursor.y); InvalidateRect(NULL, false); UpdateWindow(); } else if (point.y != cursor.y || point.x != cursor.x) { origin.y += (point.y - cursor.y) * scale; if (origin.y > 0) { origin.y = 0; } //Sys_SetCursorPos(cursor.x, cursor.y); CPoint screen = cursor; ClientToScreen(&screen); SetCursorPos(screen.x, screen.y); if (g_PrefsDlg.m_bTextureScrollbar) { SetScrollPos(SB_VERT, abs(origin.y)); } InvalidateRect(NULL, false); UpdateWindow(); } } return; } }