Esempio n. 1
0
void createPointCloud()
{
	for(int i = -25; i <= 25; i++)
	{
		for(int j = -25; j <= 25; j++)
		{
			ColorPoint p(i/25.0,j/25.0);
			p.color = myTree.evaluatePoint(p);

			glBegin(GL_POINTS);
				switch(p.color)
				{
					case RED:
						glColor4f(1.0f,0.0f,0.0f,0.2f); break;
					case BLUE:
						glColor4f(0.0f,0.0f,1.0f,0.2f); break;
					case GREEN:
						glColor4f(0.0f,1.0f,0.0f,0.2f); break;
					default:
						glColor4f(0.0f,0.0f,0.0f,0.2f); break;
				}
				glVertex3f(p.x,p.y,0.0f);

			glEnd();
			glFlush();
			glutSwapBuffers();
		}
	}

}
Esempio n. 2
0
void mouseClick(int button, int state, int x, int y)
{
	if(state == GLUT_UP)
	{
		ColorPoint point;

		point.x = map(x,0,winx,-1000,1000)/1000.0;
		point.y = map(y,0,winy,1000,-1000)/1000.0;

		cout << "x = " << point.x << endl;
		cout << "y = " << point.y << endl;


		glBegin(GL_POINTS);
			glColor3f(0.0f,0.0f,0.0f);
			glVertex3f(point.x,point.y,0.0f);
		glEnd();

		glFlush();
		glutSwapBuffers();

		//usleep(500000);
		//cout << "Aqui 1" << endl;

		Color color = myTree.evaluatePoint(point);

		//cout << "Aqui SAIDA" << endl << endl;

		glBegin(GL_POINTS);
			switch(color)
			{
				case RED:
					glColor3f(1.0f,0.0f,0.0f); break;
				case BLUE:
					glColor3f(0.0f,0.0f,1.0f); break;
				case GREEN:
					glColor3f(0.0f,1.0f,0.0f); break;
				default:
					glColor3f(0.0f,0.0f,0.0f); break;
			}
			glVertex3f(point.x,point.y,0.0f);

		glEnd();
		glFlush();
		glutSwapBuffers();

	}
	//display();
}