|
@@ -7,8 +7,6 @@ Namespace myapp
|
|
|
|
|
|
#Import "assets/"
|
|
|
|
|
|
-#Import "util"
|
|
|
-
|
|
|
Using std..
|
|
|
Using mojo..
|
|
|
Using mojo3d..
|
|
@@ -27,65 +25,61 @@ Class MyWindow Extends Window
|
|
|
|
|
|
Super.New( title,width,height,flags )
|
|
|
|
|
|
- 'little mini cubemap
|
|
|
- Local pixmap:=New Pixmap( 4,3 )
|
|
|
- pixmap.Clear( Color.Black )
|
|
|
- pixmap.SetPixelARGB( 1,0,$ffff0000 )
|
|
|
- pixmap.SetPixelARGB( 1,1,$ff00ff00 )
|
|
|
- pixmap.SetPixelARGB( 1,2,$ff0000ff )
|
|
|
- pixmap.SetPixelARGB( 0,1,$ffffff00 )
|
|
|
- pixmap.SetPixelARGB( 2,1,$ffff00ff )
|
|
|
- pixmap.SetPixelARGB( 3,1,$ff00ffff )
|
|
|
- Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap|TextureFlags.FilterMipmap ) 'seamless
|
|
|
-' Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap ) 'seamed
|
|
|
-
|
|
|
_scene=Scene.GetCurrent()
|
|
|
|
|
|
- _scene.EnvTexture=cubemap
|
|
|
-' _scene.SkyTexture=cubemap
|
|
|
-
|
|
|
_scene.AmbientLight=Color.Black
|
|
|
|
|
|
_scene.ClearColor=Color.Black
|
|
|
|
|
|
- Local bloom:=New BloomEffect
|
|
|
- bloom.Passes=4
|
|
|
+ ToggleEnv()
|
|
|
|
|
|
'create camera
|
|
|
'
|
|
|
- _camera=New Camera
|
|
|
- _camera.Near=.1
|
|
|
- _camera.Far=100
|
|
|
- _camera.Move( 0,10,-10 )
|
|
|
-
|
|
|
- 'create light
|
|
|
- '
|
|
|
- '_light=New Light
|
|
|
- '_light.RotateX( 90 ) 'aim directional light 'down' - Pi/2=90 degrees.
|
|
|
+ _camera=New Camera( Self )
|
|
|
+ _camera.Move( 0,0,-5 )
|
|
|
+ New FlyBehaviour( _camera )
|
|
|
|
|
|
- 'create donut - metallic silver...
|
|
|
+ 'create white donut
|
|
|
'
|
|
|
-' Local material:=New PbrMaterial( Color.White,1,0 ) 'shiny metallic white
|
|
|
- Local material:=New PbrMaterial( Color.White,0,1 ) 'rough non-metallic white
|
|
|
+ Local material:=New PbrMaterial( Color.White,1,1 )
|
|
|
|
|
|
_donut=Model.CreateTorus( 2,.5,48,24,material )
|
|
|
+ End
|
|
|
+
|
|
|
+ Method ToggleEnv()
|
|
|
+
|
|
|
+ Global _filter:TextureFlags=Null
|
|
|
+
|
|
|
+ _filter=_filter ? Null Else TextureFlags.FilterMipmap
|
|
|
+
|
|
|
+ 'little mini cubemap
|
|
|
+ Local pixmap:=New Pixmap( 4,3 )
|
|
|
+ pixmap.Clear( Color.Black )
|
|
|
+ pixmap.SetPixelARGB( 1,0,$ffff0000 )
|
|
|
+ pixmap.SetPixelARGB( 1,1,$ff00ff00 )
|
|
|
+ pixmap.SetPixelARGB( 1,2,$ff0000ff )
|
|
|
+ pixmap.SetPixelARGB( 0,1,$ffffff00 )
|
|
|
+ pixmap.SetPixelARGB( 2,1,$ffff00ff )
|
|
|
+ pixmap.SetPixelARGB( 3,1,$ff00ffff )
|
|
|
+ Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap|_filter )
|
|
|
+
|
|
|
+ _scene.EnvTexture=cubemap
|
|
|
|
|
|
- _donut.Move( 0,10,0 )
|
|
|
End
|
|
|
|
|
|
Method OnRender( canvas:Canvas ) Override
|
|
|
|
|
|
RequestRender()
|
|
|
|
|
|
- If Keyboard.KeyHit( Key.Space ) _donut.Visible=Not _donut.Visible
|
|
|
+ If Keyboard.KeyHit( Key.Space ) ToggleEnv()
|
|
|
|
|
|
_donut.Rotate( .1,.2,.3 )
|
|
|
|
|
|
- util.Fly( _camera,Self )
|
|
|
+ _scene.Update()
|
|
|
|
|
|
- _scene.Render( canvas,_camera )
|
|
|
+ _scene.Render( canvas )
|
|
|
|
|
|
- canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
|
|
|
+ canvas.DrawText( "Hit <space> to toggle cubemap filtering (ie: seamless cubemaps)",0,0 )
|
|
|
End
|
|
|
|
|
|
End
|