pbrspheres.monkey2 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. Namespace myapp
  2. #Import "<std>"
  3. #Import "<mojo>"
  4. #Import "<mojo3d>"
  5. #Import "assets/miramar-skybox.jpg"
  6. #Import "assets/spheres.gltf"
  7. Using std..
  8. Using mojo..
  9. Using mojo3d..
  10. Class MyWindow Extends Window
  11. Field _scene:Scene
  12. Field _camera:Camera
  13. Field _light:Light
  14. Field _ground:Model
  15. Field _spheres:Model
  16. Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
  17. Super.New( title,width,height,flags )
  18. _scene=New Scene
  19. _scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap|TextureFlags.Envmap )
  20. 'create camera
  21. '
  22. _camera=New Camera( Self )
  23. _camera.Near=.01
  24. _camera.Move( 0,10,-10 )
  25. New FlyBehaviour( _camera )
  26. 'create light
  27. '
  28. _light=New Light
  29. _light.Rotate( 54,144,0 ) 'calibrated so specular highlight matches sun on sky texture!
  30. Local godrays:=New GodraysEffect( _light )
  31. _scene.AddPostEffect( godrays )
  32. 'create ground
  33. '
  34. Local mesh:=Mesh.CreateBox( New Boxf( -50,-1,-50,50,0,50 ),1,1,1 )
  35. Local material:=New PbrMaterial( Color.Green,0,.5 )
  36. _ground=New Model( mesh,material )
  37. 'create spheres
  38. _spheres=Model.Load( "asset::MetalRoughSpheres.gltf" )
  39. _spheres.Move( 0,10,0 )
  40. End
  41. Method OnRender( canvas:Canvas ) Override
  42. RequestRender()
  43. _scene.Update()
  44. _scene.Render( canvas )
  45. canvas.DrawText( "FPS="+App.FPS,Width,0,1,0 )
  46. End
  47. End
  48. Function Main()
  49. New AppInstance
  50. New MyWindow
  51. App.Run()
  52. End