Пример #1
0
int render(void)
{
	double ws = config.worldSize;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

/*	view_angle += 0.01;*/

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(0, 0, -ws*2.5);
	glRotatef(view_angle, 0, 1, 0);

	/* Constituents of the monomers */
	glLightfv(GL_LIGHT0, GL_DIFFUSE, red);
	renderParticles(config.numMonomers, world.Ss);

	glLightfv(GL_LIGHT0, GL_DIFFUSE, green);
	renderParticles(config.numMonomers, world.As);

	glLightfv(GL_LIGHT0, GL_DIFFUSE, blue);
	renderParticles(config.numMonomers, world.Ps);

	/* Connections */
	glLightfv(GL_LIGHT0, GL_DIFFUSE, gray);
	drawCilinder(&world.Ps[0].pos, &world.Ss[0].pos,
			CILINDER_FACES, CILINDER_RADIUS);
	drawCilinder(&world.Ss[0].pos, &world.As[0].pos,
			CILINDER_FACES, CILINDER_RADIUS);
		for(int i = 1; i < config.numMonomers; i++) {
			drawCilinder(&world.Ps[i].pos, &world.Ss[i].pos,
					CILINDER_FACES, CILINDER_RADIUS);
			drawCilinder(&world.Ss[i].pos, &world.As[i].pos,
					CILINDER_FACES, CILINDER_RADIUS);
			drawCilinder(&world.Ss[i].pos, &world.Ps[i-1].pos,
					CILINDER_FACES, CILINDER_RADIUS);
		}

#if DRAWFORCES
	/* Forces */
	glColor3f(0.8, 0.0, 0.0);
	glBegin(GL_LINES);
		for(int i = 0; i < 3 * config.numMonomers; i++) {
			Vec3 tmp;
			add(&world.all[i].pos, &world.all[i].F, &tmp);
			drawLine(&world.all[i].pos, &tmp);
		}
	glEnd();
#endif

	SDL_GL_SwapBuffers();

	return 0;
}
Пример #2
0
static void renderConnection(Particle *p1, Particle *p2, RenderConf *rc)
{
	if (distance(p1->pos, p2->pos) > world.worldSize / 2)
		return; /* To avoid periodic boundary clutter */
	drawCilinder(p1->pos, p2->pos, CILINDER_FACES,
			rc->radius / CILINDER_RADIUS_DIVISOR);
}