home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / graphic / csg_rt / surf.c < prev    next >
C/C++ Source or Header  |  1993-01-12  |  3KB  |  160 lines

  1. /*
  2.  
  3. SURF.C  Surface datatype
  4.  
  5. */
  6.  
  7. /*...sincludes:0:*/
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <stddef.h>
  11. #include <malloc.h>
  12. #include <memory.h>
  13. #include <math.h>
  14. #include "standard.h"
  15. #include "rt.h"
  16. #include "fio.h"
  17. #include "tex.h"
  18. #include "vector.h"
  19. #include "rgbvec.h"
  20. #include "col.h"
  21. #define    _SURF_
  22. #include "surf.h"
  23.  
  24. /*...vrt\46\h:0:*/
  25. /*...vfio\46\h:0:*/
  26. /*...vtex\46\h:0:*/
  27. /*...vvector\46\h:0:*/
  28. /*...vrgbvec\46\h:0:*/
  29. /*...vcol\46\h:0:*/
  30. /*...vsurf\46\h:0:*/
  31. /*...e*/
  32.  
  33. /*...screate_surf:0:*/
  34. SURF    *create_surf(
  35.     double    ka, double kd, double ks, double kt,
  36.     COL    *od, COL *os,
  37.     double    phong,
  38.     double    rinx
  39.     )
  40.     {
  41.     SURF    *surf;
  42.  
  43.     if ( (surf = malloc(sizeof(SURF))) == NULL )
  44.         return ( NULL );
  45.  
  46.     surf -> ka    = ka;
  47.     surf -> kd    = kd;
  48.     surf -> ks    = ks;
  49.     surf -> kt    = kt;
  50.     surf -> od    = od;
  51.     surf -> os    = os;
  52.     surf -> phong = phong;
  53.     surf -> rinx  = rinx;
  54.     return ( surf );
  55.     }
  56. /*...e*/
  57. /*...scopy_surf:0:*/
  58. SURF    *copy_surf(SURF *surf)
  59.     {
  60.     SURF    *copy;
  61.  
  62.     if ( (copy = malloc(sizeof(SURF))) == NULL )
  63.         return ( NULL );
  64.  
  65.     if ( (copy -> od = copy_col(surf -> od)) == NULL )
  66.         {
  67.         free(copy);
  68.         return ( NULL );
  69.         }
  70.  
  71.     if ( (copy -> os = copy_col(surf -> os)) == NULL )
  72.         {
  73.         destroy_col(copy -> od);
  74.         free(copy);
  75.         return ( NULL );
  76.         }
  77.  
  78.     copy -> ka    = surf -> ka;
  79.     copy -> kd    = surf -> kd;
  80.     copy -> ks    = surf -> ks;
  81.     copy -> kt    = surf -> kt;
  82.     copy -> phong = surf -> phong;
  83.     copy -> rinx  = surf -> rinx;
  84.  
  85.     return ( copy );
  86.     }
  87. /*...e*/
  88. /*...sdestroy_surf:0:*/
  89. void    destroy_surf(SURF *surf)
  90.     {
  91.     destroy_col(surf -> od);
  92.     destroy_col(surf -> os);
  93.     free(surf);
  94.     }
  95. /*...e*/
  96.  
  97. /*...strans_x_surf:0:*/
  98. void    trans_x_surf(SURF *surf, double t)
  99.     {
  100.     trans_x_col(surf -> od, t);
  101.     trans_x_col(surf -> os, t);
  102.     }
  103. /*...e*/
  104. /*...strans_y_surf:0:*/
  105. void    trans_y_surf(SURF *surf, double t)
  106.     {
  107.     trans_y_col(surf -> od, t);
  108.     trans_y_col(surf -> os, t);
  109.     }
  110. /*...e*/
  111. /*...strans_z_surf:0:*/
  112. void    trans_z_surf(SURF *surf, double t)
  113.     {
  114.     trans_z_col(surf -> od, t);
  115.     trans_z_col(surf -> os, t);
  116.     }
  117. /*...e*/
  118. /*...sscale_x_surf:0:*/
  119. void    scale_x_surf(SURF *surf, double factor)
  120.     {
  121.     scale_x_col(surf -> od, factor);
  122.     scale_x_col(surf -> os, factor);
  123.     }
  124. /*...e*/
  125. /*...sscale_y_surf:0:*/
  126. void    scale_y_surf(SURF *surf, double factor)
  127.     {
  128.     scale_y_col(surf -> od, factor);
  129.     scale_y_col(surf -> os, factor);
  130.     }
  131. /*...e*/
  132. /*...sscale_z_surf:0:*/
  133. void    scale_z_surf(SURF *surf, double factor)
  134.     {
  135.     scale_z_col(surf -> od, factor);
  136.     scale_z_col(surf -> os, factor);
  137.     }
  138. /*...e*/
  139. /*...srot_x_surf:0:*/
  140. void    rot_x_surf(SURF *surf, double angle)
  141.     {
  142.     rot_x_col(surf -> od, angle);
  143.     rot_x_col(surf -> os, angle);
  144.     }
  145. /*...e*/
  146. /*...srot_y_surf:0:*/
  147. void    rot_y_surf(SURF *surf, double angle)
  148.     {
  149.     rot_y_col(surf -> od, angle);
  150.     rot_y_col(surf -> os, angle);
  151.     }
  152. /*...e*/
  153. /*...srot_z_surf:0:*/
  154. void    rot_z_surf(SURF *surf, double angle)
  155.     {
  156.     rot_z_col(surf -> od, angle);
  157.     rot_z_col(surf -> os, angle);
  158.     }
  159. /*...e*/
  160.