Sign in to follow this  
Followers 0
ToxicWaste55

How to 3D Render

2 posts in this topic

Hey'ya Everybody

i found some basic formulas for doing basic 3D rendering. It is really hard to do much else other than plotting points, but it works.

One of my current missions is to figure out rotation and clipping path. Eventually I will be able to make solid object like cubes rotate and fly around the screen.

Maybe one day, in a galaxy far, far away, AutoIT will have DirectX Support. Then my mission will be completed. But, I'll settle for DirectDraw...

Anyway here's the basic Algorithm:

func Calc_3D($x,$y,$z)
    Local $d
    local $return[3]
    $x = $x - $pan[0]
    $y = $y - $pan[1]
    $z = $z - $pan[2]
    $x = $Window[0]*$x/($z)
    $y = $Window[1]*$y/($z)
    if $z < $pan[2] then    ;if in front of you
        $return[0] = $x + .5 * $Window[0]  ;$window[0] is the horizontal size of the draw field 
        $return[1] = $y + .5 * $Window[1]  ;$window[1] is the vertical
        $return[2] = $d  ;distance, used in program specific times, like distance shading or diameter shrinkage.
    Else   ;if behind you
        $return[0] = 0
        $return[1] = 0
        $return[2] = -100000
    EndIf
    
    Return $return
EndFunc

The returned data is the absolute pixel positions used in GUICtrlSetGraphic's x & y parameters.

$return[0] is the x

[1] is the y

[2] is the distance from you

That is a tried and true method. It uses a one point perspective.

Another one I am working on uses three point perspective.

I was going to post it but appears as if i lost the code somewhere...

maybe i'll post it as an edit...

anyway check out my rendering example (i have more advanced ones that I might share later by the way)

3D_Example.au3

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