Changeset 472 for GraphicTest/Packages/bgrabitmap/polyaliaspersp.inc
- Timestamp:
- Apr 9, 2015, 9:58:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/polyaliaspersp.inc
r452 r472 3 3 4 4 { TPolygonPerspectiveTextureMappingInfo } 5 6 procedure TPolygonPerspectiveTextureMappingInfo.SetIntersectionValues( 7 AInter: TIntersectionInfo; AInterX: Single; AWinding, ANumSegment: integer; 8 dy: single; AData: pointer); 9 var info: PPerspectiveTextureInfo; 10 begin 11 AInter.SetValues(AInterX,AWinding,ANumSegment); 12 info := PPerspectiveTextureInfo(AData); 13 TPerspectiveTextureMappingIntersectionInfo(AInter).coordInvZ := dy*info^.InvZSlope + info^.InvZ; 14 TPerspectiveTextureMappingIntersectionInfo(AInter).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy; 15 if FLightnesses<>nil then 16 TPerspectiveTextureMappingIntersectionInfo(AInter).lightness := round(info^.lightness + info^.lightnessSlope*dy) 17 else 18 TPerspectiveTextureMappingIntersectionInfo(AInter).lightness := 32768; 19 end; 5 20 6 21 constructor TPolygonPerspectiveTextureMappingInfo.Create( … … 108 123 begin 109 124 Result:= TPerspectiveTextureMappingIntersectionInfo.Create; 110 end;111 112 procedure TPolygonPerspectiveTextureMappingInfo.ComputeIntersection(cury: single;113 var inter: ArrayOfTIntersectionInfo; var nbInter: integer);114 var115 j: integer;116 dy: single;117 info: PPerspectiveTextureInfo;118 begin119 if length(FSlices)=0 then exit;120 121 while (cury < FSlices[FCurSlice].y1) and (FCurSlice > 0) do dec(FCurSlice);122 while (cury > FSlices[FCurSlice].y2) and (FCurSlice < high(FSlices)) do inc(FCurSlice);123 with FSlices[FCurSlice] do124 if (cury >= y1) and (cury <= y2) then125 begin126 for j := 0 to nbSegments-1 do127 begin128 dy := cury - segments[j].y1;129 inter[nbinter].interX := dy * segments[j].slope + segments[j].x1;130 inter[nbinter].winding := segments[j].winding;131 info := PPerspectiveTextureInfo(segments[j].data);132 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).coordInvZ := dy*info^.InvZSlope + info^.InvZ;133 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;134 if FLightnesses<>nil then135 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).lightness := round(info^.lightness + info^.lightnessSlope*dy)136 else137 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).lightness := 32768;138 Inc(nbinter);139 end;140 end;141 125 end; 142 126 … … 495 479 { TPolygonPerspectiveMappingShaderInfo } 496 480 481 procedure TPolygonPerspectiveMappingShaderInfo.SetIntersectionValues( 482 AInter: TIntersectionInfo; AInterX: Single; AWinding, ANumSegment: integer; 483 dy: single; AData: pointer); 484 var info : PPerspectiveTextureInfo; 485 begin 486 AInter.SetValues(AInterX,AWinding,ANumSegment); 487 info := PPerspectiveTextureInfo(AData); 488 TPerspectiveTextureMappingIntersectionInfo(AInter).coordInvZ := dy*info^.InvZSlope + info^.InvZ; 489 TPerspectiveTextureMappingIntersectionInfo(AInter).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy; 490 TPerspectiveTextureMappingIntersectionInfo(AInter).Position3D := info^.Position3D + info^.Position3DSlope*dy; 491 TPerspectiveTextureMappingIntersectionInfo(AInter).Normal3D := info^.Normal3D + info^.Normal3DSlope*dy; 492 end; 493 497 494 constructor TPolygonPerspectiveMappingShaderInfo.Create( 498 495 const points: array of TPointF; const points3D: array of TPoint3D; … … 608 605 end; 609 606 610 procedure TPolygonPerspectiveMappingShaderInfo.ComputeIntersection(611 cury: single; var inter: ArrayOfTIntersectionInfo; var nbInter: integer);612 var613 j: integer;614 dy: single;615 info: PPerspectiveTextureInfo;616 begin617 if length(FSlices)=0 then exit;618 619 while (cury < FSlices[FCurSlice].y1) and (FCurSlice > 0) do dec(FCurSlice);620 while (cury > FSlices[FCurSlice].y2) and (FCurSlice < high(FSlices)) do inc(FCurSlice);621 with FSlices[FCurSlice] do622 if (cury >= y1) and (cury <= y2) then623 begin624 for j := 0 to nbSegments-1 do625 begin626 dy := cury - segments[j].y1;627 inter[nbinter].interX := dy * segments[j].slope + segments[j].x1;628 inter[nbinter].winding := segments[j].winding;629 info := PPerspectiveTextureInfo(segments[j].data);630 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).coordInvZ := dy*info^.InvZSlope + info^.InvZ;631 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).texCoordDivByZ := info^.TexCoordDivByZ + info^.TexCoordDivByZSlopes*dy;632 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).Position3D := info^.Position3D + info^.Position3DSlope*dy;633 TPerspectiveTextureMappingIntersectionInfo(inter[nbinter]).Normal3D := info^.Normal3D + info^.Normal3DSlope*dy;634 Inc(nbinter);635 end;636 end;637 end;638
Note:
See TracChangeset
for help on using the changeset viewer.