home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / MODEL / VERCONV.C < prev    next >
C/C++ Source or Header  |  1995-06-30  |  2KB  |  78 lines

  1. /*
  2.  *    頂点変換
  3.  *
  4.  *        Copyright T.Kobayashi    1994.8.9
  5.  */
  6. #include "matrix.h"
  7. #include "vector.h"
  8. #include "matclass.h"
  9. #include "strclass.h"
  10. #include "ml.h"
  11.  
  12. #include "poly.h"
  13. #include "verconv.h"
  14.  
  15. int        ConvVertex( xp, yp, zp, vxp, vyp, vzp, up, vp, buf )
  16. int        *xp, *yp, *zp, *vxp, *vyp, *vzp, *up, *vp ;
  17. DataStruct    *buf ;
  18. {
  19.     VertexClass    *ver ;
  20.     VectorClass    *vec ;
  21.  
  22.     if ( buf[0].type == TYPE_OBJECT )
  23.     {
  24.         if ( ObjectCheck( &buf[0], VertexClassID ) )
  25.         {
  26.             ver = (VertexClass*)buf[0].od.ptr ;
  27.             *xp = ver->ver.x ;
  28.             *yp = ver->ver.y ;
  29.             *zp = ver->ver.z ;
  30.             if ( ver->dtype & POLY_SHADE )
  31.             {
  32.                 *vxp = ver->ver.vx ;
  33.                 *vyp = ver->ver.vy ;
  34.                 *vzp = ver->ver.vz ;
  35.             }
  36.             else
  37.                 *vxp = *vyp = *vzp = 0 ;
  38.             if ( ver->dtype & POLY_UV )
  39.             {
  40.                 *up = ver->ver.u ;
  41.                 *vp = ver->ver.v ;
  42.             }
  43.             else
  44.                 *up = *vp = 0 ;
  45.         }
  46.         else if ( ObjectCheck( &buf[0], VectorClassID ) )
  47.         {
  48.             vec = (VectorClass*)buf[0].od.ptr ;
  49.             *xp = vec->vec.x ;
  50.             *yp = vec->vec.y ;
  51.             *zp = vec->vec.z ;
  52.             *vxp = *vyp = *vzp = *up = *vp = 0 ;
  53.         }
  54.         else
  55.             return FALSE ;
  56.     }
  57.     else
  58.     {
  59.         *xp = ToInt( &buf[0] );
  60.         *yp = ToInt( &buf[1] );
  61.         *zp = ToInt( &buf[2] );
  62.         *vxp = *vyp = *vzp = *up = *vp = 0 ;
  63.     }
  64.     return TRUE ;
  65. }
  66.  
  67. int        ToInt( buf )
  68. DataStruct    *buf ;
  69. {
  70.     if ( buf->type == TYPE_INT )
  71.         return buf->id.i ;
  72.     else if ( buf->type == TYPE_REAL )
  73.         return (int)buf->rd.r ;
  74.     else
  75.         ExecError( "引数の型が違います。" );
  76.     return -1 ;
  77. }
  78.