… | |
… | |
1043 | |
1043 | |
1044 | glDepthMask 1; |
1044 | glDepthMask 1; |
1045 | glClear GL_DEPTH_BUFFER_BIT; |
1045 | glClear GL_DEPTH_BUFFER_BIT; |
1046 | glEnable GL_TEXTURE_2D; |
1046 | glEnable GL_TEXTURE_2D; |
1047 | glEnable GL_DEPTH_TEST; |
1047 | glEnable GL_DEPTH_TEST; |
1048 | glDisable GL_CULL_FACE; |
1048 | glEnable GL_CULL_FACE; |
1049 | glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH; |
1049 | glShadeModel $::FAST ? GL_FLAT : GL_SMOOTH; |
1050 | |
1050 | |
1051 | glMatrixMode GL_PROJECTION; |
1051 | glMatrixMode GL_PROJECTION; |
1052 | glLoadIdentity; |
1052 | glLoadIdentity; |
1053 | #glFrustum -100, 100, 100, -100, 1, 1000; |
1053 | glFrustum -1 * ($::WIDTH / $::HEIGHT), 1 * ($::WIDTH / $::HEIGHT), 1, -1, 1, 10000; |
1054 | glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
1054 | #glOrtho 0, $::WIDTH, 0, $::HEIGHT, -10000, 10000; |
1055 | glMatrixMode GL_MODELVIEW; |
1055 | glMatrixMode GL_MODELVIEW; |
1056 | glLoadIdentity; |
1056 | glLoadIdentity; |
1057 | |
1057 | |
1058 | glPushMatrix; |
1058 | glPushMatrix; |
1059 | glTranslate $::WIDTH * 0.5, $::HEIGHT * 0.5, -100; |
1059 | glTranslate 0, 0, -800; |
|
|
1060 | glScale 1, -1, 1; |
1060 | glRotate $NOW * 1000 % 36000 / 20, 0, 1, 0; |
1061 | glRotate $NOW * 1000 % 36000 / 5, 0, 1, 0; |
|
|
1062 | glRotate $NOW * 1000 % 36000 / 6, 1, 0, 0; |
|
|
1063 | glRotate $NOW * 1000 % 36000 / 7, 0, 0, 1; |
1061 | glScale 50, 50, 50; |
1064 | glScale 50, 50, 50; |
1062 | |
1065 | |
1063 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
1066 | glInterleavedArrays GL_T2F_N3F_V3F, 0, $r->{v}; |
1064 | while (my ($k, $v) = each %{$r->{g}}) { |
1067 | while (my ($k, $v) = each %{$r->{g}}) { |
1065 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
1068 | glBindTexture GL_TEXTURE_2D, ($demo{t}{$k}{name} or die); |
… | |
… | |
1210 | $self->set_texture ($id => $data); |
1213 | $self->set_texture ($id => $data); |
1211 | } |
1214 | } |
1212 | } |
1215 | } |
1213 | } |
1216 | } |
1214 | |
1217 | |
|
|
1218 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
|
|
1219 | # (server resource,s latency, bandwidth), so this hack is warranted. |
|
|
1220 | # the right fix is to make real tiled maps with an overview file |
|
|
1221 | sub conn::send_mapinfo { |
|
|
1222 | my ($self, $data, $cb) = @_; |
|
|
1223 | |
|
|
1224 | if ($self->{map_info}[0] =~ m%^/world/world_(\d\d\d)_(\d\d\d)$%) { |
|
|
1225 | my ($wx, $wy) = ($1, $2); |
|
|
1226 | |
|
|
1227 | if ($data =~ /^spatial ([1-4]+)$/) { |
|
|
1228 | my @dx = (0, 0, 1, 0, -1); |
|
|
1229 | my @dy = (0, -1, 0, 1, 0); |
|
|
1230 | my ($dx, $dy); |
|
|
1231 | |
|
|
1232 | for (split //, $1) { |
|
|
1233 | $dx += $dx[$_]; |
|
|
1234 | $dy += $dy[$_]; |
|
|
1235 | } |
|
|
1236 | |
|
|
1237 | $cb->(spatial => 15, |
|
|
1238 | $self->{map_info}[1] - $MAP->ox + $dx * 50, |
|
|
1239 | $self->{map_info}[2] - $MAP->oy + $dy * 50, |
|
|
1240 | 50, 50, |
|
|
1241 | sprintf "/world/world_%03d_%03d", $wx + $dx, $wy + $dy |
|
|
1242 | ); |
|
|
1243 | |
|
|
1244 | return; |
|
|
1245 | } |
|
|
1246 | } |
|
|
1247 | |
|
|
1248 | $self->SUPER::send_mapinfo ($data, $cb); |
|
|
1249 | } |
|
|
1250 | |
1215 | # this method does a "flood fill" into every tile direction |
1251 | # this method does a "flood fill" into every tile direction |
1216 | # it assumes that tiles are arranged in a rectangular grid, |
1252 | # it assumes that tiles are arranged in a rectangular grid, |
1217 | # i.e. a map is the same as the left of the right map etc. |
1253 | # i.e. a map is the same as the left of the right map etc. |
1218 | # failure to comply are harmless and result in display errors |
1254 | # failure to comply are harmless and result in display errors |
1219 | # at worst. |
1255 | # at worst. |
1220 | sub conn::flood_fill { |
1256 | sub conn::flood_fill { |
1221 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
1257 | my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; |
1222 | |
1258 | |
1223 | # the server does not allow map paths > 6 |
1259 | # the server does not allow map paths > 6 |
1224 | return if 7 <= length $path; |
1260 | return if 7 <= length $path; |
1225 | |
1261 | |
1226 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1262 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
1227 | |
1263 | |
1228 | for ( |
1264 | for ( |
1229 | [1, 0, -1], |
1265 | [1, 3, 0, -1], |
1230 | [2, 1, 0], |
1266 | [2, 4, 1, 0], |
1231 | [3, 0, 1], |
1267 | [3, 1, 0, 1], |
1232 | [4, -1, 0], |
1268 | [4, 2, -1, 0], |
1233 | ) { |
1269 | ) { |
1234 | my ($tile, $dx, $dy) = @$_; |
1270 | my ($tile, $tile2, $dx, $dy) = @$_; |
|
|
1271 | |
|
|
1272 | next if $block & (1 << $tile); |
|
|
1273 | my $block = $block | (1 << $tile2); |
1235 | |
1274 | |
1236 | my $gx = $gx + $dx; |
1275 | my $gx = $gx + $dx; |
1237 | my $gy = $gy + $dy; |
1276 | my $gy = $gy + $dy; |
1238 | |
1277 | |
1239 | next unless $flags & (1 << ($tile - 1)); |
1278 | next unless $flags & (1 << ($tile - 1)); |
… | |
… | |
1241 | |
1280 | |
1242 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1281 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
1243 | if (my $info = $neigh->[$tile]) { |
1282 | if (my $info = $neigh->[$tile]) { |
1244 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1283 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
1245 | |
1284 | |
1246 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1285 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1247 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1286 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1248 | |
1287 | |
1249 | } else { |
1288 | } else { |
1250 | $self->send_mapinfo ("spatial $path$tile", sub { |
1289 | $self->send_mapinfo ("spatial $path$tile", sub { |
1251 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1290 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
1252 | |
1291 | |
1253 | return if $mode ne "spatial"; |
1292 | return if $mode ne "spatial"; |
1254 | |
1293 | |
1255 | $x += $MAP->ox; |
1294 | $x += $MAP->ox; |
1256 | $y += $MAP->oy; |
1295 | $y += $MAP->oy; |
1257 | |
1296 | |
1258 | $self->load_map ($hash, $x, $y) |
1297 | $self->load_map ($hash, $x, $y) |
1259 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1298 | unless $self->{neigh_map}{$hash}[5]++;#d# |
1260 | |
1299 | |
1261 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1300 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
1262 | |
1301 | |
1263 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
1302 | $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) |
1264 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1303 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
1265 | }); |
1304 | }); |
1266 | } |
1305 | } |
1267 | } |
1306 | } |
1268 | } |
1307 | } |
… | |
… | |
1281 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1320 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
1282 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1321 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
1283 | ]; |
1322 | ]; |
1284 | |
1323 | |
1285 | delete $self->{neigh_grid}; |
1324 | delete $self->{neigh_grid}; |
1286 | $self->flood_fill (0, 0, "", $hash, $flags); |
|
|
1287 | |
1325 | |
1288 | $x += $ox; |
1326 | $x += $ox; |
1289 | $y += $oy; |
1327 | $y += $oy; |
1290 | |
1328 | |
1291 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1329 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
1292 | |
1330 | |
1293 | my $map = $self->{map_info}[0]; |
|
|
1294 | $map =~ s/^.*?\/([^\/]+)$/\1/; |
1331 | (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; |
1295 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1332 | $STATWIDS->{map}->set_text ("Map: " . $map); |
1296 | |
1333 | |
1297 | $self->load_map ($hash, $x, $y); |
1334 | $self->load_map ($hash, $x, $y); |
|
|
1335 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
1298 | } |
1336 | } |
1299 | |
1337 | |
1300 | sub conn::face_find { |
1338 | sub conn::face_find { |
1301 | my ($self, $facenum, $face) = @_; |
1339 | my ($self, $facenum, $face) = @_; |
1302 | |
1340 | |