Index: generate_lightmaps.cc =================================================================== --- generate_lightmaps.cc (revision 2039) +++ generate_lightmaps.cc (working copy) @@ -122,100 +122,275 @@ int brightness = 32; int base_brightness = 128; -#define corner_sw(i) (i%3) // sw corner -#define corner_se(i) ((i/3)%3) // se corner -#define corner_ne(i) ((i/9)%3) // ne corner -#define corner_nw(i) (i/27) // nw corner +#define corner_sw(i) (i%4) // sw corner +#define corner_se(i) ((i/4)%4) // se corner +#define corner_ne(i) ((i/16)%4) // ne corner +#define corner_nw(i) (i/64) // nw corner #define einfach (0) -#define wegbar_ns (1) -#define wegbar_ow (1) +#define way_ns (1) +#define way_ew (1) #define frontback (2) /* need to divide left right */ #define illegal (4) -const int hang[81] = { - wegbar_ns | wegbar_ow, // 0:flach // flat ns|ew - frontback, // sw1 - frontback, // sw2 - frontback, // se1 - wegbar_ns | einfach, // 4:nordhang // se1,sw1 ns - 0, // se1,sw2 - 0, // se2 - 0, // se2,sw1 - wegbar_ns | einfach, // 8: double height north // se2,sw2 ns2 - frontback, // ne1 - frontback, // ne1,sw1 - frontback, // ne1,sw2 - wegbar_ow | einfach, // 12:westhang // ne1,se1 ew - 0, // ne1,se1,sw1 - frontback, // ne1,se1,sw2 - 0, // ne1,se2 - 0, // ne1,se2,sw1 - 0, // ne1,se2,sw2 - frontback, // ne2 - frontback, // ne2,sw1 - frontback, // ne2,sw2 - frontback, // ne2,se1 - frontback, // ne2,se1,sw1 - frontback, // ne2,se1,sw2 - wegbar_ow | einfach, // 24: double height west // ne2,se2 ew2 - frontback, // ne2,se2,sw1 - frontback, // ne2,se2,sw2 - 0, // nw1 - wegbar_ow | einfach, // 28:osthang // nw1,sw1 ew - frontback, // nw1,sw2 - 0, // nw1,se1 - 0, // nw1,se1,sw1 - frontback, // nw1,se1,sw2 - 0, // nw1,se2 - 0, // nw1,se2,sw1 - 0, // nw1,se2,sw2 - wegbar_ns | einfach, // 36:suedhang // nw1,ne1 ns - frontback, // nw1,ne1,sw1 - frontback, // nw1,ne1,sw2 - 0, // nw1,ne1,se1 - wegbar_ns | wegbar_ow | illegal, // 40:all 1 tile // nw1,ne1,se1,sw1 TODO 0 up 1 high - illegal, // nw1,ne1,se1,sw2 TODO 1 up 1 - 0, // nw1,ne1,se2 - illegal, // nw1,ne1,se2,sw1 TODO 3 up 1 - wegbar_ns | einfach | illegal, // 44 nordhang 2 // nw1,ne1,se2,sw2 TODOns 4 up 1 - frontback, // nw1,ne2 - frontback, // nw1,ne2,sw1 - frontback, // nw1,ne2,sw2 - frontback, // nw1,ne2,se1 - illegal, // nw1,ne2,se1,sw1 TODO 9 up 1 - illegal, // nw1,ne2,se1,sw2 TODO 10 up 1 - 0, // nw1,ne2,se2 - wegbar_ow | einfach | illegal, // 52 westhang 2 // nw1,ne2,se2,sw1 TODOew 12 up 1 - illegal, // nw1,ne2,se2,sw2 TODO 13 up 1 - 0, // nw2 - 0, // nw2,sw1 - wegbar_ow | einfach, // 56:double height east // nw2,sw2 ew2 - 0, // nw2,se1 - 0, // nw2,se1,sw1 - 0, // nw2,se1,sw2 - 0, // nw2,se2 - 0, // nw2,se2,sw1 - 0, // nw2,se2,sw2 - 0, // nw2,ne1 - 0, // nw2,ne1,sw1 - frontback, // nw2,ne1,sw2 - 0, // nw2,ne1,se1 - illegal, // nw2,ne1,se1,sw1 TODO 27 up 1 - wegbar_ow | einfach | illegal, // 68:osthang 2 // nw2,ne1,se1,sw2 TODOew 28 up 1 - 0, // nw2,ne1,se2 - illegal, // nw2,ne1,se2,sw1 TODO 30 up 1 - illegal, // nw2,ne1,se2,sw2 TODO 31 up 1 - wegbar_ns | einfach, // 72:double height south // nw2,ne2 ns2 - frontback, // nw2,ne2,sw1 - frontback, // nw2,ne2,sw2 - frontback, // nw2,ne2,se1 - wegbar_ns | einfach | illegal, // 76:suedhang 2 // nw2,ne2,se1,sw1 TODOns 36 up 1 - illegal, // nw2,ne2,se1,sw2 TODO 37 up 1 - 0, // nw2,ne2,se2 - illegal, // nw2,ne2,se2,sw1 TODO 39 up 1 - wegbar_ns | wegbar_ow | illegal // 80:all 2 tile // nw2,ne2,se2,sw2 TODO 0 up 2 high +const int hang[256] = { + way_ns | way_ew, // slope 0 # flat straight ns|ew + 0, // slope 1 # sw1 + 0, // slope 2 # sw2 + 0, // slope 3 # sw3 + 0, // slope 4 # se1 + way_ns, // slope 5 # se1,sw1 straight ns + 0, // slope 6 # se1,sw2 + 0, // slope 7 # se1,sw3 + 0, // slope 8 # se2 + 0, // slope 9 # se2,sw1 + way_ns, // slope 10 # se2,sw2 straight ns2 + 0, // slope 11 # se2,sw3 + 0, // slope 12 # se3 + 0, // slope 13 # se3,sw1 + 0, // slope 14 # se3,sw2 + way_ns, // slope 15 # se3,sw3 straight ns3 + 0, // slope 16 # ne1 + 0, // slope 17 # ne1,sw1 + 0, // slope 18 # ne1,sw2 + 0, // slope 19 # ne1,sw3 + way_ew, // slope 20 # ne1,se1 straight ew + 0, // slope 21 # ne1,se1,sw1 + 0, // slope 22 # ne1,se1,sw2 + 0, // slope 23 # ne1,se1,sw3 + 0, // slope 24 # ne1,se2 + 0, // slope 25 # ne1,se2,sw1 + 0, // slope 26 # ne1,se2,sw2 + 0, // slope 27 # ne1,se2,sw3 + 0, // slope 28 # ne1,se3 + 0, // slope 29 # ne1,se3,sw1 + 0, // slope 30 # ne1,se3,sw2 + 0, // slope 31 # ne1,se3,sw3 + 0, // slope 32 # ne2 + 0, // slope 33 # ne2,sw1 + 0, // slope 34 # ne2,sw2 + 0, // slope 35 # ne2,sw3 + 0, // slope 36 # ne2,se1 + 0, // slope 37 # ne2,se1,sw1 + 0, // slope 38 # ne2,se1,sw2 + 0, // slope 39 # ne2,se1,sw3 + way_ew, // slope 40 # ne2,se2 straight ew2 + 0, // slope 41 # ne2,se2,sw1 + 0, // slope 42 # ne2,se2,sw2 + 0, // slope 43 # ne2,se2,sw3 + 0, // slope 44 # ne2,se3 + 0, // slope 45 # ne2,se3,sw1 + 0, // slope 46 # ne2,se3,sw2 + 0, // slope 47 # ne2,se3,sw3 + 0, // slope 48 # ne3 + 0, // slope 49 # ne3,sw1 + 0, // slope 50 # ne3,sw2 + 0, // slope 51 # ne3,sw3 + 0, // slope 52 # ne3,se1 + 0, // slope 53 # ne3,se1,sw1 + 0, // slope 54 # ne3,se1,sw2 + 0, // slope 55 # ne3,se1,sw3 + 0, // slope 56 # ne3,se2 + 0, // slope 57 # ne3,se2,sw1 + 0, // slope 58 # ne3,se2,sw2 + 0, // slope 59 # ne3,se2,sw3 + way_ew, // slope 60 # ne3,se3 straight ew3 + 0, // slope 61 # ne3,se3,sw1 + 0, // slope 62 # ne3,se3,sw2 + 0, // slope 63 # ne3,se3,sw3 + 0, // slope 64 # nw1 + way_ew, // slope 65 # nw1,sw1 straight ew + 0, // slope 66 # nw1,sw2 + 0, // slope 67 # nw1,sw3 + 0, // slope 68 # nw1,se1 + 0, // slope 69 # nw1,se1,sw1 + 0, // slope 70 # nw1,se1,sw2 + 0, // slope 71 # nw1,se1,sw3 + 0, // slope 72 # nw1,se2 + 0, // slope 73 # nw1,se2,sw1 + 0, // slope 74 # nw1,se2,sw2 + 0, // slope 75 # nw1,se2,sw3 + 0, // slope 76 # nw1,se3 + 0, // slope 77 # nw1,se3,sw1 + 0, // slope 78 # nw1,se3,sw2 + 0, // slope 79 # nw1,se3,sw3 + way_ns, // slope 80 # nw1,ne1 straight ns + 0, // slope 81 # nw1,ne1,sw1 + 0, // slope 82 # nw1,ne1,sw2 + 0, // slope 83 # nw1,ne1,sw3 + 0, // slope 84 # nw1,ne1,se1 + way_ns | way_ew | illegal, // slope 85 # nw1,ne1,se1,sw1 TODO 0 up 1 + 0 | illegal, // slope 86 # nw1,ne1,se1,sw2 TODO 1 up 1 + 0 | illegal, // slope 87 # nw1,ne1,se1,sw3 TODO 2 up 1 + 0, // slope 88 # nw1,ne1,se2 + 0 | illegal, // slope 89 # nw1,ne1,se2,sw1 TODO 4 up 1 + way_ns | illegal, // slope 90 # nw1,ne1,se2,sw2 TODOns 5 up 1 + 0 | illegal, // slope 91 # nw1,ne1,se2,sw3 TODOns 6 up 1 + 0, // slope 92 # nw1,ne1,se3 + 0 | illegal, // slope 93 # nw1,ne1,se3,sw1 TODO 8 up 1 + 0 | illegal, // slope 94 # nw1,ne1,se3,sw2 TODOns 9 up 1 + way_ns | illegal, // slope 95 # nw1,ne1,se3,sw3 TODOns 10 up 1 + 0, // slope 96 # nw1,ne2 + 0, // slope 97 # nw1,ne2,sw1 + 0, // slope 98 # nw1,ne2,sw2 + 0, // slope 99 # nw1,ne2,sw3 + 0, // slope 100 # nw1,ne2,se1 + 0 | illegal, // slope 101 # nw1,ne2,se1,sw1 TODO 16 up 1 + 0 | illegal, // slope 102 # nw1,ne2,se1,sw2 TODO 17 up 1 + 0 | illegal, // slope 103 # nw1,ne2,se1,sw3 TODO 18 up 1 + 0, // slope 104 # nw1,ne2,se2 + way_ew | illegal, // slope 105 # nw1,ne2,se2,sw1 TODOew 20 up 1 + 0 | illegal, // slope 106 # nw1,ne2,se2,sw2 TODO 21 up 1 + 0 | illegal, // slope 107 # nw1,ne2,se2,sw3 TODO 22 up 1 + 0, // slope 108 # nw1,ne2,se3 + 0 | illegal, // slope 109 # nw1,ne2,se3,sw1 TODOew 24 up 1 + 0 | illegal, // slope 110 # nw1,ne2,se3,sw2 TODO 25 up 1 + 0 | illegal, // slope 111 # nw1,ne2,se3,sw3 TODO 26 up 1 + 0, // slope 112 # nw1,ne3 + 0, // slope 113 # nw1,ne3,sw1 + 0, // slope 114 # nw1,ne3,sw2 + 0, // slope 115 # nw1,ne3,sw3 + 0, // slope 116 # nw1,ne3,se1 + 0 | illegal, // slope 117 # nw1,ne3,se1,sw1 TODO 32 up 1 + 0 | illegal, // slope 118 # nw1,ne3,se1,sw2 TODO 33 up 1 + 0 | illegal, // slope 119 # nw1,ne3,se1,sw3 TODO 34 up 1 + 0, // slope 120 # nw1,ne3,se2 + 0 | illegal, // slope 121 # nw1,ne3,se2,sw1 TODOew 36 up 1 + 0 | illegal, // slope 122 # nw1,ne3,se2,sw2 TODO 37 up 1 + 0 | illegal, // slope 123 # nw1,ne3,se2,sw3 TODO 38 up 1 + 0, // slope 124 # nw1,ne3,se3 + way_ew | illegal, // slope 125 # nw1,ne3,se3,sw1 TODOew 40 up 1 + 0 | illegal, // slope 126 # nw1,ne3,se3,sw2 TODO 41 up 1 + 0 | illegal, // slope 127 # nw1,ne3,se3,sw3 TODO 42 up 1 + 0, // slope 128 # nw2 + 0, // slope 129 # nw2,sw1 + way_ew, // slope 130 # nw2,sw2 straight ew2 + 0, // slope 131 # nw2,sw3 + 0, // slope 132 # nw2,se1 + 0, // slope 133 # nw2,se1,sw1 + 0, // slope 134 # nw2,se1,sw2 + 0, // slope 135 # nw2,se1,sw3 + 0, // slope 136 # nw2,se2 + 0, // slope 137 # nw2,se2,sw1 + 0, // slope 138 # nw2,se2,sw2 + 0, // slope 139 # nw2,se2,sw3 + 0, // slope 140 # nw2,se3 + 0, // slope 141 # nw2,se3,sw1 + 0, // slope 142 # nw2,se3,sw2 + 0, // slope 143 # nw2,se3,sw3 + 0, // slope 144 # nw2,ne1 + 0, // slope 145 # nw2,ne1,sw1 + 0, // slope 146 # nw2,ne1,sw2 + 0, // slope 147 # nw2,ne1,sw3 + 0, // slope 148 # nw2,ne1,se1 + 0 | illegal, // slope 149 # nw2,ne1,se1,sw1 TODO 64 up 1 + way_ew | illegal, // slope 150 # nw2,ne1,se1,sw2 TODOew 65 up 1 + 0 | illegal, // slope 151 # nw2,ne1,se1,sw3 TODOew 66 up 1 + 0, // slope 152 # nw2,ne1,se2 + 0 | illegal, // slope 153 # nw2,ne1,se2,sw1 TODO 68 up 1 + 0 | illegal, // slope 154 # nw2,ne1,se2,sw2 TODO 69 up 1 + 0 | illegal, // slope 155 # nw2,ne1,se2,sw3 TODO 70 up 1 + 0, // slope 156 # nw2,ne1,se3 + 0 | illegal, // slope 157 # nw2,ne1,se3,sw1 TODO 72 up 1 + 0 | illegal, // slope 158 # nw2,ne1,se3,sw2 TODO 73 up 1 + 0 | illegal, // slope 159 # nw2,ne1,se3,sw3 TODO 74 up 1 + way_ns, // slope 160 # nw2,ne2 straight ns2 + 0, // slope 161 # nw2,ne2,sw1 + 0, // slope 162 # nw2,ne2,sw2 + 0, // slope 163 # nw2,ne2,sw3 + 0, // slope 164 # nw2,ne2,se1 + way_ns | illegal, // slope 165 # nw2,ne2,se1,sw1 TODOns 80 up 1 + 0 | illegal, // slope 166 # nw2,ne2,se1,sw2 TODO 81 up 1 + 0 | illegal, // slope 167 # nw2,ne2,se1,sw3 TODO 82 up 1 + 0, // slope 168 # nw2,ne2,se2 + 0 | illegal, // slope 169 # nw2,ne2,se2,sw1 TODO 84 up 1 + way_ns | way_ew | illegal, // slope 170 # nw2,ne2,se2,sw2 TODO [[85 up 1 =]] 0 up 2 + 0 | illegal, // slope 171 # nw2,ne2,se2,sw3 TODO [[86 up 2 =]] 1 up 2 + 0, // slope 172 # nw2,ne2,se3 + 0 | illegal, // slope 173 # nw2,ne2,se3,sw1 TODO 88 up 1 + 0 | illegal, // slope 174 # nw2,ne2,se3,sw2 TODO [[89 up 1 =]] 4 up 2 + way_ns | illegal, // slope 175 # nw2,ne2,se3,sw3 TODO [[90 up 1 =]] 5 up 2 + 0, // slope 176 # nw2,ne3 + 0, // slope 177 # nw2,ne3,sw1 + 0, // slope 178 # nw2,ne3,sw2 + 0, // slope 179 # nw2,ne3,sw3 + 0, // slope 180 # nw2,ne3,se1 + 0 | illegal, // slope 181 # nw2,ne3,se1,sw1 TODOns 96 up 1 + 0 | illegal, // slope 182 # nw2,ne3,se1,sw2 TODO 97 up 1 + 0 | illegal, // slope 183 # nw2,ne3,se1,sw3 TODO 98 up 1 + 0, // slope 184 # nw2,ne3,se2 + 0 | illegal, // slope 185 # nw2,ne3,se2,sw1 TODO 100 up 1 + 0 | illegal, // slope 186 # nw2,ne3,se2,sw2 TODO 101 up 1 + 0 | illegal, // slope 187 # nw2,ne3,se2,sw3 TODO 102 up 1 + 0, // slope 188 # nw2,ne3,se3 + 0 | illegal, // slope 189 # nw2,ne3,se3,sw1 TODO 104 up 1 + way_ew | illegal, // slope 190 # nw2,ne3,se3,sw2 TODO 105 up 1 [[=20 up 2]] + 0 | illegal, // slope 191 # nw2,ne3,se3,sw3 TODO 106 up 1 [[=21 up 2] + 0, // slope 192 # nw3,ne0,se0,sw0 + 0, // slope 193 # nw3,ne0,se0,sw1 + 0, // slope 194 # nw3,ne0,se0,sw2 + way_ew, // slope 195 # nw3,ne0,se0,sw3 + 0, // slope 196 # nw3,ne0,se1,sw0 + 0, // slope 197 # nw3,ne0,se1,sw1 + 0, // slope 198 # nw3,ne0,se1,sw2 + 0, // slope 199 # nw3,ne0,se1,sw3 + 0, // slope 200 # nw3,ne0,se2,sw0 + 0, // slope 201 # nw3,ne0,se2,sw1 + 0, // slope 202 # nw3,ne0,se2,sw2 + 0, // slope 203 # nw3,ne0,se2,sw3 + 0, // slope 204 # nw3,ne0,se3,sw0 + 0, // slope 205 # nw3,ne0,se3,sw1 + 0, // slope 206 # nw3,ne0,se3,sw2 + 0, // slope 207 # nw3,ne0,se3,sw3 + 0, // slope 208 # nw3,ne1,se0,sw0 + 0, // slope 209 # nw3,ne1,se0,sw1 + 0, // slope 210 # nw3,ne1,se0,sw2 + 0, // slope 211 # nw3,ne1,se0,sw3 + 0, // slope 212 # nw3,ne1,se1,sw0 + 0 | illegal, // slope 213 # nw3,ne1,se1,sw1 + 0 | illegal, // slope 214 # nw3,ne1,se1,sw2 + way_ew | illegal, // slope 215 # nw3,ne1,se1,sw3 + 0, // slope 216 # nw3,ne1,se2,sw0 + 0 | illegal, // slope 217 # nw3,ne1,se2,sw1 + 0 | illegal, // slope 218 # nw3,ne1,se2,sw2 + 0 | illegal, // slope 219 # nw3,ne1,se2,sw3 + 0, // slope 220 # nw3,ne1,se3,sw0 + 0 | illegal, // slope 221 # nw3,ne1,se3,sw1 + 0 | illegal, // slope 222 # nw3,ne1,se3,sw2 + 0 | illegal, // slope 223 # nw3,ne1,se3,sw3 + 0, // slope 224 # nw3,ne2,se0,sw0 + 0, // slope 225 # nw3,ne2,se0,sw1 + 0, // slope 226 # nw3,ne2,se0,sw2 + 0, // slope 227 # nw3,ne2,se0,sw3 + 0, // slope 228 # nw3,ne2,se1,sw0 + 0 | illegal, // slope 229 # nw3,ne2,se1,sw1 + 0 | illegal, // slope 230 # nw3,ne2,se1,sw2 + 0 | illegal, // slope 231 # nw3,ne2,se1,sw3 + 0, // slope 232 # nw3,ne3,se2,sw0 + 0 | illegal, // slope 233 # nw3,ne2,se2,sw1 + 0 | illegal, // slope 234 # nw3,ne2,se2,sw2 + way_ew | illegal, // slope 235 # nw3,ne2,se2,sw3 + 0, // slope 236 # nw3,ne3,se3,sw0 + 0 | illegal, // slope 237 # nw3,ne2,se3,sw1 + 0 | illegal, // slope 238 # nw3,ne2,se3,sw2 + 0 | illegal, // slope 239 # nw3,ne2,se3,sw3 + way_ns, // slope 240 # nw3,ne3,se0,sw0 + 0, // slope 241 # nw3,ne3,se0,sw1 + 0, // slope 242 # nw3,ne3,se0,sw2 + 0, // slope 243 # nw3,ne3,se0,sw3 + 0, // slope 244 # nw3,ne3,se1,sw0 + way_ns | illegal, // slope 245 # nw3,ne3,se1,sw1 + 0 | illegal, // slope 246 # nw3,ne3,se1,sw2 + 0 | illegal, // slope 247 # nw3,ne3,se1,sw3 + 0, // slope 248 # nw3,ne3,se2,sw0 + 0 | illegal, // slope 249 # nw3,ne3,se2,sw1 + way_ns | illegal, // slope 250 # nw3,ne3,se2,sw2 + 0 | illegal, // slope 251 # nw3,ne3,se2,sw3 + 0, // slope 252 # nw3,ne3,se3,sw0 + 0 | illegal, // slope 253 # nw3,ne3,se3,sw1 + 0 | illegal, // slope 254 # nw3,ne3,se3,sw2 + way_ns | way_ew | illegal, // slope 255 # nw3,ne3,se3,sw3 }; @@ -379,7 +554,7 @@ int ne = corner_ne(slope); int nw = corner_nw(slope); - if( slope >= 27 ) { + if( slope >= 64 ) { // front slope nw = ne; ne = se; @@ -397,7 +572,7 @@ } int line[1024]; - if( slope < 27 ) { + if( slope < 64 ) { // font part DrawLine( 0, corner[0], pak/2-1, corner[1], line, false ); DrawLine( pak/2, corner[1], pak-1, corner[2], line, false ); @@ -445,7 +620,7 @@ case 'c': case 'C': - if( !stricmp(argv[i]+1,"c#") ) { + if( !strcmp(argv[i]+1,"c#") ) { Usage(argv[0]); break; } @@ -456,7 +631,7 @@ case 'p': case 'P': - if( !stricmp(argv[i]+1,"pak") ) { + if( !strcmp(argv[i]+1,"pak") ) { Usage(argv[0]); break; } @@ -465,7 +640,7 @@ case 's': case 'S': - if( !stricmp(argv[i]+1,"slope") ) { + if( !strcmp(argv[i]+1,"slope") ) { Usage(argv[0]); break; } @@ -475,7 +650,7 @@ case 'm': case 'M': - if( !stricmp(argv[i]+1,"marker") ) { + if( !strcmp(argv[i]+1,"marker") ) { Usage(argv[0]); break; } @@ -485,7 +660,7 @@ case 'b': case 'B': - if( !stricmp(argv[i]+1,"bright") ) { + if( !strcmp(argv[i]+1,"bright") ) { Usage(argv[0]); break; } @@ -528,7 +703,7 @@ /* init bitmap */ const long row = make_lightmap ? 16 : 9; const long bitmap_x = pak*row; - const long bitmap_y = ((80/row)+1)*pak; + const long bitmap_y = ((255/row)+1)*pak; PIXRGB *bitmap = (PIXRGB *)malloc(bitmap_x*bitmap_y*sizeof(PIXRGB)); for( int i=0; i<=bitmap_x*bitmap_y; i++ ) { bitmap[i] = TRANSPARENT; @@ -538,7 +713,7 @@ /* Create tile by tile */ sun_abs = sqrt( sun[0]*sun[0] + sun[1]*sun[1] + sun[2]*sun[2] ); base_brightness = 128 - (int)(brightness*sun[2]/(sun_abs+1.0)); - for( i=0; i<=80; i++ ) { + for( i=0; i<=255; i++ ) { CreateSlope( i, bitmap + pak*(i%row) + (i / row)*bitmap_x*pak, bitmap_x ); } }