home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2608 / draw_hsi_xgl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-23  |  2.4 KB  |  128 lines

  1. #ifndef lint
  2. static    char    sccsid[] = "@(#)draw_hsi_xgl.c 1.2 92/05/28 SMI" ;
  3.     /* from draw_hsi_xgl.c 1.1 90/07/23 SMI */
  4. #endif
  5.  
  6. /*
  7.  * Copyright (c) 1986 by Sun Microsystems, Inc.
  8.  */
  9.  
  10. /*
  11.  * this file draws the hsi
  12.  */
  13.  
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <math.h>
  18. #include "graphics.h"
  19. #include "dstar.h"
  20.  
  21. extern    int    debug_level ;
  22.  
  23. #include "hsi.h"
  24.  
  25. static    int        initialized = 0 ;
  26. static    Xgl_pt_list    lon_pt[NLON] ;
  27. static    Xgl_pt_list    lat_pt[NLAT] ;
  28. static    Xgl_circle_list    circle ;
  29. static    Xgl_circle_f2d    circle_dat ;
  30. static    Xgl_bbox    my_bbox ;
  31. static    Xgl_trans    scale_trans ;
  32. static    Mat3d        scale_mat = {{1.,0.,0.,0.},{0.,1.,0.,0.},
  33.                      {0.,0.,-1.,0.},{0.,0.,0.,1.}} ;
  34.  
  35.  
  36. hsi_init()
  37. {
  38.     int    i ;
  39.     Xgl_pt_list    tmp ;
  40.  
  41.     my_bbox.bbox_type = XGL_BBOX_F3D ;
  42.     my_bbox.box.f3d.xmin = -1. ;
  43.     my_bbox.box.f3d.xmax = 1. ;
  44.     my_bbox.box.f3d.ymin = -1. ;
  45.     my_bbox.box.f3d.ymax = 1. ;
  46.     my_bbox.box.f3d.zmin = -1. ;
  47.     my_bbox.box.f3d.zmax = 1. ;
  48.  
  49.     for(i=0; i<NLON; ++i)
  50.     {
  51.       lon_pt[i].pt_type = XGL_PT_F3D ;
  52.       lon_pt[i].bbox = &my_bbox ;
  53.       lon_pt[i].num_pts = i%2 ? NLAT : NLAT+2 ;
  54.       lon_pt[i].pts.f3d = &lons[i][i%2] ;
  55.     }
  56.     tmp = lon_pt[1] ;
  57.     lon_pt[1] = lon_pt[NLON/2] ;
  58.     lon_pt[NLON/2] = tmp ;
  59.  
  60.     for(i=0; i<NLAT; ++i)
  61.     {
  62.       lat_pt[i].pt_type = XGL_PT_F3D ;
  63.       lat_pt[i].bbox = &my_bbox ; 
  64.       lat_pt[i].num_pts = NLON+1 ;
  65.       lat_pt[i].pts.f3d = lats[i] ;
  66.     }
  67.  
  68.     circle.num_circles = 1 ;
  69.     circle.type = XGL_MULTICIRCLE_F2D ;
  70.     circle.bbox = &my_bbox ;
  71.     circle.circles.f2d = &circle_dat ;
  72.     circle_dat.center.x = 0. ;
  73.     circle_dat.center.y = 0. ;
  74.     circle_dat.radius = 1 ;
  75.  
  76.     initialized = 1 ;
  77.  
  78.     scale_trans = xgl_transform_create(0) ;
  79.     xgl_transform_write(scale_trans, scale_mat) ;
  80. }
  81.  
  82.  
  83. draw_hsi(ctx)
  84. register Xgl_3d_ctx    ctx ;
  85. {
  86.     int    i,j ;
  87.     int    color ;
  88.     int    flag ;
  89.     Pt3d    p1,p2,p3,p4,p5 ;
  90. register Pt3d    *ptr ;
  91.     int    fit ;
  92.     Mat3d    matrix ;
  93.  
  94.     if( !initialized )
  95.       hsi_init() ;
  96.  
  97.     xgl_object_set(ctx,
  98.         XGL_CTX_LOCAL_MODEL_TRANS, scale_trans,
  99.         XGL_CTX_GLOBAL_MODEL_TRANS, ROT_MAT,
  100.         XGL_CTX_CLIP_PLANES, 0x3f,
  101.         0 ) ;
  102.  
  103.     Set_color(ctx,LGREY) ;
  104.  
  105. #ifdef    COMMENT
  106.     xgl_multicircle(ctx, &circle) ;
  107. #endif    COMMENT
  108.  
  109.     /* draw longitude lines */
  110.  
  111.     Set_color(ctx,RED) ;
  112.     xgl_multipolyline(ctx, NULL, 1, &lon_pt[0]) ;
  113.  
  114.     Set_color(ctx,GREEN) ;
  115.     xgl_multipolyline(ctx, NULL, 1, &lon_pt[1]) ;
  116.  
  117.     Set_color(ctx,LGREY) ;
  118.     xgl_multipolyline(ctx, NULL, NLON-2, &lon_pt[2]) ;
  119.  
  120.  
  121.     /* draw lattitude lines */
  122.  
  123.     xgl_multipolyline(ctx, NULL, (NLAT+1)/2, lat_pt) ;
  124.  
  125.     Set_color(ctx,RED) ;
  126.     xgl_multipolyline(ctx, NULL, NLAT-((NLAT+1)/2), &lat_pt[(NLAT+1)/2]) ;
  127. }
  128.