home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GRAPHICS / rayshade.lzh / datatypes.h < prev    next >
Text File  |  1990-05-08  |  4KB  |  135 lines

  1. /*
  2.  * datatypes.h
  3.  *
  4.  * Copyright (C) 1989, Craig E. Kolb
  5.  *
  6.  * This software may be freely copied, modified, and redistributed,
  7.  * provided that this copyright notice is preserved on all copies.
  8.  *
  9.  * There is no warranty or other guarantee of fitness for this software,
  10.  * it is provided solely .  Bug reports or fixes may be sent
  11.  * to the author, who may or may not act on them as he desires.
  12.  *
  13.  * You may not include this software in a program or other software product
  14.  * without supplying the source, or without informing the end-user that the
  15.  * source is available for no extra charge.
  16.  *
  17.  * If you modify this software, you should include a notice giving the
  18.  * name of the person performing the modification, the date of modification,
  19.  * and the reason for such modification.
  20.  *
  21.  * $Id: datatypes.h,v 3.0.1.1 89/11/16 20:41:39 craig Exp Locker: craig $
  22.  *
  23.  * $Log:    datatypes.h,v $
  24.  * Revision 3.0.1.1  89/11/16  20:41:39  craig
  25.  * patch1: Moved atmospheric declarations to atmosphere.h.
  26.  * 
  27.  * Revision 3.0  89/10/27  02:05:49  craig
  28.  * Baseline for first official release.
  29.  * 
  30.  */
  31.  
  32. #ifdef NOVOID
  33. typedef int void;
  34. #endif
  35.  
  36. typedef struct {
  37.     double u, v;            /* 2D point */
  38. } Vec2d;
  39.  
  40. typedef struct Vector {
  41.     double x, y, z;            /* 3D point */
  42. } Vector;
  43.  
  44. typedef struct Ray {
  45.     Vector pos;            /* Origin */
  46.     Vector     dir;            /* Direction */
  47.     char shadow;
  48.     struct SurfaceList *media;    /* Medium ray is passing through */
  49. } Ray;
  50.  
  51. typedef struct Color {
  52.     double r, g, b;            /* Red, green, blue. */
  53. } Color;
  54.  
  55. typedef struct {
  56.     double matrix[3][3];        /* Rotation matrix */
  57.     Vector translate;        /* Translation */
  58. } TransInfo;
  59.  
  60. typedef struct Trans {
  61.     TransInfo world2obj,    /* worldspace --> object space */
  62.           obj2world;    /* object space --> world space */
  63. } Trans;
  64.  
  65. typedef struct {
  66.     struct ObjList *list;        /* List of prims/objs. in object */
  67.     struct ObjList *unbounded;    /* List of unbounded prims. */
  68.     double bounds[2][3];        /* Bounding box of object */
  69. } List;
  70.  
  71. typedef struct {
  72.     short xsize, ysize, zsize;    /* # of voxels along each axis */
  73.     double bounds[2][3];        /* bounding box */
  74.     double voxsize[3];        /* size of a voxel */
  75.     struct ObjList ****cells;    /* Voxels */
  76.     struct ObjList *unbounded;    /* Unbounded objects */
  77. } Grid;
  78.  
  79. /*
  80.  * Surface definition.
  81.  */
  82. typedef struct Surface {
  83.     char *name;            /* Name */
  84.     struct Color amb;        /* Ambient color */
  85.     struct Color diff;        /* Diffuse color */
  86.     struct Color spec;        /* Specular color */
  87.     double coef;            /* Phong shading coef. */
  88.     double refl;            /* Reflectivity (0-1) */
  89.     double transp;            /* Transparency (0-1) */
  90.     double kref;            /* Index of refraction */
  91.     double translucency;        /* translucency (0-1) */
  92.     double stcoef;            /* Phong coef. for transmitted light */
  93. } Surface;
  94.  
  95. typedef struct SurfaceList {
  96.     Surface *surf;
  97.     struct SurfaceList *next;
  98. } SurfaceList;
  99.  
  100. typedef struct ObjList {
  101.     struct Object *data;        /* Pointer to object data */
  102.     struct ObjList *next;        /* Next in list */
  103. } ObjList;
  104.  
  105. typedef struct PointList {
  106.     Vector vec;            /* Vector data */
  107.     struct PointList *next;        /* Next in list */
  108. } PointList;
  109.  
  110. /*
  111.  * Data about point of intersection.
  112.  * (May be modified by texture mapping.)
  113.  */
  114. typedef struct HitInfo {
  115.     Vector    pos,        /* Location of intersection */
  116.         norm;        /* Normal to surface at int. point */
  117.     struct Primitive *prim; /* Pointer to primitive hit. */
  118.     struct Surface surf;    /* Surface to be used. */
  119.     TransInfo *totaltrans;
  120. } HitInfo;
  121.  
  122. /*
  123.  * General-purpose texture structure.  The (bad) idea is to
  124.  * have one structure which every texturing function will use.
  125.  */
  126. typedef struct Texture {
  127.     char type;        /* Texture type */
  128.     Surface *surf1;        /* Alternate surface */
  129.     double size;        /* Scale/size factor */
  130.     double *args;        /* Random arguments. */
  131.     Color *colormap;    /* Colormap */
  132.     Trans *trans;        /* Transformation matrices. */
  133.     struct Texture *next;    /* Pointer to next texture. */
  134. } Texture;
  135.