~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/stereo/thrd_view.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <tina/sys.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 #include <tina/tv.h>
 10 #include <tina/tvfuncs.h>
 11 #include <tina/draw.h>
 12 #include <tina/drawfuncs.h>
 13 #include <tina/toolsfuncs.h>
 14 
 15 static Bool geom_on = true;
 16 static Bool surface_on;
 17 static Bool ground_on;
 18 
 19 void    threed_geom_on(Bool on)
 20 {
 21     geom_on = on;
 22 }
 23 
 24 void    threed_surface_on(Bool on)
 25 {
 26     surface_on = on;
 27 }
 28 
 29 void    threed_ground_on(Bool on)
 30 {
 31     ground_on = on;
 32 }
 33 
 34 static Vec3 centre = {Vec3_id};
 35 static double radius = 1000.0;
 36 
 37 void    threed_fulldraw(Tv * tv)
 38 {
 39     List   *geom = threed_geom_get();
 40     List   *surface = threed_surface_get();
 41 
 42     if (geom_on && (geom != NULL))
 43         reclist_list_draw(tv, geom, (int)NULL, geom_col_draw, NULL);
 44     if (surface_on && (surface != NULL))
 45     {
 46         double  z;
 47 
 48         z = vec3_dot(centre, tv->ez3);
 49         tv_set_zbuff(tv, z - 5 * radius, z + 5 * radius);
 50 
 51         reclist_list_draw(tv, surface, CONE, zbuff_shade_cone, NULL);
 52     }
 53 }
 54 
 55 void    threed_tv_set_zbuff(Tv * tv)
 56 {
 57     double  z;
 58 
 59     z = vec3_dot(centre, tv->ez3);
 60     tv_set_zbuff(tv, z - 5 * radius, z + 5 * radius);
 61 }
 62 
 63 static void threed_init(Tv * tv)
 64 {
 65     Vec3    aim = {Vec3_id};
 66     Vec3    down = {Vec3_id};
 67     double   pscale;
 68     List   *geom = threed_geom_get();
 69 
 70     (void) tv_set_zoomlevel(tv, ZOOM3);
 71 
 72     if (geom == NULL)
 73         return;
 74 
 75     geom_hull_get(geom, &centre, &radius);
 76     pscale = 3.0;
 77     aim = vec3_ez();
 78     down = vec3_ey();
 79     tv_camera3(tv, centre, radius, pscale, aim, down);
 80 }
 81 
 82 void    threed_skeldraw(Tv * tv)
 83 {
 84     List   *geom = threed_geom_get();
 85     int     old_sample = curve_draw_sample_get();
 86 
 87     if (tv == NULL)
 88         return;
 89 
 90     curve_draw_sample_set(MAX(tv->height, tv->width) / 10);
 91     if (geom_on && (geom != NULL))
 92         reclist_list_draw(tv, geom, (int)NULL, geom_draw, NULL);
 93     curve_draw_sample_set(old_sample);
 94 }
 95 
 96 Tv     *threed_tv_make(void)
 97 {
 98     Tv     *tv3d = NULL;
 99 
100     centre = vec3(0.0, 0.0, 0.0);
101 
102     tv3d = tv_create("threed");
103     (void) tv_set_fulldraw(tv3d, threed_fulldraw);
104     (void) tv_set_skeldraw(tv3d, threed_skeldraw);
105     tv_set_init(tv3d, threed_init);
106     tv_init(tv3d);
107     return (tv3d);
108 }
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.