home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / D3DRMDEF.H < prev    next >
C/C++ Source or Header  |  1997-01-16  |  14KB  |  403 lines

  1. /*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1995-1996 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:       d3drm.h
  6.  *  Content:    Direct3DRM include file
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #ifndef __D3DRMDEFS_H__
  11. #define __D3DRMDEFS_H__
  12.  
  13. #include <stddef.h>
  14. #include "d3dtypes.h"
  15.  
  16. #ifdef WIN32
  17. #define D3DRMAPI  __stdcall
  18. #else
  19. #define D3DRMAPI
  20. #endif
  21.  
  22. #if defined(__cplusplus)
  23. extern "C" {
  24. #endif
  25.  
  26. #ifndef TRUE
  27. #define FALSE 0
  28. #define TRUE 1
  29. #endif
  30.  
  31. typedef struct _D3DRMVECTOR4D
  32. {   D3DVALUE x, y, z, w;
  33. } D3DRMVECTOR4D, *LPD3DRMVECTOR4D;
  34.  
  35. typedef D3DVALUE D3DRMMATRIX4D[4][4];
  36.  
  37. typedef struct _D3DRMQUATERNION
  38. {   D3DVALUE s;
  39.     D3DVECTOR v;
  40. } D3DRMQUATERNION, *LPD3DRMQUATERNION;
  41.  
  42. typedef struct _D3DRMBOX
  43. {   D3DVECTOR min, max;
  44. } D3DRMBOX, *LPD3DRMBOX;
  45.  
  46. typedef void (*D3DRMWRAPCALLBACK)
  47.     (LPD3DVECTOR, int* u, int* v, LPD3DVECTOR a, LPD3DVECTOR b, LPVOID);
  48.  
  49. typedef enum _D3DRMLIGHTTYPE
  50. {   D3DRMLIGHT_AMBIENT,
  51.     D3DRMLIGHT_POINT,
  52.     D3DRMLIGHT_SPOT,
  53.     D3DRMLIGHT_DIRECTIONAL,
  54.     D3DRMLIGHT_PARALLELPOINT
  55. } D3DRMLIGHTTYPE, *LPD3DRMLIGHTTYPE;
  56.  
  57. typedef enum _D3DRMSHADEMODE {
  58.     D3DRMSHADE_FLAT     = 0,
  59.     D3DRMSHADE_GOURAUD  = 1,
  60.     D3DRMSHADE_PHONG    = 2,
  61.  
  62.     D3DRMSHADE_MASK     = 7,
  63.     D3DRMSHADE_MAX      = 8
  64. } D3DRMSHADEMODE, *LPD3DRMSHADEMODE;
  65.  
  66. typedef enum _D3DRMLIGHTMODE {
  67.     D3DRMLIGHT_OFF      = 0 * D3DRMSHADE_MAX,
  68.     D3DRMLIGHT_ON       = 1 * D3DRMSHADE_MAX,
  69.  
  70.     D3DRMLIGHT_MASK     = 7 * D3DRMSHADE_MAX,
  71.     D3DRMLIGHT_MAX      = 8 * D3DRMSHADE_MAX
  72. } D3DRMLIGHTMODE, *LPD3DRMLIGHTMODE;
  73.  
  74. typedef enum _D3DRMFILLMODE {
  75.     D3DRMFILL_POINTS    = 0 * D3DRMLIGHT_MAX,
  76.     D3DRMFILL_WIREFRAME = 1 * D3DRMLIGHT_MAX,
  77.     D3DRMFILL_SOLID     = 2 * D3DRMLIGHT_MAX,
  78.  
  79.     D3DRMFILL_MASK      = 7 * D3DRMLIGHT_MAX,
  80.     D3DRMFILL_MAX       = 8 * D3DRMLIGHT_MAX
  81. } D3DRMFILLMODE, *LPD3DRMFILLMODE;
  82.  
  83. typedef DWORD D3DRMRENDERQUALITY, *LPD3DRMRENDERQUALITY;
  84.  
  85. #define D3DRMRENDER_WIREFRAME   (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_WIREFRAME)
  86. #define D3DRMRENDER_UNLITFLAT   (D3DRMSHADE_FLAT+D3DRMLIGHT_OFF+D3DRMFILL_SOLID)
  87. #define D3DRMRENDER_FLAT        (D3DRMSHADE_FLAT+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  88. #define D3DRMRENDER_GOURAUD     (D3DRMSHADE_GOURAUD+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  89. #define D3DRMRENDER_PHONG       (D3DRMSHADE_PHONG+D3DRMLIGHT_ON+D3DRMFILL_SOLID)
  90.  
  91. typedef enum _D3DRMTEXTUREQUALITY
  92. {   D3DRMTEXTURE_NEAREST,               /* choose nearest texel */
  93.     D3DRMTEXTURE_LINEAR,                /* interpolate 4 texels */
  94.     D3DRMTEXTURE_MIPNEAREST,            /* nearest texel in nearest mipmap  */
  95.     D3DRMTEXTURE_MIPLINEAR,             /* interpolate 2 texels from 2 mipmaps */
  96.     D3DRMTEXTURE_LINEARMIPNEAREST,      /* interpolate 4 texels in nearest mipmap */
  97.     D3DRMTEXTURE_LINEARMIPLINEAR        /* interpolate 8 texels from 2 mipmaps */
  98. } D3DRMTEXTUREQUALITY, *LPD3DRMTEXTUREQUALITY;
  99.  
  100. typedef enum _D3DRMCOMBINETYPE
  101. {   D3DRMCOMBINE_REPLACE,
  102.     D3DRMCOMBINE_BEFORE,
  103.     D3DRMCOMBINE_AFTER
  104. } D3DRMCOMBINETYPE, *LPD3DRMCOMBINETYPE;
  105.  
  106. typedef D3DCOLORMODEL D3DRMCOLORMODEL, *LPD3DRMCOLORMODEL;
  107.  
  108. typedef enum _D3DRMPALETTEFLAGS
  109. {   D3DRMPALETTE_FREE,                  /* renderer may use this entry freely */
  110.     D3DRMPALETTE_READONLY,              /* fixed but may be used by renderer */
  111.     D3DRMPALETTE_RESERVED               /* may not be used by renderer */
  112. } D3DRMPALETTEFLAGS, *LPD3DRMPALETTEFLAGS;
  113.  
  114. typedef struct _D3DRMPALETTEENTRY
  115. {   unsigned char red;          /* 0 .. 255 */
  116.     unsigned char green;        /* 0 .. 255 */
  117.     unsigned char blue;         /* 0 .. 255 */
  118.     unsigned char flags;        /* one of D3DRMPALETTEFLAGS */
  119. } D3DRMPALETTEENTRY, *LPD3DRMPALETTEENTRY;
  120.  
  121. typedef struct _D3DRMIMAGE
  122. {   int width, height;          /* width and height in pixels */
  123.     int aspectx, aspecty;       /* aspect ratio for non-square pixels */
  124.     int depth;                  /* bits per pixel */
  125.     int rgb;                    /* if false, pixels are indices into a
  126.                                    palette otherwise, pixels encode
  127.                                    RGB values. */
  128.     int bytes_per_line;         /* number of bytes of memory for a
  129.                                    scanline. This must be a multiple
  130.                                    of 4. */
  131.     void* buffer1;              /* memory to render into (first buffer). */
  132.     void* buffer2;              /* second rendering buffer for double
  133.                                    buffering, set to NULL for single
  134.                                    buffering. */
  135.     unsigned long red_mask;
  136.     unsigned long green_mask;
  137.     unsigned long blue_mask;
  138.     unsigned long alpha_mask;   /* if rgb is true, these are masks for
  139.                                    the red, green and blue parts of a
  140.                                    pixel.  Otherwise, these are masks
  141.                                    for the significant bits of the
  142.                                    red, green and blue elements in the
  143.                                    palette.  For instance, most SVGA
  144.                                    displays use 64 intensities of red,
  145.                                    green and blue, so the masks should
  146.                                    all be set to 0xfc. */
  147.     int palette_size;           /* number of entries in palette */
  148.     D3DRMPALETTEENTRY* palette; /* description of the palette (only if
  149.                                    rgb is false).  Must be (1<<depth)
  150.                                    elements. */
  151. } D3DRMIMAGE, *LPD3DRMIMAGE;
  152.  
  153. typedef enum _D3DRMWRAPTYPE
  154. {   D3DRMWRAP_FLAT,
  155.     D3DRMWRAP_CYLINDER,
  156.     D3DRMWRAP_SPHERE,
  157.     D3DRMWRAP_CHROME
  158. } D3DRMWRAPTYPE, *LPD3DRMWRAPTYPE;
  159.  
  160. #define D3DRMWIREFRAME_CULL             1 /* cull backfaces */
  161. #define D3DRMWIREFRAME_HIDDENLINE       2 /* lines are obscured by closer objects */
  162.  
  163. typedef enum _D3DRMPROJECTIONTYPE
  164. {   D3DRMPROJECT_PERSPECTIVE,
  165.     D3DRMPROJECT_ORTHOGRAPHIC
  166. } D3DRMPROJECTIONTYPE, *LPD3DRMPROJECTIONTYPE;
  167.  
  168. typedef enum _D3DRMXOFFORMAT
  169. {   D3DRMXOF_BINARY,
  170.     D3DRMXOF_COMPRESSED,
  171.     D3DRMXOF_TEXT
  172. } D3DRMXOFFORMAT, *LPD3DRMXOFFORMAT;
  173.  
  174. typedef DWORD D3DRMSAVEOPTIONS;
  175. #define D3DRMXOFSAVE_NORMALS 1
  176. #define D3DRMXOFSAVE_TEXTURECOORDINATES 2
  177. #define D3DRMXOFSAVE_MATERIALS 4
  178. #define D3DRMXOFSAVE_TEXTURENAMES 8
  179. #define D3DRMXOFSAVE_ALL 15
  180.  
  181. typedef enum _D3DRMCOLORSOURCE
  182. {   D3DRMCOLOR_FROMFACE,
  183.     D3DRMCOLOR_FROMVERTEX
  184. } D3DRMCOLORSOURCE, *LPD3DRMCOLORSOURCE;
  185.  
  186. typedef enum _D3DRMFRAMECONSTRAINT
  187. {   D3DRMCONSTRAIN_Z,           /* use only X and Y rotations */
  188.     D3DRMCONSTRAIN_Y,           /* use only X and Z rotations */
  189.     D3DRMCONSTRAIN_X            /* use only Y and Z rotations */
  190. } D3DRMFRAMECONSTRAINT, *LPD3DRMFRAMECONSTRAINT;
  191.  
  192. typedef enum _D3DRMMATERIALMODE
  193. {   D3DRMMATERIAL_FROMMESH,
  194.     D3DRMMATERIAL_FROMPARENT,
  195.     D3DRMMATERIAL_FROMFRAME
  196. } D3DRMMATERIALMODE, *LPD3DRMMATERIALMODE;
  197.  
  198. typedef enum _D3DRMFOGMODE
  199. {   D3DRMFOG_LINEAR,            /* linear between start and end */
  200.     D3DRMFOG_EXPONENTIAL,       /* density * exp(-distance) */
  201.     D3DRMFOG_EXPONENTIALSQUARED /* density * exp(-distance*distance) */
  202. } D3DRMFOGMODE, *LPD3DRMFOGMODE;
  203.  
  204. typedef enum _D3DRMZBUFFERMODE {
  205.     D3DRMZBUFFER_FROMPARENT,    /* default */
  206.     D3DRMZBUFFER_ENABLE,        /* enable zbuffering */
  207.     D3DRMZBUFFER_DISABLE        /* disable zbuffering */
  208. } D3DRMZBUFFERMODE, *LPD3DRMZBUFFERMODE;
  209.  
  210. typedef enum _D3DRMSORTMODE {
  211.     D3DRMSORT_FROMPARENT,       /* default */
  212.     D3DRMSORT_NONE,             /* don't sort child frames */
  213.     D3DRMSORT_FRONTTOBACK,      /* sort child frames front-to-back */
  214.     D3DRMSORT_BACKTOFRONT       /* sort child frames back-to-front */
  215. } D3DRMSORTMODE, *LPD3DRMSORTMODE;
  216.  
  217. typedef DWORD D3DRMANIMATIONOPTIONS;
  218. #define D3DRMANIMATION_OPEN 0x01L
  219. #define D3DRMANIMATION_CLOSED 0x02L
  220. #define D3DRMANIMATION_LINEARPOSITION 0x04L
  221. #define D3DRMANIMATION_SPLINEPOSITION 0x08L
  222. #define D3DRMANIMATION_SCALEANDROTATION 0x00000010L
  223. #define D3DRMANIMATION_POSITION 0x00000020L
  224.  
  225. typedef DWORD D3DRMLOADOPTIONS;
  226.  
  227. #define D3DRMLOAD_FROMFILE  0x00L
  228. #define D3DRMLOAD_FROMRESOURCE 0x01L
  229. #define D3DRMLOAD_FROMMEMORY 0x02L
  230. #define D3DRMLOAD_FROMSTREAM 0x04L
  231.  
  232. #define D3DRMLOAD_BYNAME 0x10L
  233. #define D3DRMLOAD_BYPOSITION 0x20L
  234. #define D3DRMLOAD_BYGUID 0x40L
  235. #define D3DRMLOAD_FIRST 0x80L
  236.  
  237. #define D3DRMLOAD_INSTANCEBYREFERENCE 0x100L
  238. #define D3DRMLOAD_INSTANCEBYCOPYING 0x200L
  239.  
  240. typedef struct _D3DRMLOADRESOURCE {
  241.   HMODULE hModule;
  242.   LPCTSTR lpName;
  243.   LPCTSTR lpType;
  244. } D3DRMLOADRESOURCE, *LPD3DRMLOADRESOURCE;
  245.  
  246. typedef struct _D3DRMLOADMEMORY {
  247.   LPVOID lpMemory;
  248.   DWORD dSize;
  249. } D3DRMLOADMEMORY, *LPD3DRMLOADMEMORY;
  250.  
  251. typedef enum _D3DRMUSERVISUALREASON {
  252.     D3DRMUSERVISUAL_CANSEE,
  253.     D3DRMUSERVISUAL_RENDER
  254. } D3DRMUSERVISUALREASON, *LPD3DRMUSERVISUALREASON;
  255.  
  256.  
  257. typedef DWORD D3DRMMAPPING, D3DRMMAPPINGFLAG, *LPD3DRMMAPPING;
  258. static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPU = 1;
  259. static const D3DRMMAPPINGFLAG D3DRMMAP_WRAPV = 2;
  260. static const D3DRMMAPPINGFLAG D3DRMMAP_PERSPCORRECT = 4;
  261.  
  262. typedef struct _D3DRMVERTEX
  263. {   D3DVECTOR       position;
  264.     D3DVECTOR       normal;
  265.     D3DVALUE        tu, tv;
  266.     D3DCOLOR        color;
  267. } D3DRMVERTEX, *LPD3DRMVERTEX;
  268.  
  269. typedef LONG D3DRMGROUPINDEX; /* group indexes begin a 0 */
  270. static const D3DRMGROUPINDEX D3DRMGROUP_ALLGROUPS = -1;
  271.  
  272. /*
  273.  * Create a color from three components in the range 0-1 inclusive.
  274.  */
  275. extern D3DCOLOR D3DRMAPI        D3DRMCreateColorRGB(D3DVALUE red,
  276.                                           D3DVALUE green,
  277.                                           D3DVALUE blue);
  278.  
  279. /*
  280.  * Create a color from four components in the range 0-1 inclusive.
  281.  */
  282. extern D3DCOLOR D3DRMAPI        D3DRMCreateColorRGBA(D3DVALUE red,
  283.                                                  D3DVALUE green,
  284.                                                  D3DVALUE blue,
  285.                                                  D3DVALUE alpha);
  286.  
  287. /*
  288.  * Get the red component of a color.
  289.  */
  290. extern D3DVALUE                 D3DRMAPI D3DRMColorGetRed(D3DCOLOR);
  291.  
  292. /*
  293.  * Get the green component of a color.
  294.  */
  295. extern D3DVALUE                 D3DRMAPI D3DRMColorGetGreen(D3DCOLOR);
  296.  
  297. /*
  298.  * Get the blue component of a color.
  299.  */
  300. extern D3DVALUE                 D3DRMAPI D3DRMColorGetBlue(D3DCOLOR);
  301.  
  302. /*
  303.  * Get the alpha component of a color.
  304.  */
  305. extern D3DVALUE                 D3DRMAPI D3DRMColorGetAlpha(D3DCOLOR);
  306.  
  307. /*
  308.  * Add two vectors.  Returns its first argument.
  309.  */
  310. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorAdd(LPD3DVECTOR d,
  311.                                           LPD3DVECTOR s1,
  312.                                           LPD3DVECTOR s2);
  313.  
  314. /*
  315.  * Subtract two vectors.  Returns its first argument.
  316.  */
  317. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorSubtract(LPD3DVECTOR d,
  318.                                                LPD3DVECTOR s1,
  319.                                                LPD3DVECTOR s2);
  320. /*
  321.  * Reflect a ray about a given normal.  Returns its first argument.
  322.  */
  323. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorReflect(LPD3DVECTOR d,
  324.                                               LPD3DVECTOR ray,
  325.                                               LPD3DVECTOR norm);
  326.  
  327. /*
  328.  * Calculate the vector cross product.  Returns its first argument.
  329.  */
  330. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorCrossProduct(LPD3DVECTOR d,
  331.                                                    LPD3DVECTOR s1,
  332.                                                    LPD3DVECTOR s2);
  333. /*
  334.  * Return the vector dot product.
  335.  */
  336. extern D3DVALUE                 D3DRMAPI D3DRMVectorDotProduct(LPD3DVECTOR s1,
  337.                                                  LPD3DVECTOR s2);
  338.  
  339. /*
  340.  * Scale a vector so that its modulus is 1.  Returns its argument or
  341.  * NULL if there was an error (e.g. a zero vector was passed).
  342.  */
  343. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorNormalize(LPD3DVECTOR);
  344. #define D3DRMVectorNormalise D3DRMVectorNormalize
  345.  
  346. /*
  347.  * Return the length of a vector (e.g. sqrt(x*x + y*y + z*z)).
  348.  */
  349. extern D3DVALUE                 D3DRMAPI D3DRMVectorModulus(LPD3DVECTOR v);
  350.  
  351. /*
  352.  * Set the rotation part of a matrix to be a rotation of theta radians
  353.  * around the given axis.
  354.  */
  355.  
  356. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorRotate(LPD3DVECTOR r, LPD3DVECTOR v, LPD3DVECTOR axis, D3DVALUE theta);
  357.  
  358. /*
  359.  * Scale a vector uniformly in all three axes
  360.  */
  361. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorScale(LPD3DVECTOR d, LPD3DVECTOR s, D3DVALUE factor);
  362.  
  363. /*
  364.  * Return a random unit vector
  365.  */
  366. extern LPD3DVECTOR      D3DRMAPI D3DRMVectorRandom(LPD3DVECTOR d);
  367.  
  368. /*
  369.  * Returns a unit quaternion that represents a rotation of theta radians
  370.  * around the given axis.
  371.  */
  372.  
  373. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionFromRotation(LPD3DRMQUATERNION quat,
  374.                                                               LPD3DVECTOR v,
  375.                                                               D3DVALUE theta);
  376.  
  377. /*
  378.  * Calculate the product of two quaternions
  379.  */
  380. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionMultiply(LPD3DRMQUATERNION q,
  381.                                                           LPD3DRMQUATERNION a,
  382.                                                           LPD3DRMQUATERNION b);
  383.  
  384. /*
  385.  * Interpolate between two quaternions
  386.  */
  387. extern LPD3DRMQUATERNION D3DRMAPI D3DRMQuaternionSlerp(LPD3DRMQUATERNION q,
  388.                                                        LPD3DRMQUATERNION a,
  389.                                                        LPD3DRMQUATERNION b,
  390.                                                        D3DVALUE alpha);
  391.  
  392. /*
  393.  * Calculate the matrix for the rotation that a unit quaternion represents
  394.  */
  395. extern void             D3DRMAPI D3DRMMatrixFromQuaternion(D3DRMMATRIX4D dmMat, LPD3DRMQUATERNION lpDqQuat);
  396.  
  397.  
  398. #if defined(__cplusplus)
  399. };
  400. #endif
  401.  
  402. #endif
  403.