Sign in to follow this  
Followers 0

3D Graphics in AutoIt

33 posts in this topic

Posted (edited)

v0.2 : InputManger now works.

Short-Term todo list:

> the camera is fixed at (0,0,0). Even though the tree can move toward or away from this point along the z-axis, you want to be able to move the camera around freely.

> When the tree is very close to the camera, the polygon is drawn in strange ways. Also, when you zoom in too far (past the tree), the tree appears upside down! This is because polygons are not clipped to the view frusum.

> Finally, the tree is flat, which is kind of boring. Solid trees and other solid shapes will be more interesting.

ok... now back to the demo...

Test exe:

(Whenever an "ASSERT" box pops up, click Ignore.)

Libraries: http://www.autoitscript.com/fileman/users/nfwu/AutoIt3D.zip

(Source code for test is in /test/ of the ZIP, as usual)

Controls for demo:

ESC : Quit

Up Arrow : Zoom In

Down Arrow : Zoom Out

#)

NOTES:

1) The libraries are pretty complicated to use *for now*. I will create an easier to use version soon after I have completed the short-term goals listed above.

Please make suggestions!!!

Edited by Jon
1 person likes this

Share this post


Link to post
Share on other sites



Posted

NICE :o:geek: : D ;):sorcerer::huggles::zorro:

Share this post


Link to post
Share on other sites

Posted

Wow! never thought it would be possible :o

Share this post


Link to post
Share on other sites

Posted

That's pretty cool. It reminds me a lot of my physics class.. the inversion effect of a lens when you get to a certain angle (in this case, when you zoom in enough). Nice work so far.

Share this post


Link to post
Share on other sites

Posted

that's pretty sweet.

Share this post


Link to post
Share on other sites

Posted

I think it's cool. But man, you really need to switch to J or C for these kind of things. I haven't looked at the code but what you're doing really is trying to make a 2D environment react like a 3D one, so it looks like 3D. Real 3D needs a different engine.

Share this post


Link to post
Share on other sites

Posted

Can't you import Direct X libraries and use Direct X API functions to create 3d objects and such? I did it in visual basic, but i am pretty sure you could import the same libraries.

Maybe, no?

Share this post


Link to post
Share on other sites

Posted (edited)

Can't you import Direct X libraries and use Direct X API functions to create 3d objects and such? I did it in visual basic, but i am pretty sure you could import the same libraries.

Maybe, no?

I can... i was planning tio use OpenGL, but it was a bit complicated...

Can you supply some srce code and the libraries?

#)

EDIT: I am busy until Saturday afternoon

Edited by nfwu

Share this post


Link to post
Share on other sites

Posted

awesome... i agree with manadar. Its pretty cool though. Also, i agree with what the Kandie Man Said.

Share this post


Link to post
Share on other sites

Posted

I think it's cool. But man, you really need to switch to J or C for these kind of things. I haven't looked at the code but what you're doing really is trying to make a 2D environment react like a 3D one, so it looks like 3D. Real 3D needs a different engine.

Errmmm... I happen to do 3d programming in Java and C++ as well, and ALL "3d" graphics are projected onto the screen. Using points in "imaginary 3d" space and projecting them on the screen....

#)

Share this post


Link to post
Share on other sites

Posted

I am very very very interested in your progress with this 3d Graphics stuff.

Once you get things how you want them I am going to try to make a 3D Construction program.

I am going to build a playset/Fort for my Son this spring but I haven't found any good construction software that will tell me how many 2x4's or 1x6's I need for a specified area (Wall/Floor). I was going to do this without any graphical representation, just output as text but if you get this working it will be AWSOME!!!.

Mike

Share this post


Link to post
Share on other sites

Posted

NICE!

Share this post


Link to post
Share on other sites

Posted

I just completed version 0.3 of this, which has all the short-term goals sorted out.

The only problem is that it takes 2 minutes to draw 1 frame!!!!

I'm going to switch the calculations, etc, etc into a C++ DLL and only let AutoIt handle the keyboard/mouse input and the GUI.

(Starting everything from scratch again...)

#)

Share this post


Link to post
Share on other sites

Posted

make some UDF's :) possible

Share this post


Link to post
Share on other sites

Posted

If you're looking for some 3d-to-2d translation functions and 3d rotation functions, check out my 3d stars screen saver post

Share this post


Link to post
Share on other sites

Posted

Thanks, but's that's not required... i've already done stuff like this in Java...

Now it is just a preformance issue..

I hope that converting this to a Plugin or DLL will increase the speed...

because it is Native code... no translation required, not like AutoIt.

#)

Share this post


Link to post
Share on other sites

Posted

It's ~2 months after my last post in this thread...

I have recently just profiled my application amd realized that it takes a long time in this function:

(1~2 minutes)

(v0.3 - not yet released)

Func ScreenManager_ClearScreen($p_color=0x000000)
  For $i = 0 to $ScreenWidth
    For $j = 0 to $ScreenHeight
       $ScreenBuffer[$i][$j] = $p_color
    Next
  Next
EndFunc

$ScreenWidth is usually ~600

$ScreenHeight is usuallly ~450

Is there any alternative to this that is much faster?

#)

Share this post


Link to post
Share on other sites

Posted

It's ~2 months after my last post in this thread...

I have recently just profiled my application amd realized that it takes a long time in this function:

(1~2 minutes)

(v0.3 - not yet released)

Func ScreenManager_ClearScreen($p_color=0x000000)
  For $i = 0 to $ScreenWidth
    For $j = 0 to $ScreenHeight
       $ScreenBuffer[$i][$j] = $p_color
    Next
  Next
EndFunc

$ScreenWidth is usually ~600

$ScreenHeight is usuallly ~450

Is there any alternative to this that is much faster?

#)

You're trying to flood-fill a buffer using loops in an array in a high-level language? Yeah, that's going to be slow.

I'd say instead of using a 2-d array, just use 1 big binary string. And work with it using DLLs whenever possible.

Share this post


Link to post
Share on other sites

Posted (edited)

how about making it multithreading ?

this took me ~18 sec :

Dim $MaxH = @DesktopHeight
Dim $MaxW = @DesktopWidth
Dim $ScreenBuffer[$MaxH+1][$MaxW+1]

Func ScreenManager_ClearScreen($p_color=0x000000)
  For $H = 0 to $MaxH
    For $W = 0 to $MaxW
        $ScreenBuffer[$H][$W] = $p_color
    Next
    ToolTip ( "Heigh Scanning :" & $H & @CRLF & "Widht Scanning : " & $W & @CRLF & "Set with Color : " & $p_color )
  Next
EndFunc

ScreenManager_ClearScreen()

please take a look at this, its not 100% working now, and the math is not 100% correct, but i shall work much faster!

this is what i meant with multithreading :)

Dim $MaxH = @DesktopHeight
Dim $MaxW = @DesktopWidth
Dim $ScreenBuffer[$MaxH + 1][$MaxW + 1]
Dim $1DesktopXMax = $MaxH / 2
Dim $1DesktopYMax = $MaxW / 2
;=====================; MULTITHREAD 1
Dim $1MultiH = 1;-> $1DesktopXMax
Dim $1MultiW = 1;-> $1DesktopYMax
;=====================; MULTITHREAD 2
Dim $2MultiH = $1DesktopXMax;-> $MaxH
Dim $2MultiW = $1DesktopYMax;-> $1DesktopYMax
;=====================; MULTITHREAD 3
Dim $3MultiH = 1;-> $1DesktopXMax
Dim $3MultiW = $1DesktopYMax;-> $1DesktopYMax
;=====================; MULTITHREAD 4
Dim $4MultiH = $1DesktopXMax;-> $MaxH
Dim $4MultiW = $1DesktopYMax;-> $MaxW
;=====================; END
Func ScreenManager_ClearScreen($p_color = 123456789)
    $timer = TimerInit()
    For $1MultiH=1 To $1DesktopXMax
    ; MULTITHREAD 2
        If $2MultiH <= $MaxH Then
            $2MultiH += 1
        EndIf
    ; MULTITHREAD 3
        If $3MultiH <= $1DesktopXMax Then
            $3MultiH += 1
        EndIf
    ; MULTITHREAD 4
        If $4MultiH <= $MaxH Then
            $4MultiH += 1
        EndIf
        For $1MultiW=1 To $1DesktopYMax - 1
        ; MULTITHREAD 2
            If $2MultiW <= $1DesktopYMax Then
                $2MultiW += 1
            EndIf
        ; MULTITHREAD 3
            If $3MultiW <= $1DesktopYMax Then
                $3MultiW += 1
            EndIf
        ; MULTITHREAD 4
            If $4MultiW <= $MaxW Then
                $4MultiW += 1
            EndIf
            $ScreenBuffer[$1MultiH][$1MultiH] = $p_color
            $ScreenBuffer[$2MultiH][$2MultiW] = $p_color
            $ScreenBuffer[$3MultiH][$3MultiW] = $p_color
            $ScreenBuffer[$4MultiH][$4MultiW] = $p_color
            ToolTip("#" & @CRLF & _
                "Rest der Hälfte 1 X : " & $1MultiH & "/" & $1DesktopXMax & @CRLF & _
                "Rest der Hälfte 1 Y : " & $1MultiW & "/" & $1DesktopYMax & @CRLF & @CRLF & _
                "Rest der Hälfte 2 X : " & $2MultiH & "/" & $MaxH & @CRLF & _
                "Rest der Hälfte 2 Y : " & $2MultiW & "/" & $1DesktopYMax & @CRLF & @CRLF & _
                "Rest der Hälfte 3 X : " & $3MultiH & "/" & $1DesktopXMax & @CRLF & _
                "Rest der Hälfte 3 Y : " & $3MultiW & "/" & $1DesktopYMax & @CRLF & @CRLF & _
                "Rest der Hälfte 4 X : " & $4MultiH & "/" & $MaxH & @CRLF & _
                "Rest der Hälfte 4 Y : " & $4MultiW & "/" & $MaxW & @CRLF)
            Next
        Next

;check
    #cs
        For $H = $1MultiH To $MaxH
        For $W = $1MultiW To $MaxW -1
        $ScreenBuffer[$H][$W] = $p_color
        Next
        ToolTip ( "Heigh Scanning :" & $H & @CRLF & _
        "Widht Scanning : " & $W & @CRLF & _
        "Set with Color : " & $p_color & @CRLF & _
        "ScreenBuffer : " & $ScreenBuffer[$H][$W] & @CRLF & _
        "Rest der Hälfte X : " & $1MultiH & @CRLF & _
        "Rest der Hälfte Y : " & $1MultiW )
        Next
    #ce
    MsgBox(0, "", "TimeNeedet : " & TimerDiff($timer))
EndFunc  ;==>ScreenManager_ClearScreen
;test()
ScreenManager_ClearScreen()
Edited by Busti

Share this post


Link to post
Share on other sites

Posted

push....nfwu could you answer if this is something like you searched?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.