Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | pmbaty | 1 | /* |
| 2 | * Portions of this file are copyright Rebirth contributors and licensed as |
||
| 3 | * described in COPYING.txt. |
||
| 4 | * Portions of this file are copyright Parallax Software and licensed |
||
| 5 | * according to the Parallax license below. |
||
| 6 | * See COPYING.txt for license details. |
||
| 7 | |||
| 8 | THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
||
| 9 | SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
||
| 10 | END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
||
| 11 | ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
||
| 12 | IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
||
| 13 | SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
||
| 14 | FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
||
| 15 | CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
||
| 16 | AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
||
| 17 | COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
||
| 18 | */ |
||
| 19 | /* |
||
| 20 | * $Source: /cvsroot/dxx-rebirth/d2x-rebirth/include/texmap.h,v $ |
||
| 21 | * $Revision: 1.1.1.1 $ |
||
| 22 | * $Author: zicodxx $ |
||
| 23 | * $Date: 2006/03/17 20:01:30 $ |
||
| 24 | * |
||
| 25 | * Include file for entities using texture mapper library. |
||
| 26 | * |
||
| 27 | */ |
||
| 28 | |||
| 29 | #pragma once |
||
| 30 | |||
| 31 | #include "maths.h" |
||
| 32 | #include "3d.h" |
||
| 33 | |||
| 34 | #define NUM_LIGHTING_LEVELS 32 |
||
| 35 | #define MAX_LIGHTING_VALUE ((NUM_LIGHTING_LEVELS-1)*F1_0/NUM_LIGHTING_LEVELS) |
||
| 36 | #define MIN_LIGHTING_VALUE (F1_0/NUM_LIGHTING_LEVELS) |
||
| 37 | |||
| 38 | #ifdef __cplusplus |
||
| 39 | #include "dxxsconf.h" |
||
| 40 | #include "dsx-ns.h" |
||
| 41 | #include <array> |
||
| 42 | |||
| 43 | namespace dcx { |
||
| 44 | |||
| 45 | constexpr std::integral_constant<unsigned, 25> MAX_TMAP_VERTS{}; |
||
| 46 | |||
| 47 | #if !DXX_USE_OGL |
||
| 48 | // ------------------------------------------------------------------------------------------------------- |
||
| 49 | // This is the main texture mapper call. |
||
| 50 | // tmap_num references a texture map defined in Texmap_ptrs. |
||
| 51 | // nverts = number of vertices |
||
| 52 | // vertbuf is a pointer to an array of vertex pointers |
||
| 53 | void draw_tmap(grs_canvas &, const grs_bitmap &bp, uint_fast32_t nverts, const g3s_point *const *vertbuf); |
||
| 54 | |||
| 55 | //function that takes the same parms as draw_tmap, but renders as flat poly |
||
| 56 | //we need this to do the cloaked effect |
||
| 57 | void draw_tmap_flat(grs_canvas &, const grs_bitmap &bp, uint_fast32_t nverts, const g3s_point *const *vertbuf); |
||
| 58 | #endif |
||
| 59 | |||
| 60 | // ------------------------------------------------------------------------------------------------------- |
||
| 61 | // Texture map vertex. |
||
| 62 | // The fields r,g,b and l are mutually exclusive. r,g,b are used for rgb lighting. |
||
| 63 | // l is used for intensity based lighting. |
||
| 64 | struct g3ds_vertex { |
||
| 65 | fix x,y,z; |
||
| 66 | fix u,v; |
||
| 67 | fix x2d,y2d; |
||
| 68 | fix l; |
||
| 69 | }; |
||
| 70 | |||
| 71 | // A texture map is defined as a polygon with u,v coordinates associated with |
||
| 72 | // one point in the polygon, and a pair of vectors describing the orientation |
||
| 73 | // of the texture map in the world, from which the deltas Du_dx, Dv_dy, etc. |
||
| 74 | // are computed. |
||
| 75 | struct g3ds_tmap { |
||
| 76 | int nv; // number of vertices |
||
| 77 | std::array<g3ds_vertex, MAX_TMAP_VERTS> verts; // up to 8 vertices, this is inefficient, change |
||
| 78 | }; |
||
| 79 | |||
| 80 | // ------------------------------------------------------------------------------------------------------- |
||
| 81 | |||
| 82 | // Note: Not all interpolation method and lighting combinations are supported. |
||
| 83 | // Set Interpolation_method to 0/1/2 for linear/linear, perspective/linear, perspective/perspective |
||
| 84 | #if !DXX_USE_OGL |
||
| 85 | extern int Interpolation_method; |
||
| 86 | extern uint8_t Transparency_on; |
||
| 87 | |||
| 88 | // Set Lighting_on to 0/1/2 for no lighting/intensity lighting/rgb lighting |
||
| 89 | extern int Lighting_on; |
||
| 90 | |||
| 91 | // HACK INTERFACE: how far away the current segment (& thus texture) is |
||
| 92 | extern unsigned Current_seg_depth; |
||
| 93 | void init_interface_vars_to_assembler(); |
||
| 94 | #endif |
||
| 95 | class push_interpolation_method |
||
| 96 | { |
||
| 97 | #if DXX_USE_OGL |
||
| 98 | public: |
||
| 99 | push_interpolation_method(int, bool = true) {} |
||
| 100 | #else |
||
| 101 | int previous; |
||
| 102 | public: |
||
| 103 | push_interpolation_method(int next, bool condition = true) : |
||
| 104 | previous(Interpolation_method) |
||
| 105 | { |
||
| 106 | if (condition) |
||
| 107 | Interpolation_method = next; |
||
| 108 | } |
||
| 109 | ~push_interpolation_method() |
||
| 110 | { |
||
| 111 | Interpolation_method = previous; |
||
| 112 | } |
||
| 113 | #endif |
||
| 114 | }; |
||
| 115 | |||
| 116 | // These are pointers to texture maps. If you want to render texture map #7, then you will render |
||
| 117 | // the texture map defined by Texmap_ptrs[7]. |
||
| 118 | |||
| 119 | extern int Window_clip_left, Window_clip_bot, Window_clip_right, Window_clip_top; |
||
| 120 | |||
| 121 | // for ugly hack put in to be sure we don't overflow render buffer |
||
| 122 | |||
| 123 | #define FIX_XLIMIT (639 * F1_0) |
||
| 124 | #define FIX_YLIMIT (479 * F1_0) |
||
| 125 | |||
| 126 | } |
||
| 127 | |||
| 128 | #endif |