Wireframe Viewing System


Basic System

int main(int argc, char **argv)
{
  Scene *s;
  init_sdl();
  s = scene_read();
  plot_init("anim", s, TRUE);
  plot_scene(s);
  plot_close();
}  

void plot_scene(Scene *s)
{
  Object *o;
  plot_newscene(s);
  for (o = s->objs; o != NULL; o = o->next) {
    switch (o->type) {
    case V_POLYLIST: plot_plist(o->u.pols); break;
    case V_CSG_NODE: plot_csg(o->u.tcsg); break;
    case V_PRIM: plot_prim(o->u.prim); break;
    }
  }
  plot_showbuffer(0);
}

void init_sdl(void)
{
  lang_defun("scene", scene_parse);
  lang_defun("view", view_parse);

  lang_defun("polyobj", obj_parse);
  lang_defun("trilist", trilist_parse);

  lang_defun("primobj", obj_parse);
  lang_defun("sphere", sphere_parse);

  lang_defun("csgobj", obj_parse);
  lang_defun("csg_union", csg_union_parse);
  lang_defun("csg_inter", csg_inter_parse);
  lang_defun("csg_diff", csg_diff_parse);
  lang_defun("csg_prim", csg_prim_parse);

  lang_defun("group", group_parse);
  lang_defun("translate", translate_parse);
  lang_defun("scale", scale_parse);
  lang_defun("rotate", rotate_parse);
}


Input-Output

Input
scene{
        camera = view {
                from = {0, 0, -3}, to = {0, 0, 0}, roll = 0, fov = 60
                },
        object = group{
	        transform = { translate {v = {0, .1, 0}}},
                children = primobj{ shape = sphere{radius = .1}}
                }
};

Output
GP


Extension Options


Copyright © 1999 Luiz Velho