- procedure TfrmXY.PaintBoxXYClick(Sender: TObject);
- var
- i,count : integer;
- v : Tvertex;
- f : TFace;
- VertexRec,MausRec,resultRec,SphereRec : TRect;
- FaceRegion,FaceRegion2 : HRGN;
- V1,V2,V3,V4 : TPoint;
- points : array[1..4] of TPoint;
- points2 : array[1..4] of TPoint;
- s : TSphere;
- MinZ : Single;
- SelItem: Integer;
- begin
- ...
- MausRec.Left := FPaintMous.X-1;
- MausRec.Top := FPaintMous.y-1;
- MausRec.Right := MausRec.Left +2;
- MausRec.Bottom := MausRec.Top +2;
- //Vertices durchgehen
- MinZ := -MaxInt;
- SelItem := -1;
- for i:=0 to FVertexList.Count-1 do begin
- //vertex berechnen
- if IntersectRect(resultRec,VertexRec,MausRec) then
- if TVertex(FVertexList.Objects[i]).FZ > MinZ then begin
- SelItem := i;
- MinZ := v.z;
- end;
- end;
- // nachdem alle Punkte geprüft wurden.
- if (SelItem >= 0) then begin
- v := Tvertex(FVertexList.Objects[SelItem]);
- ...
- end;
- //Faces durchgehen
- MinZ := -MaxInt;
- SelItem := -1;
- for i:=0 to FFaceList.Count-1 do begin
- //Region eins erstellen
- V1.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V1.Fx * FZoom)+Round(VerticesDraw.Size * 20);
- V1.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V1.FY * FZoom)+Round(VerticesDraw.Size * 170);
- V2.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V2.Fx * FZoom)+Round(VerticesDraw.Size * 170);
- V2.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V2.FY * FZoom)+Round(VerticesDraw.Size * 170);
- V3.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V3.Fx * FZoom)+Round(VerticesDraw.Size * 170);
- V3.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V3.FY * FZoom)+Round(VerticesDraw.Size * 20);
- V4.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V4.Fx * FZoom)+Round(VerticesDraw.Size * 20);
- V4.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V4.FY * FZoom)+Round(VerticesDraw.Size * 20);
- points[1] := v1;
- points[2] := v2;
- points[3] := v3;
- points[4] := v4;
- count := 4;
- FaceRegion := CreatePolygonRgn(points,count,WINDING);
- //region zwei erstellen
- V1.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V1.Fx * FZoom)+Round((VerticesDraw.Size*180));// * 100
- V1.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V1.FY * FZoom)+Round((VerticesDraw.Size*50));// /80
- V2.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V2.Fx * FZoom)+Round((VerticesDraw.Size*50));// /80
- V2.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V2.FY * FZoom)+Round((VerticesDraw.Size*50));// /80
- V3.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V3.Fx * FZoom)+Round((VerticesDraw.Size*50));// /80
- V3.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V3.FY * FZoom)+Round((VerticesDraw.Size*180));
- V4.X := ScrollBarZoomX.Position + Round(+TFace(FFaceList.Objects[i]).V4.Fx * FZoom)+Round((VerticesDraw.Size*180));
- V4.Y := ScrollBarZoomY.Position + Round(-TFace(FFaceList.Objects[i]).V4.FY * FZoom)+Round((VerticesDraw.Size*180));
- points2[1] := v1;
- points2[2] := v2;
- points2[3] := v3;
- points2[4] := v4;
- count := 4;
- FaceRegion2 := CreatePolygonRgn(points2,count,WINDING);
- if RectInRegion(FaceRegion,MausRec) then
- if not RectInRegion(FaceRegion2,MausRec) then
- if Tface(FFaceList.Objects[i]).V1.Fz > MinZ then begin
- SelItem := i;
- MinZ := Tface(FFaceList.Objects[i]).V1.Fz;
- end;
- end;
- if (SelItem >= 0) then begin
- f := TFace(FFaceList.Objects[SelItem]);
- ...
- end;