Esempio n. 1
0
void mouseListener(int button, int state, int x, int y){
	if (state == GLUT_DOWN){
		Vec3 point;
		switch(button){
		case GLUT_LEFT_BUTTON :
			point = Vec3(x, g_nWinHeight-y, 0);
			cout << "ADDED POINT AT " << point << endl;
			spline.addPointAt(spline.pointCount(), point);
			break;
		case GLUT_RIGHT_BUTTON: 
			int i = 0;
			for (i = 0; i < spline.segmentCount(); i++) {
				cout << "last" << spline.evaluate(i, 0.0) << endl;
				cout << "next" << spline.evaluate(i, 1.0) << endl;
			}
			break;
		}
	}
	glutPostRedisplay();
}
Esempio n. 2
0
void display() {
	setCamera();

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
	glClear(GL_COLOR_BUFFER_BIT);

	glDisable(GL_LIGHTING);
	glBegin(GL_LINES);
	glColor3f(0.5,0.5,0.5);

	for (int i = 0; i < spline.pointCount(); i++) {
		Vec3 p = spline.getPoint(i);
		glVertex4f(p.x,p.y,p.z,1.0);
		glVertex4f(0.0,-1.0,0.0,0.0);
	}

	for (int i = 0; i < (int) spline.segmentCount(); i++) {
		Vec3 last = spline.evaluate(i, 0.0);

		cout << i << "::" << last << endl;

		for(float t = 0.01; t < 1.0; t += 0.01){
			Vec3 next = spline.evaluate(i, t);

			glVertex3f(last.x, last.y, last.z);
			glVertex3f(next.x, next.y, next.z);
			last = next;
		}

		cout << i << "l ::" << last << endl;
	}


	glFinish();
	glutSwapBuffers();
	// glutPostRedisplay();

}