void SubdividerState::mouseMoved(double x, double y) {
    if (paused) {
        return;
    }
    
    nsgl::Vec2f mouseCurr(x, y), dv;
    
    dv = mouseCurr - mousePrev;
    if (dv.norm() > 50.0f)
        dv = nsgl::Vec2f(0, 0);
    
    mousePrev = mouseCurr;
    camera.mouseMoved(dv.x(), dv.y());
}
Beispiel #2
0
void Camera::mouseMoved(int x, int y)
{
    Eigen::Vector2f mouseCurr(x, y);
    Eigen::Vector2f dv = mouseCurr - mousePrev;
    switch(state) {
    case Camera::ROTATE:
        rotations += rfactor * dv;
        break;
    case Camera::TRANSLATE:
        translations(0) += tfactor * dv(0);
        translations(1) -= tfactor * dv(1);
        break;
    case Camera::SCALE:
        translations(2) *= (1.0f - sfactor * dv(1));
        break;
    }
    mousePrev = mouseCurr;
}
void Camera::mouseMoved(int x, int y)
{
	glm::vec2 mouseCurr(x, y);
	glm::vec2 dv = mouseCurr - mousePrev;
	switch(state) {
		case Camera::ROTATE:
			rotations += rfactor * dv;
			break;
		case Camera::TRANSLATE:
			translations.x += tfactor * dv.x;
			translations.y -= tfactor * dv.y;
			break;
		case Camera::SCALE:
			translations.z *= (1.0f + sfactor * dv.y);
			break;
	}
	mousePrev.x = x;
	mousePrev.y = y;
}