Ejemplo n.º 1
0
void			cylinder_inter(t_inter *inter, void *obj, t_ray ray,
								t_light *light)
{
	t_cylinder	cylinder;
	double		dist;
	t_ray		temp;

	cylinder = *((t_cylinder *)obj);
	temp = ray;
	change_frame(&ray, cylinder.inv, vector_inverse(cylinder.trans));
	dist = cylinder_distance(ray, cylinder);
	if (dist > EPS && (inter->dist == NULL || dist < *(inter->dist) - EPS))
	{
		if (inter->dist == NULL)
			inter->dist = malloc(sizeof(double));
		free_light_ray_list(inter);
		*(inter->dist) = dist;
		inter->pos = calculate_position(ray, dist);
		inter->normal = cylinder_normal(inter->pos, cylinder);
		if (vector_dot_product(inter->normal, ray.dir) > 0)
			inter->normal = vector_inverse(inter->normal);
		op_inv(cylinder.trans, cylinder.rot, &(inter->normal), &(inter->pos));
		inter->refl = calculate_reflection(temp, inter->normal);
		inter->color = cylinder.color;
		create_light_ray_list(inter, light, inter->pos);
		inter->refl_val = cylinder.refl;
	}
}
Ejemplo n.º 2
0
int				cylinder_shadow(void *obj, t_ray ray, double light_dist)
{
	t_cylinder	cylinder;
	double		cylinder_dist;

	cylinder = *((t_cylinder *)obj);
	change_frame(&ray, cylinder.inv, vector_inverse(cylinder.trans));
	cylinder_dist = cylinder_distance(ray, cylinder);
	if (cylinder_dist < EPS || cylinder_dist > light_dist - EPS)
		return (0);
	return (1);
}
Ejemplo n.º 3
0
void test_proc(Stimulus *st)
{
    Locator *pos = &st->pos;
    int imw,imh,nreps,i,x,y;
    struct timeval start,stop;
    float timediff();
    float angle = 900;
    
    for(i = 0; i < 30; i++)
    {
        calc_stimulus(st,1);
        paint_stimulus(st,1);
        glRotatef(angle,0.0,0.0,1.0);
        paint_stimulus(st);
        glRotatef(-angle,0.0,0.0,1.0);
        change_frame();
        increment_stimulus(st, pos);
    }
}
Ejemplo n.º 4
0
GameCanvas::GameCanvas(QWidget *parent) : QWidget(parent)
{
    // make sure game is focused
    setFocusPolicy(Qt::StrongFocus);

    // get game logic event loop to work
    startTimer(1000/60);

    // load assets
    this->load_assets();

    // initialize animation timer
    animation_timer = new QTimer(this);
    connect(animation_timer, SIGNAL(timeout()), this, SLOT(change_frame()));
    animation_timer->start(animation_speed);

    app = new game(this);

    connect(app, SIGNAL(add_person(QPoint,QString)), this, SLOT(add_person(QPoint,QString)));
    connect(app, SIGNAL(remove_person(QPoint)), this, SLOT(remove_person(QPoint)));
}
Ejemplo n.º 5
0
void
ScenegraphAggregator::signal_frame (int frame)
{
    if (m_frames.contains (frame))
        change_frame (frame);
}