Board index » delphi » Polygons and Textured Polygons

Polygons and Textured Polygons

Does anyone know of where I can find good source to replace Delphi's
polygon() method?  I am also looking for a textured polygon procedure as
well for 4 sided images.

If you have some old source that is for Turbo Pascal, I may be able to use
it by converting it to delphi.  Most of the source I've seen had lots of
spagetti code.  If they were well comented, it would have made made my life
easier.

-rottweiler

 

Re:Polygons and Textured Polygons


Check the Delphi Infomant site. There was an article on this several months
ago.

http://www.informant.com/delphi

Quote
"Steven J. Morales" wrote:
> Does anyone know of where I can find good source to replace Delphi's
> polygon() method?  I am also looking for a textured polygon procedure as
> well for 4 sided images.

> If you have some old source that is for Turbo Pascal, I may be able to use
> it by converting it to delphi.  Most of the source I've seen had lots of
> spagetti code.  If they were well comented, it would have made made my life
> easier.

> -rottweiler

Re:Polygons and Textured Polygons


Check the Delphi Infomant site. There was an article with code on this several months
ago.

http://www.informant.com/delphi

Quote
"Steven J. Morales" wrote:
> Does anyone know of where I can find good source to replace Delphi's
> polygon() method?  I am also looking for a textured polygon procedure as
> well for 4 sided images.

> If you have some old source that is for Turbo Pascal, I may be able to use
> it by converting it to delphi.  Most of the source I've seen had lots of
> spagetti code.  If they were well comented, it would have made made my life
> easier.

> -rottweiler

Re:Polygons and Textured Polygons


Quote
Eddie Shipman <ship...@inetport.com> wrote in message

news:373AED5C.C0094987@inetport.com...

Quote
> Check the Delphi Infomant site. There was an article on this several months
> ago.

> http://www.informant.com/delphi

Links to the whole series of Delphi Informant Graphics articles can be found at
http://www.efg2.com/lab/library/Delphi/Graphics/Algorithms.htm#Graphics

For example, the direct link to Part III, Mar 97: "Texture Mapping" (pp. 74-82)
is
http://www.informant.com/libs/delphi/2x/DI9703DP.ZIP

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:Polygons and Textured Polygons


Hey, Earl, do you have a link to "How to program my Toaster Oven to make my bagel 66% brown"
on your efg site? <RBG>
Seems you have everything there!!!
Quote
"Earl F. Glynn" wrote:
> Eddie Shipman <ship...@inetport.com> wrote in message
> news:373AED5C.C0094987@inetport.com...
> > Check the Delphi Infomant site. There was an article on this several months
> > ago.

> > http://www.informant.com/delphi

> Links to the whole series of Delphi Informant Graphics articles can be found at
> http://www.efg2.com/lab/library/Delphi/Graphics/Algorithms.htm#Graphics

> For example, the direct link to Part III, Mar 97: "Texture Mapping" (pp. 74-82)
> is
> http://www.informant.com/libs/delphi/2x/DI9703DP.ZIP

> efg
> _________________________________
> efg's Computer Lab:       www.efg2.com/lab
> Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

> Earl F. Glynn     E-Mail:  EarlGl...@att.net
> Overland Park, KS  USA

Re:Polygons and Textured Polygons


Quote
Eddie Shipman <ship...@inetport.com> wrote in message

news:373AFE3E.BA6CCDBD@inetport.com...

Quote
> Hey, Earl, do you have a link to "How to program my Toaster Oven to make my
bagel 66% brown"
> on your efg site? <RBG>
> Seems you have everything there!!!

I guess I'll have to add that link to my Color page.  :)
Do you use Delphi in your Toaster Oven?
(I have Delphi and non-Delphi color info!)

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:Polygons and Textured Polygons


Another note:

I've found some good source that uses the GMP unit.  It works pretty good in
the demos, but I've been having trouble extracting the texture mapper part
from the rest of it.  All I want is a simple procedure that will take a
source and a destination bitmap and display it on the destination at the
points provided.  I don't really want to deal with premade packages.  I may
look at the GMP unit and see if I can adapt it, but I'd prefer just the
following...

Texture4Polygon(X1,Y1,X2,Y2,X3,Y3,X4,Y4:TPoint; SRC, DST : TBitmap);

Re:Polygons and Textured Polygons


On Mon, 17 May 1999 14:43:29 -0400, "Steven J. Morales"

Quote
<smora...@twinlab.com> wrote:
>Another note:

>I've found some good source that uses the GMP unit.  It works pretty good in
>the demos, but I've been having trouble extracting the texture mapper part
>from the rest of it.  All I want is a simple procedure that will take a
>source and a destination bitmap and display it on the destination at the
>points provided.  I don't really want to deal with premade packages.  I may
>look at the GMP unit and see if I can adapt it, but I'd prefer just the
>following...

>Texture4Polygon(X1,Y1,X2,Y2,X3,Y3,X4,Y4:TPoint; SRC, DST : TBitmap);

Well, here's my variation of the theme, not the most efficient as I
only have Delphi2 (no scanline), but it works for me...

procedure TexMap(Bmp: TBitmap; Dst: TCanvas; P0, P1, P2: TPoint; Bl:
Boolean; Blimit: double);
var
  sx, sy, kx, ky: double;
  tx, ty:         integer;
  x, y:           integer;
  xp, yp:         integer;
  w, h:           integer;
  k1,k2:          double;
  cl:             TColor;
  xpd, ypd:       double;
  d1, d2:         double;
  c20x, c10y:     integer;
  x0, x1, y0, y1: integer;
  P3:             TPoint;
  Trns:           TColor;

begin
  w := Bmp.Width;
  h := Bmp.Height;
  P3.x := P0.x + (P1.x-P0.x) + (P2.x - P0.x);
  P3.y := P0.y + (P1.y-P0.y) + (P2.y - P0.y);
  c20x := (P2.x - P0.x);
  c10y := (P1.y - P0.y);
  if (c20x = 0) then
    c20x := 1;
  if (c10y = 0) then
    c10y := 1;
  sx := c20x / w;
  sy := c10y / h;
  tx := P0.x;
  ty := P0.y;
  kx := (P2.y - P0.y) / c20x;
  ky := (P1.x - P0.x) / c10y;
  k1 := 1.0 / (sx-kx*ky*sx);
  k2 := 1.0 / (sy-kx*ky*sy);
  x0 := Min(P0.x, Min(P1.x, Min(P2.x, P3.x)));
  x1 := Max(P0.x, Max(P1.x, Max(P2.x, P3.x)));
  y0 := Min(P0.y, Min(P1.y, Min(P2.y, P3.y)));
  y1 := Max(P0.y, Max(P1.y, Max(P2.y, P3.y)));
  Trns := Bmp.Canvas.Pixels[0,0];
  for y := y0 to y1 do begin
    for x := x0 to x1 do begin
      xpd := (x - tx - ky*(y-ty)) * k1;
      ypd := (y - ty - kx*(x-tx)) * k2;
      xp := Round(xpd);
      yp := Round(ypd);
      d1 := (xpd - xp);
      d2 := (ypd - yp);
      cl := Bmp.Canvas.Pixels[xp,yp];
      if (cl <> -1) and (cl <> Trns)
      then begin
        if Bl then begin
          if (d1 < -Blimit) then
            cl := Blend(cl, Bmp.Canvas.Pixels[xp-1,yp],-d1)
          else if (d1 > Blimit) then
            cl := Blend(cl, Bmp.Canvas.Pixels[xp+1,yp],d1);
          if (d2 < -Blimit) then
            cl := Blend(cl, Bmp.Canvas.Pixels[xp,yp-1],-d2)
          else if (d2 > Blimit) then
            cl := Blend(cl, Bmp.Canvas.Pixels[xp,yp+1],d2)
        end;
        Dst.Pixels[x, y] := cl;
      end
    end
  end
end;

------------------------------------
Anders Isaksson, Sweden

BlockCAD: http://user.tninet.se/~hbh828t/proglego.htm
Gallery:  http://user.tninet.se/~hbh828t/gallery.htm

Other Threads