GDI+ Spielerei 3D-Linien

  • Nach langer Pause hab ich mich mal wieder mit GDI+ gespielt.

    viel Vergnügen!

    autoit.de/wcf/attachment/15295/

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <WinAPI.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 500
    Global $iHeight = 400
    Global $iStyle = $GUI_SS_DEFAULT_GUI, $iExStyle = 0, $iX = -1, $iY = -1

    [/autoit] [autoit][/autoit] [autoit]

    If MsgBox(4, "Fullscreen?", "Fullscreen?") = 6 Then
    $iWidth = @DesktopWidth
    $iHeight = @DesktopHeight
    $iStyle = $WS_POPUP
    $iExStyle = $WS_EX_TOPMOST
    $iX = 0
    $iY = 0
    _WinAPI_ShowCursor(False)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Global $iPlanes = 16
    Global $iLines = 32
    Global $iCount = $iPlanes * $iLines
    Global $fPersp = 0.04
    Global $fSpeed = 0.2

    [/autoit] [autoit][/autoit] [autoit]

    Global $hMatrix_Speed = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix_Speed, 0, $fSpeed)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_V = DllStructCreate("float[8];")
    Global $pWarp_V = DllStructGetPtr($tWarp_V)
    DllStructSetData($tWarp_V, 1, 0, 1)
    DllStructSetData($tWarp_V, 1, $iHeight, 2)
    DllStructSetData($tWarp_V, 1, 0, 3)
    DllStructSetData($tWarp_V, 1, 0, 4)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 5)
    DllStructSetData($tWarp_V, 1, ($iHeight / 2) + ($iHeight * $fPersp), 6)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 7)
    DllStructSetData($tWarp_V, 1, ($iHeight / 2) - ($iHeight * $fPersp), 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_H = DllStructCreate("float[8];")
    Global $pWarp_H = DllStructGetPtr($tWarp_H)
    DllStructSetData($tWarp_H, 1, $iWidth, 1)
    DllStructSetData($tWarp_H, 1, $iHeight, 2)
    DllStructSetData($tWarp_H, 1, 0, 3)
    DllStructSetData($tWarp_H, 1, $iHeight, 4)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) + ($iWidth * $fPersp), 5)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 6)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) - ($iWidth * $fPersp), 7)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tData = DllStructCreate("int Count; ptr Points; ptr Types;")
    Global $pData = DllStructGetPtr($tData)
    Global $tData_P = DllStructCreate("float[" & $iCount * 2 & "]")
    Global $pData_P = DllStructGetPtr($tData_P)
    Global $tData_T = DllStructCreate("ubyte[" & $iCount & "]")
    Global $pData_T = DllStructGetPtr($tData_T)
    DllStructSetData($tData, "Count", $iCount)
    DllStructSetData($tData, "Points", $pData_P)
    DllStructSetData($tData, "Types", $pData_T)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $tPoints_V = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pPoints_V = DllStructGetPtr($tPoints_V)
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_V, 1, Random(-300, 300), $j * 2 + 1)
    DllStructSetData($tPoints_V, 1, 0, $j * 2 + 2)
    Next
    For $i = 1 To $iPlanes - 1
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_V, 1, _CalcNewPoint(DllStructGetData($tPoints_V, 1, (($i - 1) * $iLines + $j) * 2 + 1)), ($i * $iLines + $j) * 2 + 1)
    DllStructSetData($tPoints_V, 1, $i, ($i * $iLines + $j) * 2 + 2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $tPoints_H = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pPoints_H = DllStructGetPtr($tPoints_H)
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_H, 1, Random(-300, 300), $j * 2 + 1)
    DllStructSetData($tPoints_H, 1, 0, $j * 2 + 2)
    Next
    For $i = 1 To $iPlanes - 1
    For $j = 0 To $iLines - 1
    DllStructSetData($tPoints_H, 1, _CalcNewPoint(DllStructGetData($tPoints_H, 1, (($i - 1) * $iLines + $j) * 2 + 1)), ($i * $iLines + $j) * 2 + 1)
    DllStructSetData($tPoints_H, 1, $i, ($i * $iLines + $j) * 2 + 2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarped_H = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pWarped_H = DllStructGetPtr($tWarped_H)
    Global $tWarped_V = DllStructCreate("float[" & $iCount * 2 & "];")
    Global $pWarped_V = DllStructGetPtr($tWarped_V)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth, $iHeight, $iX, $iY, $iStyle, $iExStyle)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hDC = _WinAPI_GetDC($hGui)
    Global $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight)
    Global $hBmpTmp = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    _WinAPI_DeleteObject($hBMP)
    $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmpTmp)
    _GDIPlus_BitmapDispose($hBmpTmp)
    Global $hCDC = _WinAPI_CreateCompatibleDC($hDC)
    Global $hOBJ = _WinAPI_SelectObject($hCDC, $hBMP)
    Global $hGfxBuffer = _GDIPlus_GraphicsCreateFromHDC($hCDC)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF005500, 1)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Select
    Case _IsPressed("25")
    _Move_H(0.5)
    Case _IsPressed("27")
    _Move_H(-0.5)
    Case _IsPressed("26")
    _Move_V(0.5)
    Case _IsPressed("28")
    _Move_V(-0.5)
    EndSelect
    _Draw()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Move_H($fMove)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    DllCall($ghGDIPDll, "uint", "GdipShearMatrix", "hwnd", $hMatrix, "float", $fMove, "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", $pPoints_H, "int", $iCount)
    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>_Move_H

    [/autoit] [autoit][/autoit] [autoit]

    Func _Move_V($fMove)
    Local $hMatrix = _GDIPlus_MatrixCreate()
    DllCall($ghGDIPDll, "uint", "GdipShearMatrix", "hwnd", $hMatrix, "float", $fMove, "float", 0, "int", 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix, "ptr", $pPoints_V, "int", $iCount)
    _GDIPlus_MatrixDispose($hMatrix)
    EndFunc ;==>_Move_V

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcNewPoint($fOld)
    Local $fTmp
    Do
    $fTmp = Random(-30, 30)
    Until Abs($fOld + $fTmp) < 300; And Abs($fX + $fTmp) > 10
    Return $fOld + $fTmp
    EndFunc ;==>_CalcNewPoint

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix_Speed, "ptr", $pPoints_H, "int", $iCount)
    DllCall($ghGDIPDll, "uint", "GdipTransformMatrixPoints", "hwnd", $hMatrix_Speed, "ptr", $pPoints_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    If DllStructGetData($tPoints_H, 1, 2) >= 1 Then
    Local $fX, $fTmp
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pPoints_H + ($iLines * 8), "ptr", $pPoints_H, "ulong_ptr", DllStructGetSize($tPoints_H) - ($iLines * 8))
    For $i = 1 To $iLines
    DllStructSetData($tPoints_H, 1, _CalcNewPoint(DllStructGetData($tPoints_H, 1, ($i - 1) * 2 + 1)), ($i - 1) * 2 + 1)
    DllStructSetData($tPoints_H, 1, 0, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pPoints_V + ($iLines * 8), "ptr", $pPoints_V, "ulong_ptr", DllStructGetSize($tPoints_V) - ($iLines * 8))
    For $i = 1 To $iLines
    DllStructSetData($tPoints_V, 1, _CalcNewPoint(DllStructGetData($tPoints_V, 1, ($i - 1) * 2 + 1)), ($i - 1) * 2 + 1)
    DllStructSetData($tPoints_V, 1, 0, ($i - 1) * 2 + 2)
    Next
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0)
    Local $hPath_Temp = $aResult[2]
    DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath_Temp, "ptr", $pPoints_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fOff = DllStructGetData($tPoints_H, 1, 2)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathData", "hwnd", $hPath_Temp, "ptr", $pData)

    [/autoit] [autoit][/autoit] [autoit]

    Local $fX1, $fY1, $fX2, $fY2
    For $i = 1 To $iLines
    $fX1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 1)
    $fY1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 2)
    $fX2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 2)
    DllStructSetData($tData_P, 1, $fX1 + ($fX2 - $fX1) * $fOff, ($i - 1) * 2 + 1)
    DllStructSetData($tData_P, 1, $fY1 + ($fY2 - $fY1) * $fOff, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath2", "ptr", $pData_P, "ptr", $pData_T, "int", $iCount, "int", 0, "int*", 0)
    Local $hPath_V = $aResult[5]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", -50, "float", 2, "float", 100, "float", $iPlanes, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipResetPath", "hwnd", $hPath_Temp)
    DllCall($ghGDIPDll, "uint", "GdipAddPathLine2", "hwnd", $hPath_Temp, "ptr", $pPoints_H, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathData", "hwnd", $hPath_Temp, "ptr", $pData)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $iLines
    $fX1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 1)
    $fY1 = DllStructGetData($tData_P, 1, ($iLines + $i - 1) * 2 + 2)
    $fX2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 1)
    $fY2 = DllStructGetData($tData_P, 1, ($i - 1) * 2 + 2)
    DllStructSetData($tData_P, 1, $fX1 + ($fX2 - $fX1) * $fOff, ($i - 1) * 2 + 1)
    DllStructSetData($tData_P, 1, $fY1 + ($fY2 - $fY1) * $fOff, ($i - 1) * 2 + 2)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath2", "ptr", $pData_P, "ptr", $pData_T, "int", $iCount, "int", 0, "int*", 0)
    Local $hPath_H = $aResult[5]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", -50, "float", 2, "float", 100, "float", $iPlanes, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_H, "ptr", $pWarped_H, "int", $iCount)
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_V, "ptr", $pWarped_V, "int", $iCount)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF040008)
    For $i = $iPlanes - 2 To 0 Step -1
    _GDIPlus_PenSetWidth($hPen, _CalcPenW(DllStructGetData($tPoints_H, 1, ($i * $iLines) * 2 + 2), $iPlanes, 2))
    _GDIPlus_PenSetColor($hPen, BitOR(BitShift(0xFF - ($i * 0xFF / $iPlanes), -24), BitShift(0xFF - ($i * 0xFF / $iPlanes), -16), ($i * 0xFF / $iPlanes)))
    For $j = 0 To $iLines - 1
    $fX1 = DllStructGetData($tWarped_H, 1, ($i * $iLines + $j) * 2 + 1)
    $fY1 = DllStructGetData($tWarped_V, 1, ($i * $iLines + $j) * 2 + 2)
    $fX2 = DllStructGetData($tWarped_H, 1, (($i + 1) * $iLines + $j) * 2 + 1)
    $fY2 = DllStructGetData($tWarped_V, 1, (($i + 1) * $iLines + $j) * 2 + 2)
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $fX1, "float", $fY1, "float", $fX2, "float", $fY2)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_Temp)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CalcPenW($fVal, $iRange, $iMax)
    Local $fW = (Log($iRange * 2) - Log($fVal + 1)) * $iMax
    Return $fW
    EndFunc ;==>_CalcPenW

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hCDC, 0, 0, 0x00CC0020)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_MatrixDispose($hMatrix_Speed)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _WinAPI_SelectObject($hCDC, $hOBJ)
    _WinAPI_DeleteObject($hBMP)
    _WinAPI_DeleteDC($hCDC)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    E

    Edit.: sollte nun auch auf älteren AutoIt Versionen laufen...

  • Sieht sehr toll aus und würde sich sicher gut als Bildschirmschoner eignen.
    Ich kenn mich nicht sehr gut mir Dlls aus etc, aber du benutzt sehr viele Dlls Calls und Structs, könntest du mir evtl erklären wozu die alle sind und was das für Vorteile bringt?
    Gruß

    Edit// Bei mir stürzt es nicht ab. Win7 64Bit

    mfg BB

    "IF YOU'RE GOING TO KILL IT
    OPEN SOURCE IT!"

    by Phillip Torrone

    Zitat von Shoutbox

    [Heute, 11:16] Andy: ....böseböseböseböse....da erinnere ich mich daran, dass man den Puschelschwanz eines KaRnickels auch "Blume" nennt....ob da eins zum anderen passt? :rofl: :rofl: :rofl: :rofl:

    https://autoit.de/index.php?page…leIt#post251138

    Neon Snake

    Einmal editiert, zuletzt von BadBunny (9. März 2012 um 23:38)

  • Hi,
    bei mir stürzt das Skript mit folgender Meldung ab:

    Zitat von Scite-Konsole


    (193) : ==> Subscript used with non-Array variable.:
    Local $hPath_V = $aResult[5]
    Local $hPath_V = $aResult^ ERROR

    Benutze Win7, 32 Bit.

    Gruß stay

  • Verwendest du AutoIt 3.3.8.1?

    Bei diesem DllCall wird eine Struct via "struct*" übergeben und das geht erst ab 3.3.8.0
    Kann aber ohne weiteres auf "ptr", DllStructGetPtr($tData_P) geändert werden... (natürlich überall im Script)

    Einige der DllCalls sind die GDIPlus Funktionen, welche nicht in der Standard UDF enthalten sind.
    Das Arbeiten mit Structs bringt in diesem Fall einen Geschwindigkeitsvorteil, da nicht jedesmal zwischen Structs und AutoIt-Arrays gewandelt werden muss.

    z.B.: $tWarp_V in Zeile 24: ich erstelle diese Struct nur einmal selber. Würde ich die Funktion _GDIPlus_PathWarp aus der GDIp.au3 verwenden, dann würde diese Struct bei jedem Aufruf erneut ertellt und befüllt werden - und das kostet Zeit!

    E

  • Ich zeichne einen Punkt auf einen Pfad, verzerre diesen als Wand bzw. Boden und lese die neuen Koordinaten wieder aus.

    Das hast du wahrscheinlich nicht verstanden, deshalb probier mal dieses Script:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Global $iWidth = 500
    Global $iHeight = 500

    [/autoit] [autoit][/autoit] [autoit]

    Global $fPersp = 0.2

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_V = DllStructCreate("float[8];")
    Global $pWarp_V = DllStructGetPtr($tWarp_V)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 1)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 2)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) - ($iWidth * $fPersp), 3)
    DllStructSetData($tWarp_V, 1, ($iWidth / 2) + ($iWidth * $fPersp), 4)
    DllStructSetData($tWarp_V, 1, 0, 5)
    DllStructSetData($tWarp_V, 1, 0, 6)
    DllStructSetData($tWarp_V, 1, 0, 7)
    DllStructSetData($tWarp_V, 1, $iHeight, 8)

    [/autoit] [autoit][/autoit] [autoit]

    Global $tWarp_H = DllStructCreate("float[8];")
    Global $pWarp_H = DllStructGetPtr($tWarp_H)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) - ($iWidth * $fPersp), 1)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 2)
    DllStructSetData($tWarp_H, 1, ($iWidth / 2) + ($iWidth * $fPersp), 3)
    DllStructSetData($tWarp_H, 1, ($iHeight / 2) + ($iHeight * $fPersp), 4)
    DllStructSetData($tWarp_H, 1, 0, 5)
    DllStructSetData($tWarp_H, 1, $iHeight, 6)
    DllStructSetData($tWarp_H, 1, $iWidth, 7)
    DllStructSetData($tWarp_H, 1, $iHeight, 8)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate("GDI+ Script by Eukalyptus", $iWidth + 200, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth + 200, $iHeight, $hGraphics)
    Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    Global $hPen = _GDIPlus_PenCreate(0xFF00FF00, 1)
    Global $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 1)

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_PAINT, "WM_PAINT")
    GUIRegisterMsg($WM_ERASEBKGND, "WM_PAINT")

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    _Draw()
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Draw()
    Local Static $fRect_W = Random(5, 10), $fRect_H = Random(5, 10), $fRect_T = Random(5, 10)
    Local Static $fRect_X = Random(0, 100 - $fRect_W), $fRect_Y = Random(0, 100 - $fRect_H), $iRect_Z = Int(-$fRect_T)
    $iRect_Z += 1

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFF000000)

    [/autoit] [autoit][/autoit] [autoit]

    If $iRect_Z > 100 Then
    $fRect_W = Random(5, 10) ; Neue Breite
    $fRect_H = Random(5, 10) ; Neue Höhe
    $fRect_T = Random(5, 10) ; Neue Tiefe
    $iRect_Z = Int(-$fRect_T)
    $fRect_X = Random(0, 100 - $fRect_W) ; Neue Position X (0..100% von $iWidth) Range kann beliebig gewählt werden, aber derselbe Wert muss später auch bei Warp verwendet werden
    $fRect_Y = Random(0, 100 - $fRect_H) ; Neue Position Y
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) ;neuen Pfad erstellen
    Local $hPath_H = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreatePath", "int", 0, "int*", 0) ;neuen Pfad erstellen
    Local $hPath_V = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_H, "float", $fRect_X, "float", $iRect_Z, "float", $fRect_W, "float", $fRect_T) ; Rechteck in Pfad einfügen
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_V, "float", $fRect_Y, "float", $iRect_Z, "float", $fRect_H, "float", $fRect_T)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;#####################################################################
    ; nur um zu demonstrieren, wie der Pfad verzerrt bzw. verwendet wird
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_H, "int*", 0)
    Local $hPath_H_Clone = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_V, "int*", 0)
    Local $hPath_V_Clone = $aResult[2]
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_H_Clone, "float", 0, "float", 0, "float", 100, "float", 100)
    DllCall($ghGDIPDll, "uint", "GdipAddPathRectangle", "hwnd", $hPath_V_Clone, "float", 0, "float", 0, "float", 100, "float", 100)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_H_Clone, "int*", 0)
    Local $hPath_H_Clone2 = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipClonePath", "hwnd", $hPath_V_Clone, "int*", 0)
    Local $hPath_V_Clone2 = $aResult[2]

    [/autoit] [autoit][/autoit] [autoit]

    Local $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, $iWidth, 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_H_Clone, "hwnd", $hMatrix)
    _GDIPlus_MatrixTranslate($hMatrix, 100, 0)
    DllCall($ghGDIPDll, "uint", "GdipTransformPath", "hwnd", $hPath_V_Clone, "hwnd", $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_H_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_V_Clone)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H_Clone2, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0)
    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V_Clone2, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_H_Clone2)
    DllCall($ghGDIPDll, "uint", "GdipDrawPath", "hwnd", $hGfxBuffer, "hwnd", $hPen2, "hwnd", $hPath_V_Clone2)

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H_Clone)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V_Clone2)
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H_Clone2)
    ;#####################################################################

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_H, "hwnd", 0, "ptr", $pWarp_H, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0) ; Parameter 7 und 8 sollten den gleichen Wert haben, wie $iRect_X bzw. $iRect_Z
    DllCall($ghGDIPDll, "uint", "GdipWarpPath", "hwnd", $hPath_V, "hwnd", 0, "ptr", $pWarp_V, "int", 4, "float", 0, "float", 0, "float", 100, "float", 100, "int", 0, "float", 0) ; Parameter 7 und 8 sollten den gleichen Wert haben, wie $iRect_Y bzw. $iRect_Z

    [/autoit] [autoit][/autoit] [autoit]

    Local $tPoints_H = DllStructCreate("float[8];")
    Local $tPoints_V = DllStructCreate("float[8];")

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_H, "ptr", DllStructGetPtr($tPoints_H), "int", 4) ; Die 4 Expunkte des Rechtecks(Horizontal) in die Struct lesen
    DllCall($ghGDIPDll, "uint", "GdipGetPathPoints", "hwnd", $hPath_V, "ptr", DllStructGetPtr($tPoints_V), "int", 4) ; Die 4 Expunkte des Rechtecks(Vertikal) in die Struct lesen

    [/autoit] [autoit][/autoit] [autoit]

    Local $aP_H[8][2], $aP_V[8][2] ;Zum leichteren Verständniss wandle ich die Struct in ein Array
    For $i = 0 To 7
    For $j = 0 To 1
    $aP_H[$i][$j] = DllStructGetData($tPoints_H, 1, $i * 2 + $j + 1)
    Next
    Next
    For $i = 0 To 7
    For $j = 0 To 1
    $aP_V[$i][$j] = DllStructGetData($tPoints_V, 1, $i * 2 + $j + 1)
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Horizontal
    ; 0---1
    ; / \
    ;3------2

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Vertikal
    ;3--__
    ;| --0
    ;| |
    ;| __--1
    ;2--

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte 3D
    ;0----1
    ;|\ |\
    ;| 4----5
    ;3----2 |
    ; \| \|
    ; 7----6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[1][0], "float", $aP_V[0][1]);0-1
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[3][1], "float", $aP_H[2][0], "float", $aP_V[3][1]);3-2

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[1][1], "float", $aP_H[1][0], "float", $aP_V[1][1]);4-5
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[2][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);7-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[3][0], "float", $aP_V[3][1]);0-3
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[0][1], "float", $aP_H[2][0], "float", $aP_V[3][1]);1-2

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[1][1], "float", $aP_H[3][0], "float", $aP_V[2][1]);4-7
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[1][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);5-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[0][0], "float", $aP_V[0][1], "float", $aP_H[0][0], "float", $aP_V[1][1]);0-4
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[1][0], "float", $aP_V[0][1], "float", $aP_H[1][0], "float", $aP_V[1][1]);1-5

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[3][0], "float", $aP_V[3][1], "float", $aP_H[3][0], "float", $aP_V[2][1]);3-7
    DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $hGfxBuffer, "handle", $hPen, "float", $aP_H[2][0], "float", $aP_V[3][1], "float", $aP_H[2][0], "float", $aP_V[2][1]);2-6

    [/autoit] [autoit][/autoit] [autoit]

    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_V) ;Pfad löschen
    DllCall($ghGDIPDll, "uint", "GdipDeletePath", "hwnd", $hPath_H) ;Pfad löschen
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    EndFunc ;==>_Draw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_PAINT

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _Exit()
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    Rechts siehst du die unverzerrten Pfade "Horizontal" und "Vertikal"
    Im linken Bildauschnitt sind in Rot gezeichnet die verzerrten Pfade und in Grün die Linien, die ich aus den verzerrten Koordinaten auslese!

    Diese Methode stimmt nicht wirklich, denn eigenlich müsste man für jede Ebene des Quaders einen eigenen Pfad ertellen und verzerren.
    (Das hab ich bei meinem BlockOut-Versuch gemacht: Blockout 3D Tetris)
    Das ist mir meistens zu Aufwändig, aber auch so ist das Ergebnis ganz OK.

    E

  • Danke eukalyptus :D. Endlich hab ich verstanden wie das geht. Ich hab mal ein wenig mit dem System herumexperimentiert, und das ist dabei herausgekommen:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GDIP.au3>
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; - Author: name22 (http://www.autoit.de), eukalyptus (original)

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GUIOnEventMode", 1)
    Opt("MouseCoordMode", 2)

    [/autoit] [autoit][/autoit] [autoit]

    ;###-v-SETTINGS-v-###

    [/autoit] [autoit][/autoit] [autoit]

    $iWidth = 800
    $iHeight = 800
    $iDepth = 800
    $iX_Offset = 0
    $iY_Offset = 0
    $fPersp = 0.6

    [/autoit] [autoit][/autoit] [autoit]

    $iARGB_BG = 0xFF000000
    $nFPS = 80

    [/autoit] [autoit][/autoit] [autoit]

    $iX_Vel = 0
    $iY_Vel = 0
    $iZ_Vel = -1000

    [/autoit] [autoit][/autoit] [autoit]

    ;###-^-SETTINGS-^-###

    [/autoit] [autoit][/autoit] [autoit]

    $iW_Rect = Random(60, 300, 1)
    $iH_Rect = $iW_Rect
    $iD_Rect = Random(60, 300, 1)
    $iX_Rect = Random(0, $iWidth - $iW_Rect, 1)
    $iY_Rect = Random(0, $iHeight - $iH_Rect, 1)
    $iZ_Rect = 2000

    [/autoit] [autoit][/autoit] [autoit]

    Global $aWarp_V[5][2] = [[4], [0, 0], [$iWidth / 2 * $fPersp + $iX_Offset, $iHeight / 2 * $fPersp + $iY_Offset], [0, $iHeight], [$iWidth / 2 * $fPersp + $iX_Offset, $iHeight - $iHeight / 2 * $fPersp + $iY_Offset]]
    Global $aWarp_H[5][2] = [[4], [0, $iHeight], [$iWidth, $iHeight], [$iWidth / 2 * $fPersp + $iX_Offset, $iHeight - $iHeight / 2 * $fPersp + $iY_Offset], [$iWidth - $iWidth / 2 * $fPersp + $iX_Offset, $iHeight - $iHeight / 2 * $fPersp + $iY_Offset]]

    [/autoit] [autoit][/autoit] [autoit]

    $nSleepTime = 1000 / $nFPS

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Display = 0
    $nFPS_Average = $nFPS

    [/autoit] [autoit][/autoit] [autoit]

    $vNTdll = DllOpen("ntdll.dll")
    $vU32Dll = DllOpen("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    $tPrecSleep = DllStructCreate("int64 time;")
    $pPrecSleep = DllStructGetPtr($tPrecSleep)

    [/autoit] [autoit][/autoit] [autoit]

    $hMain = GUICreate("Example by name22", $iWidth, $iHeight)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hDC_Main = _WinAPI_GetDC($hMain)
    $hDC_Buffer = _WinAPI_CreateCompatibleDC($hDC_Main)
    $hBitmap_Buffer = _WinAPI_CreateCompatibleBitmap($hDC_Main, $iWidth, $iHeight)
    _WinAPI_SelectObject($hDC_Buffer, $hBitmap_Buffer)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)

    [/autoit] [autoit][/autoit] [autoit]

    $hImageFront = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Front.png")

    [/autoit] [autoit][/autoit] [autoit]

    $hPen_Cube = _GDIPlus_PenCreate(0xFF00FF00)
    $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFF808080)
    $hBrush_Walls = _GDIPlus_BrushCreateSolid(0xFFF0F0F0)

    [/autoit] [autoit][/autoit] [autoit]

    $hStringFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hStringFormat, 2)
    $hFamily_FPS = _GDIPlus_FontFamilyCreate("Sony Sketch EF")
    $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8)

    [/autoit] [autoit][/autoit] [autoit]

    $aMeasure = _GDIPlus_GraphicsMeasureString($hGraphics, "FPS: 0", $hFont_FPS, _GDIPlus_RectFCreate(), $hStringFormat)
    $tLayout_FPS = _GDIPlus_RectFCreate(0, $iHeight - DllStructGetData($aMeasure[0], "Height"), $iWidth, 0)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Close", $hMain)
    OnAutoItExitRegister("_Shutdown")

    [/autoit] [autoit][/autoit] [autoit]

    MouseMove($iWidth / 2, $iHeight / 2, 0)

    [/autoit] [autoit][/autoit] [autoit]

    $aMousePosOld = MouseGetPos()
    $nT_UpdateFPS = TimerInit()
    $nT_Sleep = TimerInit() + $nSleepTime
    While True
    DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep)))
    DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
    $nFrameTime = TimerDiff($nT_Sleep)
    $nT_Sleep = TimerInit()

    [/autoit] [autoit][/autoit] [autoit]

    $nFPS_Cur = 1000 / $nFrameTime
    If TimerDiff($nT_UpdateFPS) >= 1000 Then
    $nFPS_Display = $nFPS_Cur
    $nT_UpdateFPS = TimerInit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $aMousePosNew = MouseGetPos()
    If $aMousePosOld[0] <> $aMousePosNew[0] Or $aMousePosOld[1] <> $aMousePosNew[1] Then
    $iX_Offset = $aMousePosNew[0] - $iWidth / 2
    $iY_Offset = $aMousePosNew[1] - $iHeight / 2
    $aWarp_V[2][0] = $iWidth / 2 * $fPersp + $iX_Offset
    $aWarp_V[2][1] = $iHeight / 2 * $fPersp + $iY_Offset
    $aWarp_V[4][0] = $aWarp_V[2][0]
    $aWarp_V[4][1] = $iHeight - $iHeight / 2 * $fPersp + $iY_Offset
    $aWarp_H[3][0] = $aWarp_V[2][0]
    $aWarp_H[3][1] = $aWarp_V[4][1]
    $aWarp_H[4][0] = $iWidth - $iWidth / 2 * $fPersp + $iX_Offset
    $aWarp_H[4][1] = $aWarp_V[4][1]
    $aMousePosOld = $aMousePosNew
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $iX_Rect += $iX_Vel / $nFPS_Cur
    $iY_Rect += $iY_Vel / $nFPS_Cur
    $iZ_Rect += $iZ_Vel / $nFPS_Cur

    [/autoit] [autoit][/autoit] [autoit]

    If $iZ_Rect < 0 Then
    $iW_Rect = Random(60, 300, 1)
    $iH_Rect = $iW_Rect
    $iD_Rect = Random(60, 300, 1)
    $iX_Rect = Random(0, $iWidth - $iW_Rect, 1)
    $iY_Rect = Random(0, $iHeight - $iH_Rect, 1)
    $iZ_Rect = 2000
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hPath_V = _GDIPlus_PathCreate()
    $hPath_H = _GDIPlus_PathCreate()

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathAddRectangle($hPath_V, $iZ_Rect, $iY_Rect, $iD_Rect, $iH_Rect)
    _GDIPlus_PathAddRectangle($hPath_H, $iX_Rect, $iZ_Rect, $iW_Rect, $iD_Rect)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathWarp($hPath_V, 0, $aWarp_V, 0, 0, $iDepth, $iHeight)
    _GDIPlus_PathWarp($hPath_H, 0, $aWarp_H, 0, 0, $iWidth, $iDepth)

    [/autoit] [autoit][/autoit] [autoit]

    $aPoints_V = _GDIPlus_PathGetPoints($hPath_V)
    $aPoints_H = _GDIPlus_PathGetPoints($hPath_H)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_PathDispose($hPath_V)
    _GDIPlus_PathDispose($hPath_H)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsClear($hGraphics, $iARGB_BG)
    _GDIPlus_GraphicsFillPolygon($hGraphics, $aWarp_H, $hBrush_Walls)
    _GDIPlus_GraphicsFillPolygon($hGraphics, $aWarp_V, $hBrush_Walls)
    _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints_H, $hPen_Cube)
    _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints_V, $hPen_Cube)

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Horizontal
    ; 4---3
    ; / \
    ;1------2

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte Vertikal
    ;1--__
    ;| --2
    ;| |
    ;| __--3
    ;4--

    [/autoit] [autoit][/autoit] [autoit]

    ;Punkte 3D
    ;1----2
    ;|\ |\
    ;| 5----6
    ;4----3 |
    ; \| \|
    ; 8----7

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[1][0], $aPoints_V[4][1], $aPoints_H[2][0], $aPoints_V[4][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[2][0], $aPoints_V[4][1], $aPoints_H[3][0], $aPoints_V[3][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[3][0], $aPoints_V[3][1], $aPoints_H[4][0], $aPoints_V[3][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[4][0], $aPoints_V[3][1], $aPoints_H[1][0], $aPoints_V[4][1], $hPen_Cube)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[1][0], $aPoints_V[1][1], $aPoints_H[2][0], $aPoints_V[1][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[2][0], $aPoints_V[1][1], $aPoints_H[3][0], $aPoints_V[2][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[3][0], $aPoints_V[2][1], $aPoints_H[4][0], $aPoints_V[2][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[4][0], $aPoints_V[2][1], $aPoints_H[1][0], $aPoints_V[1][1], $hPen_Cube)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[1][0], $aPoints_V[1][1], $aPoints_H[1][0], $aPoints_V[4][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[2][0], $aPoints_V[1][1], $aPoints_H[2][0], $aPoints_V[4][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[3][0], $aPoints_V[2][1], $aPoints_H[3][0], $aPoints_V[3][1], $hPen_Cube)
    _GDIPlus_GraphicsDrawLine($hGraphics, $aPoints_H[4][0], $aPoints_V[2][1], $aPoints_H[4][0], $aPoints_V[3][1], $hPen_Cube)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImageFront, $aPoints_H[1][0], $aPoints_V[1][1], Abs($aPoints_H[2][0] - $aPoints_H[1][0]), Abs($aPoints_V[4][1] - $aPoints_V[1][1]))

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawStringEx($hGraphics, "FPS: " & Int($nFPS_Display), $hFont_FPS, $tLayout_FPS, $hStringFormat, $hBrush_FPS)
    _WinAPI_BitBlt($hDC_Main, 0, 0, $iWidth, $iHeight, $hDC_Buffer, 0, 0, $SRCCOPY)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Close()
    Exit
    EndFunc ;==>_Close

    [/autoit] [autoit][/autoit] [autoit]

    Func _Shutdown()
    _WinAPI_ReleaseDC($hMain, $hDC_Main)
    _WinAPI_DeleteDC($hDC_Buffer)
    _WinAPI_DeleteObject($hBitmap_Buffer)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_ImageDispose($hImageFront)
    _GDIPlus_BrushDispose($hBrush_FPS)
    _GDIPlus_BrushDispose($hBrush_Walls)
    _GDIPlus_PenDispose($hPen_Cube)
    _GDIPlus_StringFormatDispose($hStringFormat)
    _GDIPlus_FontFamilyDispose($hFamily_FPS)
    _GDIPlus_FontDispose($hFont_FPS)
    _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    DllClose($vNTdll)
    DllClose($vU32Dll)
    EndFunc ;==>_Shutdown

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION#;===============================================================================
    ;
    ; Name...........: _HighPrecisionSleep()
    ; Description ...: Sleeps down to 0.1 microseconds
    ; Syntax.........: _HighPrecisionSleep( $iMicroSeconds, $hDll=False)
    ; Parameters ....: $iMicroSeconds - Amount of microseconds to sleep
    ; $hDll - Can be supplied so the UDF doesn't have to re-open the dll all the time.
    ; Return values .: None
    ; Author ........: Andreas Karlsson (monoceres)
    ; Modified.......:
    ; Remarks .......: Even though this has high precision you need to take into consideration that it will take some time for autoit to call the function.
    ; Related .......:
    ; Link ..........;
    ; Example .......; No
    ;
    ;;==========================================================================================
    Func _HighPrecisionSleep($iMicroSeconds, $hDll = False)
    Local $hStruct, $bLoaded
    If Not $hDll Then
    $hDll = DllOpen("ntdll.dll")
    $bLoaded = True
    EndIf
    $hStruct = DllStructCreate("int64 time;")
    DllStructSetData($hStruct, "time", -1 * ($iMicroSeconds * 10))
    DllCall($hDll, "dword", "ZwDelayExecution", "int", 0, "ptr", DllStructGetPtr($hStruct))
    If $bLoaded Then DllClose($hDll)
    EndFunc ;==>_HighPrecisionSleep

    [/autoit]


    Falls ihr wollt, könnt ihr das Bild (oder auch ein komplett anderes) in das Scriptverzeichnis packen (oder den Pfad in Zeile 63 anpassen).

  • Wie immer sehr cooooooooollllllllllllll!

    Ich muss mal auch wieder was mit GDI+ machen! Bin total aus der Übung...

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Respekt!
    Wenn ich was mit 3D mache nutze ich OpenGL, aber ohne Projektionsmatrix die das berechnet ist es wohl deutlich schwerer, sowa zu zei hnen.

    Ich zieh meinen Hut !

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal

  • Mir ist gerade beim experimentieren mit diesem Script eine Idee gekommen.. Wie wäre es mit 3dimensionalen Fraktalen in AutoIt mit GDI+? Die Berechnungen würden am Anfang zwar eine Menge Zeit in Anspruch nehmen, aber "einfachere Dinge" wie zum Beispiel der Menger-Schwamm sollten doch möglich sein, oder?

  • Beim "Menger Schwamm" hast du aber von Hause aus ein 3D Objekt.
    Die meisten Fraktale sind jedoch 2D, siehe Mandelbrot, Julia, Koch Kurve, Pythagoras Baum, ...

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal