Example #1
0
void calglMotionMouseWindow3D(int x, int y){
	GLfloat rot_x = 0.0f, rot_y = 0.0f;
	GLfloat transY = 0;

	if (leftPressed){
		x -= window3D->sub_width / 2;
		y -= window3D->sub_height / 2;

		rot_x = (float)(x - old_x) * mouseSensitivity;
		rot_y = -(float)(y - old_y) * mouseSensitivity;
		old_x = x;
		old_y = y;

		if (translationOn){
			return;
		}

		xRot[glutGetWindow() - 2] -= rot_y;
		yRot[glutGetWindow() - 2] += rot_x;

		/*window3D->models[glutGetWindow()-2]->modelView->xRotation -= rot_y;
		window3D->models[glutGetWindow()-2]->modelView->yRotation += rot_x;*/

		calglRedisplayAllWindow3D();
	}
	else if (rightPressed){
		y -= window3D->sub_height / 2;
		transY = -(y - oldestY) * mouseSensitivity;
		oldestY = y;

		zPos[glutGetWindow() - 2] += transY;

		calglRedisplayAllWindow3D();
	}
}
Example #2
0
void calglTimeFunc3D(int value){
	glutTimerFunc(calglGetGlobalSettings()->refreshTime, calglTimeFunc3D, value);

	if (!calglGetGlobalSettings()->fixedDisplay){
		calglRedisplayAllWindow3D();
	}
}
Example #3
0
void calglMouseWindow3D(int button, int state, int x, int y){
	if (button == 0){  // Left click
		leftPressed = CAL_TRUE;
		old_x = x - window3D->sub_width / 2;
		old_y = y-window3D->sub_height/2;

		//models3D[glutGetWindow()-2]->moving = CAL_TRUE;
	}
	else if (button == 2) { // Right click
		rightPressed = CAL_TRUE;
		oldestY = y-window3D->sub_height/2;

		//models3D[glutGetWindow()-2]->moving = CAL_TRUE;
	}

	if (state == GLUT_UP){
		leftPressed = CAL_FALSE;
		rightPressed = CAL_FALSE;

		//models3D[glutGetWindow()-2]->moving = CAL_FALSE;
	}
	else {
		calglRedisplayAllWindow3D();
	}
}
Example #4
0
void calglKeyboardEventWindow3D(unsigned char key, int x, int y){
	if(key=='t'){
		x -= window3D->sub_width/2;
		y -= window3D->sub_height/2;

		if(translationOn){
			yPos[activeSubWindow]+=-(y - key_old_y)*keyboardSensitivity;
			xPos[activeSubWindow]+=(x - key_old_x)*keyboardSensitivity;

			key_old_x = x;
			key_old_y = y;
		} else {
			activeSubWindow = glutGetWindow()-2;
			key_old_x = x;
			key_old_y = y;
			translationOn = CAL_TRUE;
		}
	}

	if(key=='h'){
		calglGetGlobalSettings()->onlyModel = !calglGetGlobalSettings()->onlyModel; 
	}

	if(key=='p'){
		if(window3D->models[0]->calUpdater){
			window3D->models[0]->calUpdater->active = !window3D->models[0]->calUpdater->active;
		}
	}

	calglRedisplayAllWindow3D();
}
Example #5
0
void calglMainLoop3D(int argc, char** argv) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

	glClearColor(0.5f, 0.5f, 1.0f, 1.0f);
	glShadeModel(GL_SMOOTH);
	glEnable(GL_DEPTH_TEST);

	calglCreateWindow3D(argc, argv, calglGetGlobalSettings(), models3D, noModels3D);

	calglPrintfInfoCommand3D();

	calglRedisplayAllWindow3D();

	glutMainLoop();

	calglDestroyWindow3D(window3D);
}
Example #6
0
void calglSpecialKeyboardEventWindow3D(int key, int x, int y){
	activeSubWindow = glutGetWindow() - 2;
	switch (key){
	case GLUT_KEY_UP: {
		yPos[activeSubWindow] += TRANSLATION_CONSTANT*keyboardSensitivity;
	}; break;
	case GLUT_KEY_RIGHT: {
		xPos[activeSubWindow] += TRANSLATION_CONSTANT*keyboardSensitivity;
	}; break;
	case GLUT_KEY_DOWN: {
		yPos[activeSubWindow] -= TRANSLATION_CONSTANT*keyboardSensitivity;
	}; break;
	case GLUT_KEY_LEFT: {
		xPos[activeSubWindow] -= TRANSLATION_CONSTANT*keyboardSensitivity;
	}; break;
	default: break;
	}

	calglRedisplayAllWindow3D();
}
Example #7
0
void calglKeyboardEventWindow3D(unsigned char key, int x, int y){
	int i = 0;

	if (key == 't'){
		x -= window3D->sub_width / 2;
		y -= window3D->sub_height / 2;

		if (translationOn){
			yPos[activeSubWindow] += -(y - key_old_y)*keyboardSensitivity;
			xPos[activeSubWindow] += (x - key_old_x)*keyboardSensitivity;

			key_old_x = x;
			key_old_y = y;
		}
		else {
			activeSubWindow = glutGetWindow() - 2;
			key_old_x = x;
			key_old_y = y;
			translationOn = CAL_TRUE;
		}
	}

	if (key == 'h'){
		calglGetGlobalSettings()->onlyModel = !calglGetGlobalSettings()->onlyModel;
	}

	if (key == 'x' || key == 's'){
		if (window3D->models[0]->calglRun){
			window3D->models[0]->calglRun->active = !window3D->models[0]->calglRun->active;
		}
	}

	if(key=='r') {
		for(i = 0; i < window3D->noModels; i++) {
			xPos[i] = 0.0f;	yPos[i] = 0.0f;	zPos[i] = 0.0f;
			xRot[i] = 90.0f; yRot[i] = 0.0f; zRot[i] = 0.0f;
		}
	}

	calglRedisplayAllWindow3D();
}
Example #8
0
void calglIdleFuncWindow3D(void){
	if (calglGetGlobalSettings()->fixedDisplay && window3D->models[0]->calglRun->step%calglGetGlobalSettings()->fixedStep == 0){
		calglRedisplayAllWindow3D();
	}
}