Starg Posted August 1, 2013 Author Posted August 1, 2013 I googled "simple 3D graphics GDI+" and found this topic at the top!
Starg Posted August 2, 2013 Author Posted August 2, 2013 Another example: expandcollapse popup#include <GUIConstantsEx.au3> #include <S3d.au3> Global Const $PI = 3.1416 Main() Func Main() ; Create a window and initialize GDI+ Local $hGUI = GUICreate("S3d Test", 650, 550) GUISetState() _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(650, 550, $hGraphics) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrushB = _GDIPlus_BrushCreateSolid(0x996699FF) Local $hBrushG = _GDIPlus_BrushCreateSolid(0x9966FF33) Local $hPen = _GDIPlus_PenCreate(0xCCFF6633, 3) ; Select a Graphic object ; width = 650, height = 550 _S3d_SelectGraphic($hGraphic, 650, 550) _S3d_SelectPen($hPen) Local $i = 0 ; Loop until user exits Do ; Clear the Graphics object _S3d_Clear(0xFFCCCCCC) ; Set camera _S3d_SetCamera(500 * Cos($i), 500 * Sin($i), 1000, 0, 0, 600) ; Draw an arrow _S3d_Arrow(0, 0, -300, 0, 0, 900) _S3d_SelectBrush($hBrushG) _S3d_MoveTo2(100, 0, 0, 130, 0, 0) For $j = 0 To $PI * 2 * 3 Step ($PI * 2) / 20 _S3d_RibbonTo(100 * Cos($j), 100 * Sin($j), $j * 50, 130 * Cos($j), 130 * Sin($j), $j * 50) Next _S3d_SelectBrush($hBrushB) _S3d_MoveTo2(-100, 0, 0, -130, 0, 0) For $j = 0 To $PI * 2 * 3 Step ($PI * 2) / 20 _S3d_RibbonTo(-100 * Cos($j), -100 * Sin($j), $j * 50, -130 * Cos($j), -130 * Sin($j), $j * 50) Next ; Copy to the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $i += 0.3 Sleep(30) Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushB) _GDIPlus_BrushDispose($hBrushG) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Main DatMCEyeBall and UEZ 2
UEZ Posted August 2, 2013 Posted August 2, 2013 Looks really cool! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Starg Posted August 3, 2013 Author Posted August 3, 2013 (edited) Looks really cool! Br, UEZ Thanks. Now I'm thinking of making a small game with S3d. Edit: This topic became "Hot"! Edited August 3, 2013 by Starg tirpider 1
Starg Posted August 5, 2013 Author Posted August 5, 2013 UPDATENew version (v1.2.0) released! Please see the first post.Added: _S3d_SetCameraExAdded: _S3d_SetLocalMatrixExAdded: Optional parameter $iSmooth for _S3d_SelectGraphic to set the graphics object rendering qualityChanged: Internal function __S3d_Clip modified to avoid long loopRemoved: Unused internal function __S3d_RotateIf you have written some example scripts that use S3d.au3, feel free to post them here.
DatMCEyeBall Posted August 5, 2013 Posted August 5, 2013 What does _S3d_SetCameraEx() do? "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation
Starg Posted August 5, 2013 Author Posted August 5, 2013 What does _S3d_SetCameraEx() do? _S3d_SetCameraEx accepts $nXYAngle and $nXZAngle instead of $nTargetX, $nTargetY, and $nTargetZ. Please see 9-SetCameraEx.au3 in the archive for more information.
PlayHD Posted August 6, 2013 Posted August 6, 2013 How to make the camera to follow the mouse My UDF : _WinShake, _WinSplitMy Apps : Google Guitar Bot, PuzzleGameDesign Gui : Interesting Tabs Design, RBox Project (abandoned), Animated Gui on Exit
Starg Posted August 6, 2013 Author Posted August 6, 2013 (edited) How to make the camera to follow the mouse Something like this? Edit: Run 11-Mouse.au3 in the zip instead of this. expandcollapse popup#include <GUIConstantsEx.au3> #include <S3d.au3> Opt("MouseCoordMode", 0) ; relative coords to the active window Global Const $PI = 3.1416 Main() Func Main() ; Create a window and initialize GDI+ Local $hGUI = GUICreate("Mouse Test", 650, 550) GUISetState() _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(650, 550, $hGraphics) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrush = _GDIPlus_BrushCreateSolid(0x996699FF) _S3d_SelectBrush($hBrush) ; Select a Graphic object ; width = 650, height = 550 _S3d_SelectGraphic($hGraphic, 650, 550) Local $iX = 0, $iY = 0 ; Loop until user exits Do ; Clear the Graphics object _S3d_Clear(0xFF333333) ; Set camera ; Camera : (0, 0, 150) ; $nXYAngle = $i (rad) ; $nXZAngle = 0.5 * Sin($i) (rad) _S3d_SetCameraEx(0, 0, 150, $iX, $iY) Local $k For $j = 0 To $PI * 2 Step $PI * 2 / 6 $k = $j + $PI / 6 ; $j + $PI * 2 / 12 _S3d_Square(1000 * Cos($j), 1000 * Sin($j), 0, _ 1000 * Cos($j), 1000 * Sin($j), 300, _ 1000 * Cos($k), 1000 * Sin($k), 300, _ 1000 * Cos($k), 1000 * Sin($k), 0) Next ; Copy to the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $iX += (MouseGetPos(0) - 275) * 0.00005 $iY += (MouseGetPos(1) - 325) * 0.00005 ; Limit value of $iY If $iY < -0.5 Then $iY = -0.5 ElseIf $iY > 0.5 Then $iY = 0.5 EndIf Sleep(30) Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Main Edited August 9, 2013 by Starg tirpider 1
Starg Posted August 8, 2013 Author Posted August 8, 2013 UPDATENew version (v1.2.1) released! Please see the first post. Added: Function Reference (not yet completed) Changed: _S3d_Square calls _S3dLine when $fFill = False Fixed: Strange behavior of _S3d_LineTo Enjoy!
Starg Posted August 9, 2013 Author Posted August 9, 2013 UPDATE New version (v1.2.2) released! Please see the first post. Fixed: _S3d_RibbonTo didn't return 1 on success Fixed: _S3d_SetCameraEx accidentally reversed $nXYAngle and $nXZAngle Changed: _S3d_Square performance improved Enjoy!
Starg Posted August 12, 2013 Author Posted August 12, 2013 This might be useful:http://people.physics.anu.edu.au/~mxk121/research/polyhedron.html
Starg Posted August 15, 2013 Author Posted August 15, 2013 (edited) Now I'm looking for a way to improve the algorithm. Edit: $aOutPos[3] in __S3d_ConvertPos() doesn't seem to be necessary. Edited August 15, 2013 by Starg
Starg Posted August 16, 2013 Author Posted August 16, 2013 UPDATE New version (v1.2.3) released! Please see the first post. Fixed: Unnecessary calculation in internal function __S3d_ConvertPos removed Some internal changes Enjoy!
Starg Posted August 31, 2013 Author Posted August 31, 2013 Another example: http://pastebin.com/n5Qvp3vE
Starg Posted September 5, 2013 Author Posted September 5, 2013 UPDATENew version (v1.3.0) released! Please see the first post.Added: _S3d_InitCurrentPos().Added: New optional parameter $fRefresh for _S3d_MultiplyLocalMatrix() and _S3d_Local****()'s to determine whether to update the local matrix.Changed: Better algorithm for handling the current position.Changed: Internal function __S3d_SetCamera() performance improved.Changed: _S3d_MoveTo(), _S3d_LineTo(), _S3d_MoveTo2(), and _S3d_RibbonTo() no longer return values or set @error.Changed: Internal function __S3d_CreateMatrix() now accepts initial values.Enjoy!
Starg Posted September 20, 2013 Author Posted September 20, 2013 I forgot to update the documentation in the archive....
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now