ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.155 by root, Thu Dec 17 02:49:38 2009 UTC vs.
Revision 1.158 by root, Mon Dec 21 23:52:34 2009 UTC

396} 396}
397 397
398sub scroll { 398sub scroll {
399 my ($self, $dx, $dy) = @_; 399 my ($self, $dx, $dy) = @_;
400 400
401 $::MAP->scroll ($dx, $dy);
402
403 $self->{last_fow_texture} = $self->{fow_texture};
404 $self->{ldx} = $self->{sdx} + $dx * $self->{tilesize}; # smooth displacement
405 $self->{ldy} = $self->{sdy} + $dy * $self->{tilesize};
406
407 $self->movement_update; 401 $self->movement_update;
408 402
409 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement 403 $self->{sdx} += $dx * $self->{tilesize}; # smooth displacement
410 $self->{sdy} += $dy * $self->{tilesize}; 404 $self->{sdy} += $dy * $self->{tilesize};
405
406 # save old fow texture, if applicable
407 $self->{last_fow_texture} = $self->{fow_texture}
408 if $::CFG->{smooth_transitions};
409 $self->{lfdx} = $dx;
410 $self->{lfdy} = $dy;
411 $self->{lmdx} = $self->{dx};
412 $self->{lmdy} = $self->{dy};
413
414 $::MAP->scroll ($dx, $dy);
411} 415}
412 416
413sub set_magicmap { 417sub set_magicmap {
414 my ($self, $w, $h, $x, $y, $data) = @_; 418 my ($self, $w, $h, $x, $y, $data) = @_;
415 419
486 490
487 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx; 491 my $dx = $self->{dx} = DC::ceil 0.5 * ($::MAP->w - $sw) - $sx;
488 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; 492 my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy;
489 493
490 if ($::CFG->{fow_enable}) { 494 if ($::CFG->{fow_enable}) {
491 my ($sdx_t, $sdy_t);#d# do not anchor at player 495 # draw_fow_texture REQUIRES the fow texture to stay the same size.
492
493 my ($w, $h, $data) = $::MAP->fow_texture ( 496 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
494 $dx + (min 0, $sdx_t),
495 $dy + (min 0, $sdy_t),
496 $sw + abs $sdx_t,
497 $sh + abs $sdy_t
498 );
499 497
500 $self->{fow_texture} = new DC::Texture 498 $self->{fow_texture} = new DC::Texture
501 w => $w, 499 w => $w,
502 h => $h, 500 h => $h,
503 data => $data, 501 data => $data,
504 internalformat => GL_INTENSITY, 502 internalformat => GL_ALPHA,
505 format => GL_LUMINANCE; 503 format => GL_ALPHA;
506 } else { 504 } else {
507 delete $self->{fow_texture}; 505 delete $self->{fow_texture};
508 } 506 }
509 507
510 glNewList ($self->{list} ||= glGenList); 508 glNewList ($self->{list} ||= glGenList);
517 $::MAP->draw ($dx, $dy, $sw, $sh, 515 $::MAP->draw ($dx, $dy, $sw, $sh,
518 $self->{tilesize}, 516 $self->{tilesize},
519 $::CONN->{player}{tag}, 517 $::CONN->{player}{tag},
520 -$self->{sdx}, -$self->{sdy}); 518 -$self->{sdx}, -$self->{sdy});
521 519
522 #d#glTranslate -$self->{sdx}, -$self->{sdy}; # anchor fow at player
523 glScale $self->{tilesize}, $self->{tilesize}; 520 glScale $self->{tilesize}, $self->{tilesize};
524 521
525 if (my $tex = $self->{fow_texture}) { 522 if (my $tex = $self->{fow_texture}) {
526 if (0 && $self->{last_fow_texture}) { 523 if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d#
527 my $d1 = ($self->{sdx} ** 2 + $self->{sdy} ** 2) ** 0.5; 524 my $d1 = DC::distance $self->{sdx}, $self->{sdy};
528 my $d2 = ($self->{ldx} ** 2 + $self->{ldy} ** 2) ** 0.5; 525 my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize;
529 526
530 if ($d1 * $d2) { 527 if ($d1 * $d2) {
531 my $a2 = $d1 / $d2; 528 DC::Texture::draw_fow_texture
532 my $a1 = 1 - $a2;
533
534 #$a1 *= 0.9;
535 #$a2 *= 0.9;
536
537 printf "%8g %8g %8g %8g\n", $d1, $d2, $a1, $a2;#d#
538
539 #$a1 = 1 - (1-$a1) * 0.707;
540 #$a2 = 1 - (1-$a2) * 0.707;
541
542 glColor 1,0,0,1;
543 glBegin GL_QUADS;
544 glVertex 10 + $sdx_t, 10;
545 glVertex 11 + $sdx_t, 10;
546 glVertex 11 + $sdx_t, 11;
547 glVertex 10 + $sdx_t, 11;
548 glEnd;
549
550 if(0){
551 glBlendFunc GL_ZERO, GL_DST_COLOR;
552 glColor +($::CFG->{fow_intensity}) x 3, $a2; 529 $::CFG->{fow_intensity},
553 glPushMatrix; 530 $self->{hidden_tex}{name},
554 glTranslate $sdx_t, $sdy_t; # anchor at player 531 @{$self->{fow_texture}}{qw(name data s t w h)},
555 glTranslate $self->{ldx} / -$tilesize, $self->{ldy} / -$tilesize; 532 (min 1, $d1 / $d2),
556 glScale 1/3, 1/3; 533 $self->{lmdx} - $dx - $self->{lfdx},
557 $self->{last_fow_texture}->draw_quad_alpha (0, 0); 534 $self->{lmdy} - $dy - $self->{lfdy},
558 glPopMatrix; 535 @{$self->{last_fow_texture}}{qw(name data)};
559 }
560 } else { 536 } else {
561 delete $self->{last_fow_texture}; 537 delete $self->{last_fow_texture};
562 } 538 }
563 } else { 539 }
540
541 unless ($self->{last_fow_texture}) {
564 DC::Texture::draw_fow_texture 542 DC::Texture::draw_fow_texture
565 $::CFG->{fow_intensity}, 543 $::CFG->{fow_intensity},
544 $self->{hidden_tex}{name},
566 @{$self->{fow_texture}}{qw(name s t w h)}; 545 @{$self->{fow_texture}}{qw(name data s t w h)};
567 #d#glTranslate +(min 0, $sdx_t), (min 0, $sdy_t); # anchor at player
568 } 546 }
569 } 547 }
570 548
571 if ($self->{magicmap}) { 549 if ($self->{magicmap}) {
572 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} }; 550 my ($x, $y, $w, $h, $data) = @{ $self->{magicmap} };
574 $x += $::MAP->ox + $self->{dx}; 552 $x += $::MAP->ox + $self->{dx};
575 $y += $::MAP->oy + $self->{dy}; 553 $y += $::MAP->oy + $self->{dy};
576 554
577 glTranslate - $x - 1, - $y - 1; 555 glTranslate - $x - 1, - $y - 1;
578 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name}; 556 glBindTexture GL_TEXTURE_2D, $magicmap_tex->{name};
579 $::MAP->draw_magicmap ($x, $y, $w, $h, $data); 557 $::MAP->draw_magicmap ($w, $h, $data);
580 } 558 }
581 559
582 glPopMatrix; 560 glPopMatrix;
583 glEndList; 561 glEndList;
584 } 562 }
585 } else { 563 } else {
564 delete $self->{last_fow_texture};
565 delete $self->{fow_texture};
566
586 glDeleteList delete $self->{list} 567 glDeleteList delete $self->{list}
587 if $self->{list}; 568 if $self->{list};
588 } 569 }
589} 570}
590 571

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines