[bb] Lorenz 3D by BlitzSupport [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:42

Previous topic - Next topic

BlitzBot

Title : Lorenz 3D
Author : BlitzSupport
Posted : 1+ years ago

Description : This is a port of the fractal created by meteorologist Lorenz. Whereas the image has previously been drawn in only 2 dimensions due to lack of a 3rd, this version lets you see the fractal the way it's meant to be seen! Use the controls as described...

I recommend downloading <a href="http://www.hi-toro.com/blitz/lorenz3d.zip" target="_blank">this ZIP file</a> [59K] with its custom sprite, as the default drawing is rather boring! This really makes it look very 'Tron'-like :)

EDIT (24 May 2017): Couple of quick links  to above ZIP file, can't upload to original location right now:

<a href="http://s000.tinyupload.com/index.php?file_id=78520137689960463917" target="_blank">http://s000.tinyupload.com/index.php?file_id=78520137689960463917</a>
<a href="https://www.sendspace.com/file/tjynz2" target="_blank">https://www.sendspace.com/file/tjynz2</a>


Code :
Code (blitzbasic) Select
; Lorenz Attractor in 3D... from 'Computers and Chaos' by Conrad Bessant,
; converted from AmigaBASIC to Blitz3D by james @ hi - toro . com :)

; CONTROLS:

; Cursors + A & Z, or mouse + both buttons.
; SPACE toggles drawing.

AppTitle "Lorenz Attractor in 3D"

; Display mode...

sw = 640 : sh = 480
;sw = 1024: sh = 768

Graphics3D sw, sh

; I don't pretend to understand any of this, but play with a, b and c for
; different results...

a# = 10
b# = 28
c# = 8.0 / 3.0

dt# = 0.01

x# = 1
y# = 1
z# = 1

; Render every iteration (eg. 2 renders every 2nd iteration, etc)...

detail = 1

cam = CreateCamera ()
CameraRange cam, 0.1, 1000
PositionEntity cam, 0, 0, -50

ball = LoadSprite ("point.bmp", 16 + 32)
If ball
ScaleSprite ball, 2.5, 2.5
spritescale# = 0.5
Else
ball = CreateSprite (): EntityColor ball, 0, 255, 0
spritescale# = 0.25
EndIf

wind = Load3DSound ("wind.wav")
If wind
LoopSound wind
CreateListener (cam, 1, 0.1)
windchannel = EmitSound (wind, ball)
EndIf

SetFont LoadFont ("arial", 15, 1)

fps = CreateTimer (60)

Repeat

WaitTimer (fps)

MoveMouse GraphicsWidth () / 2, GraphicsHeight () / 2
TurnEntity cam, -MouseYSpeed () / 5.0, -MouseXSpeed () / 5.0, 0

If (KeyDown (30)) Or (MouseDown (1))
MoveEntity cam, 0, 0, 0.5
Else
If (KeyDown (44)) Or (MouseDown (2))
MoveEntity cam, 0, 0, -0.5
EndIf
EndIf

If KeyHit (57)
stopdrawing = 1 - stopdrawing
If wind Then ChannelVolume windchannel, 1 - stopdrawing
EndIf

If KeyDown (203)
TurnEntity cam, 0, 2, 0
Else
If KeyDown (205)
TurnEntity cam, 0, -2, 0
EndIf
EndIf

If KeyDown (200)
TurnEntity cam, 2, 0, 0
Else
If KeyDown (208)
TurnEntity cam, -2, 0, 0
EndIf
EndIf

If stopdrawing = False

; These six lines are the equation which produces the whole thing!

dx# = a * (y - x)
dy# = b * x - y - x * z
dz# = x * y - c * z

x = x + dx * dt
y = y + dy * dt
z = z + dz * dt

frames = frames + 1
If frames Mod detail = 0
PositionEntity ball, x, y, z
newball = CopyEntity (ball)
ScaleSprite newball, spritescale, spritescale
EndIf

EndIf

RenderWorld

If stopdrawing
Text 20, 20, "Iterations, drawn every " + detail + " frame(s): " + frames + "  -- use SPACE to pause/continue"
EndIf

Flip

Until KeyHit (1)

End


Comments :


Ben(t)(Posted 1+ years ago)

 i'm sorry but what is this supposed to do?


xlsior(Posted 1+ years ago)

 It draws a fractal in 3D. Use cursor keys to rotate, and mouse buttons to zoom in/out.


BlitzSupport(Posted 2 weeks ago)

 Couple of copies of archive...<a href="http://s000.tinyupload.com/index.php?file_id=78520137689960463917" target="_blank">http://s000.tinyupload.com/index.php?file_id=78520137689960463917</a><a href="https://www.sendspace.com/file/tjynz2" target="_blank">https://www.sendspace.com/file/tjynz2</a>