TEXMAP.H 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/texmap/rcs/texmap.h $
  15. * $Revision: 1.17 $
  16. * $Author: mike $
  17. * $Date: 1994/11/10 11:09:16 $
  18. *
  19. * Include file for entities using texture mapper library.
  20. *
  21. * $Log: texmap.h $
  22. * Revision 1.17 1994/11/10 11:09:16 mike
  23. * detail level stuff.
  24. *
  25. * Revision 1.16 1994/11/09 22:55:32 matt
  26. * Added variable Current_seg_depth for detail level optimization
  27. *
  28. * Revision 1.15 1994/06/09 16:10:04 mike
  29. * Add prototype for SC2000
  30. *
  31. * Revision 1.14 1994/05/25 18:46:16 matt
  32. * Added gr_upoly_tmap_ylr(), which generates ylr's for a polygon
  33. *
  34. * Revision 1.13 1994/05/25 09:47:12 mike
  35. * Added interface support for linear texture mapper (Mike change, Matt commnet)
  36. *
  37. * Revision 1.12 1994/05/24 17:30:43 mike
  38. * Prototype a bunch of linear, vertical scanning functions.
  39. *
  40. * Revision 1.11 1994/05/19 23:26:14 mike
  41. * Add constants NUM_LIGHTING_VALUES, MAX_LIGHTING_VALUE, MIN_LIGHTING_VALUE,
  42. * all part of new lighting_values_in_0_to_1 system.
  43. *
  44. * Revision 1.10 1994/05/14 17:19:21 matt
  45. * Added externs
  46. *
  47. * Revision 1.9 1994/04/13 23:55:44 matt
  48. * Increased max_tmap_verts from 16 to 25
  49. *
  50. * Revision 1.8 1994/03/31 08:35:43 mike
  51. * Prototype for gr_upoly_tmap.
  52. *
  53. * Revision 1.7 1994/02/08 15:17:54 mike
  54. * define label for MAX_TMAP_VERTS
  55. *
  56. * Revision 1.6 1994/01/31 15:41:51 mike
  57. * Add texture_map_lin_lin_sky_v
  58. *
  59. * Revision 1.5 1994/01/18 10:49:40 mike
  60. * prototype for texture_map_lin_lin_sky
  61. *
  62. * Revision 1.4 1993/11/30 17:09:46 mike
  63. * prototype for compute_lighting_value.
  64. *
  65. * Revision 1.3 1993/11/22 10:50:38 matt
  66. * Add ifndef around body of file
  67. *
  68. * Revision 1.2 1993/10/06 12:41:25 mike
  69. * Change prototype for draw_tmap.
  70. *
  71. * Revision 1.1 1993/09/08 17:29:11 mike
  72. * Initial revision
  73. *
  74. *
  75. */
  76. #ifndef _TEXMAP_H
  77. #define _TEXMAP_H
  78. #include "fix.h"
  79. #include "3d.h"
  80. #include "gr.h"
  81. #define NUM_LIGHTING_LEVELS 32
  82. #define MAX_TMAP_VERTS 25
  83. #define MAX_LIGHTING_VALUE ((NUM_LIGHTING_LEVELS-1)*F1_0/NUM_LIGHTING_LEVELS)
  84. #define MIN_LIGHTING_VALUE (F1_0/NUM_LIGHTING_LEVELS)
  85. // -------------------------------------------------------------------------------------------------------
  86. extern fix compute_lighting_value(g3s_point *vertptr);
  87. // -------------------------------------------------------------------------------------------------------
  88. // This is the main texture mapper call.
  89. // tmap_num references a texture map defined in Texmap_ptrs.
  90. // nverts = number of vertices
  91. // vertbuf is a pointer to an array of vertex pointers
  92. extern void draw_tmap(grs_bitmap *bp, int nverts, g3s_point **vertbuf);
  93. // -------------------------------------------------------------------------------------------------------
  94. // Texture map vertex.
  95. // The fields r,g,b and l are mutually exclusive. r,g,b are used for rgb lighting.
  96. // l is used for intensity based lighting.
  97. typedef struct g3ds_vertex {
  98. fix x,y,z;
  99. fix u,v;
  100. fix x2d,y2d;
  101. fix l;
  102. fix r,g,b;
  103. } g3ds_vertex;
  104. // A texture map is defined as a polygon with u,v coordinates associated with
  105. // one point in the polygon, and a pair of vectors describing the orientation
  106. // of the texture map in the world, from which the deltas Du_dx, Dv_dy, etc.
  107. // are computed.
  108. typedef struct g3ds_tmap {
  109. int nv; // number of vertices
  110. g3ds_vertex verts[MAX_TMAP_VERTS]; // up to 8 vertices, this is inefficient, change
  111. } g3ds_tmap;
  112. // -------------------------------------------------------------------------------------------------------
  113. // Note: Not all interpolation method and lighting combinations are supported.
  114. // Set Interpolation_method to 0/1/2 for linear/linear, perspective/linear, perspective/perspective
  115. extern int Interpolation_method;
  116. // Set Lighting_on to 0/1/2 for no lighting/intensity lighting/rgb lighting
  117. extern int Lighting_on;
  118. // HACK INTERFACE: how far away the current segment (& thus texture) is
  119. extern int Current_seg_depth;
  120. extern int Max_perspective_depth; // Deepest segment at which perspective interpolation will be used.
  121. extern int Max_linear_depth; // Deepest segment at which linear interpolation will be used.
  122. extern int Max_flat_depth; // Deepest segment at which flat shading will be used. (If not flat shading, then what?)
  123. // These are pointers to texture maps. If you want to render texture map #7, then you will render
  124. // the texture map defined by Texmap_ptrs[7].
  125. extern grs_bitmap Texmap_ptrs[];
  126. extern grs_bitmap Texmap4_ptrs[];
  127. // Interface for sky renderer
  128. extern void texture_map_lin_lin_sky(grs_bitmap *srcb, g3ds_tmap *t);
  129. extern void texture_map_lin_lin_sky_v(grs_bitmap *srcb, g3ds_tmap *t);
  130. extern void texture_map_hyp_lin_v(grs_bitmap *srcb, g3ds_tmap *t);
  131. extern void ntexture_map_lighted_linear(grs_bitmap *srcb, g3ds_tmap *t);
  132. // This is the gr_upoly-like interface to the texture mapper which uses texture-mapper compatible
  133. // (ie, avoids cracking) edge/delta computation.
  134. void gr_upoly_tmap(int nverts, int *vert );
  135. //This is like gr_upoly_tmap() but instead of drawing, it calls the specified
  136. //function with ylr values
  137. void gr_upoly_tmap_ylr(int nverts, int *vert, void *ylr_func() );
  138. extern int Transparency_on,per2_flag;
  139. // Set to !0 to enable Sim City 2000 (or Eric's Drive Through, or Eric's Game) specific code.
  140. extern int SC2000;
  141. #endif