int csg_display_sphere(t_rt *s, t_object *obj) { t_sphere *shape; s->hit.limited = 0; shape = (t_sphere *)obj->datas; inter_sphere(s, shape); if (get_simple_inter(s, s->ray.vct, &s->ray.new_eye) == 0) { end_rotation(&s->rotation, s->ray.vct, &shape->rot); end_rotation(&s->rotation, &s->hit.simple_inter1, &shape->rot); get_norm_sphere(s, &s->hit.norm1); rotation(&s->rotation, &s->hit.simple_inter1, &shape->rot); shape->simple_inter1 = s->hit.simple_inter1; shape->simple_inter2 = s->hit.simple_inter2; shape->k1 = s->hit.k1; shape->k2 = s->hit.k2; shape->norm1 = s->hit.norm1; s->hit.name = obj->name; if ((fill_inter_list_sphere(s, obj)) == -1) return (-1); } else end_rotation(&s->rotation, s->ray.vct, &shape->rot); return (0); }
t_obj *all_inter(t_env *e) { t_obj *my_obj; t_obj *obj; double value; obj = NULL; my_obj = e->obj; value = e->value; while (my_obj) { if (my_obj->type == 0) value = inter_plan(my_obj, e); else if (my_obj->type == 1) value = inter_sphere(my_obj, e); else if (my_obj->type == 3) value = inter_cyl(my_obj, e); else if (my_obj->type == 2) value = inter_cone(my_obj, e); if (value > 0.0001 && value < e->value) { obj = my_obj; e->value = value; } my_obj = my_obj->next; } return (obj); }
int get_pixel_color(t_pos xyz, t_win *mw) { int i; int color; double k; double a; double cos; i = 0; k = 1000000; color = 0x000000; while (mw->tab_obj[i].obj != 0) { mw->tab_obj[i].obj == 1 ? a = inter_sphere(xyz, *mw, i) : 0; mw->tab_obj[i].obj == 2 ? a = inter_plan(xyz, *mw, i) : 0; mw->tab_obj[i].obj == 3 ? a = inter_cone(xyz, *mw, i, &cos) : 0; mw->tab_obj[i].obj == 4 ? a = inter_cylindre(xyz, *mw, i) : 0; mw->tab_obj[i].obj == 5 ? a = inter_cube(xyz, *mw, i) : 0; if (a < k && a > 0.000001) { k = a; color = mw->tab_obj[i].color; } i++; } color = change_color(color, xyz, *mw, k); return (color); }
void spot_calc(t_scene *sc, t_object *obj) { if (obj->type == SPHERE) inter_sphere(sc); if (obj->type == CONE) inter_cone(sc); if (obj->type == PLAN) inter_plan(sc); if (obj->type == CYLIND) inter_cylindre(sc); }
int calc(t_pixel *pixel, t_rt *rt) { rt->vx = 100; rt->vy = 200 - pixel->x; rt->vz = 200 - pixel->y; rt->xoeil = - 300; rt->zoeil = 100; rt->yoeil = 0; inter_sphere(pixel, rt); inter_plan(pixel, rt); // inter_cylindre(pixel, rt); //inter_cone(pixel, rt); }
double calc_shad(t_objet p, t_utils l, int type) { double k; k = -1.0; if (type == PLAN) k = inter_plan(l, &p); else if (type == SPHERE) k = inter_sphere(l, &p); else if (type == CYLINDRE) k = inter_cylindre(l, &p); else if (type == CONE) k = inter_cone(l, &p); else if (type == PARABOLOIDE) k = inter_paraboloide(l, &p); else if (type == HYPERBOLOIDE) k = inter_hyperboloide(l, &p); return (k); }
float get_inter(t_eye *eye, t_3dpoint *vec, t_obj *obj) { t_3dpoint tmp_eye; t_3dpoint pvec; pvec.x = vec->x; pvec.y = vec->y; pvec.z = vec->z; real_position(&tmp_eye, &pvec, eye, obj); if (obj->type == O_SPHERE) return (inter_sphere(&tmp_eye, &pvec, obj->obj.sphere.radius)); if (obj->type == O_PLANE) return (inter_plane(&tmp_eye, &pvec)); if (obj->type == O_CONE) return (inter_cone(obj, &tmp_eye, &pvec)); if (obj->type == O_CYLINDER) return (inter_cylinder(obj, &tmp_eye, &pvec)); return (0); }
t_obj *all_inter(t_env *e) { t_obj *my_obj; t_obj *obj; double value; double nb; nb = 0; obj = NULL; my_obj = e->obj; value = e->value; while (my_obj) { if (my_obj->type == 0) value = inter_plan(my_obj, e); else if (my_obj->type == 1)// && e->type_actual != 1) value = inter_sphere(my_obj, e); else if (my_obj->type == 3) value = inter_cyl(my_obj, e); else if (my_obj->type == 2) value = inter_cone(my_obj, e); if (value > 0.0001 && value < e->value) { if(e->myetat == 1 && e->myv == nb) { } else { obj = my_obj; e->value = value; if(e->myetat == 0) e->myv = nb; } } nb++; my_obj = my_obj->next; } return (obj); }