About Monkey 2 › Forums › Monkey 2 Code Library › Lorenz attractor (and future instancing benchmark?)
This topic contains 0 replies, has 1 voice, and was last updated by
DruggedBunny
1 year ago.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
March 22, 2018 at 3:06 am #14091
This was just a quick Blitz3D port, but as it creates a literal copy of the base entity, and there’s not much in the way of optimisation in mojo3d yet, it slows down after only a few thousand copies — to be expected for now.
I imagine if we gain view-culling (and maybe instancing at some point), it could become a useful stress test, since it just keeps adding more and more meshes, but is at least visually interesting in itself for a couple of minutes, and we can always use more mojo3d demos!
[/crayon]Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210[crayon-5cb9a3b7caa4b704162410 inline="true" ]' Don't copy [crayon-5cb9a3b7caa4e868208416] line above if it appears here -- forum bug!#Import "<std>"#Import "<mojo3d>"Using std..Using mojo..Using mojo3d..Global AppName:String = "Lorenz Attractor"#RemQuick Blitz3D port!; ID: 340; Author: BlitzSupport; Date: 2002-06-07 22:11:44; Title: Lorenz 3D; Description: Fractal exploration in 3D; 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.#EndClass Game Extends Window' Basic 3D scene requirements...Field scene:SceneField camera:CameraField light:LightField sprite:ModelConst CAMERA_SPEED_NORMAL:Float = 0.1Const CAMERA_SPEED_TURBO:Float = 0.5Field boost_camera:Bool ' Camera speed boost (left-shift sets True)' Lorenz stuff...Field a:Float = 10Field b:Float = 28Field c:Float = 8.0 / 3.0Field dt:Float = 0.01Field x:Float = 1Field y:Float = 1Field z:Float = 1Field lastx:Float = 1Field lasty:Float = 1Field lastz:Float = 1Field dx:FloatField dy:FloatField dz:FloatField frames:IntField detail:Int = 1 ' Spawn new ball every frameField count:IntMethod New (title:String, width:Int, height:Int, flags:WindowFlags)Super.New (title, width, height, flags)scene = Scene.GetCurrent () ' Important!scene.ClearColor = Color.Blackcamera = New Cameracamera.Near = 0.1camera.Far = 1000light = New Lightsprite = Model.CreateSphere (0.25, 8, 8, New PbrMaterial (Color.White))count = 1EndMethod ProcessInput:Void ()If Keyboard.KeyHit (Key.Escape) Then App.Terminate ()If Keyboard.KeyDown (Key.LeftShift)boost_camera = TrueElseboost_camera = FalseEndifIf Keyboard.KeyDown (Key.A)If boost_cameracamera.Move (0.0, 0.0, CAMERA_SPEED_TURBO)Elsecamera.Move (0.0, 0.0, CAMERA_SPEED_NORMAL)EndifEndifIf Keyboard.KeyDown (Key.Z)If boost_cameracamera.Move (0.0, 0.0, -CAMERA_SPEED_TURBO)Elsecamera.Move (0.0, 0.0, -CAMERA_SPEED_NORMAL)EndifEndifIf Keyboard.KeyDown (Key.Left)camera.Rotate (0.0, 1.0, 0.0)EndifIf Keyboard.KeyDown (Key.Right)camera.Rotate (0.0, -1.0, 0.0)EndifIf Keyboard.KeyDown (Key.Up)camera.Rotate (1.0, 0.0, 0.0, True)EndifIf Keyboard.KeyDown (Key.Down)camera.Rotate (-1.0, 0.0, 0.0, True)Endifcamera.FOV = camera.FOV - (Mouse.WheelY * 5.0)EndMethod UpdateGame:Void ()dx = a * (y - x)dy = b * x - y - x * zdz = x * y - c * zx = x + dx * dty = y + dy * dtz = z + dz * dtPrint xPrint yPrint zPrint ""frames = frames + 1If frames Mod detail = 0' Hack to make cursor appear at front!sprite.SetPosition (lastx, lasty, lastz)Local copy:Model = Model.CreateSphere (0.1, 8, 8, New PbrMaterial (Color.Rnd ()), sprite)copy.Parent = Nullsprite.SetPosition (x, y, z)count = count + 1EndIflastx = xlasty = ylastz = zProcessInput ()scene.Update ()EndMethod OnRender (canvas:Canvas) OverrideUpdateGame ()scene.Render (canvas)canvas.DrawText ("FPS: " + App.FPS, 20, 20)canvas.DrawText ("Count: " + count, 20, 40)canvas.DrawText ("Cursors, A/Z and left-shift to move", 20, 80)RequestRender ()EndEndFunction Main ()' Windowed mode...Local width:Int = 640Local height:Int = 480Local flags:WindowFlags = WindowFlags.CenterNew AppInstanceNew Game (AppName, width, height, flags)App.Run ()End -
AuthorPosts
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.