Code archives/3D Graphics - Effects/Lorenz 3D

This code has been declared by its author to be Public Domain code.

Download source code

Lorenz 3D by BlitzSupport2002
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 this ZIP file [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:

http://s000.tinyupload.com/index.php?file_id=78520137689960463917
https://www.sendspace.com/file/tjynz2
; 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)2007
i'm sorry but what is this supposed to do?


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


BlitzSupportMay
Couple of copies of archive...

http://s000.tinyupload.com/index.php?file_id=78520137689960463917
https://www.sendspace.com/file/tjynz2


Code Archives Forum