Ejemplo n.º 1
0
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);
        }
    }
}
Ejemplo n.º 2
0
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);
        }
    }
}
Ejemplo n.º 3
0
/*
 =======================================================================================================================
 =======================================================================================================================
 */
void CNewTexWnd::OnLButtonDown(UINT nFlags, CPoint point) {
	cursor = point;

	SetFocus();
	bool fitScale = Sys_KeyDown(VK_CONTROL);
	bool edit = Sys_KeyDown(VK_SHIFT) && !fitScale;

	const idMaterial *mat = getMaterialAtPoint(point);
	if (mat) {
		Select_SetDefaultTexture(mat, fitScale, true);
	} else {
		Sys_Status("Did not select a texture\n", 0);
	}

	//
	UpdateSurfaceDialog();
	UpdatePatchInspector();
}
Ejemplo n.º 4
0
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 idGLDrawableView::mouseMove(float x, float y) {
	bool doZoom;
	float sensitivity = 0.5f;

	if (handleMove) {

		// Left mouse button rotates and zooms the view
		if (button == MK_LBUTTON) {
			doZoom = Sys_KeyDown(VK_MENU);
			if (doZoom) {
				if ( y != pressY ) {
					viewDistance -= ( y - pressY );
					pressY = y;
				}
			} else {
				float xo = 0.f;
				float yo = 0.f;

				if (x != pressX) {
					xo = (x - pressX);
					pressX = x;
				}
				if (y != pressY) {
					yo = (y - pressY);
					pressY = y;
				}

				viewRotation.yaw += -(xo * sensitivity);
				viewRotation.pitch += (yo * sensitivity);

				viewRotation.pitch = idMath::ClampFloat( -89.9f, 89.9f, viewRotation.pitch );
			}

		// Right mouse button moves lights in the view plane
		} else if (button == MK_RBUTTON) {
			int		i;
			float	lightMovement = 0;
			idVec3	lightForward, lightRight, lightUp;
			idVec3	lightMove;

			lightMove.Zero();
			viewRotation.ToVectors( &lightForward, &lightRight, &lightUp );

			doZoom = Sys_KeyDown(VK_MENU);
			if (doZoom) {
				if ( y != pressY ) {
					lightMovement = -( y - pressY ) * sensitivity;
					pressY = y;

					lightMovement = idMath::ClampFloat( -32.f, 32.f, lightMovement );
					lightMove = lightForward * lightMovement;
				}
			} else {
				if (x != pressX) {
					lightMovement = (x - pressX) * sensitivity;
					pressX = x;

					lightMovement = idMath::ClampFloat( -32.f, 32.f, lightMovement );
					lightMove = lightRight * lightMovement;
				}
				if (y != pressY) {
					lightMovement = -(y - pressY) * sensitivity;
					pressY = y;

					lightMovement = idMath::ClampFloat( -32.f, 32.f, lightMovement );
					lightMove += lightUp * lightMovement;
				}
			}

			// Go through the lights and move the ones that are set to allow movement
			for ( i = 0; i < viewLights.Num(); i++ ) {
				lightInfo_t	*vLight = &viewLights[i];
                
				if ( vLight->allowMove ) {
					vLight->origin += lightMove;
				}
			}

		// Middle mouse button moves object up and down
		} else if ( button == MK_MBUTTON ) {
			float yo = 0.f;

			if (y != pressY) {
				yo = (y - pressY);
				pressY = y;
			}

			viewOrigin.z -= yo;

			UpdateModel();
		}
	}
}
Ejemplo n.º 6
0
/*
 =======================================================================================================================
 =======================================================================================================================
 */
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;
	}
}