Răsfoiți Sursa

Updated toy-plane banana for spinning prop!

Mark Sibly 7 ani în urmă
părinte
comite
7fdac020d5

BIN
bananas/toy-plane/models/plane/Plane$0_metallicRoughness.png


BIN
bananas/toy-plane/models/plane/plane.bin


Fișier diff suprimat deoarece este prea mare
+ 445 - 349
bananas/toy-plane/models/plane/plane.gltf


BIN
bananas/toy-plane/models/plane/plane_color.png


+ 43 - 52
bananas/toy-plane/plane.monkey2

@@ -1,4 +1,3 @@
-
 Namespace plane
 
 #Import "<std>"
@@ -8,8 +7,7 @@ Namespace plane
 #Import "source/PlaneControl"
 
 #Import "textures/"
-
-#Import "models/plane/"
+#Import "models/"
 
 Using std..
 Using mojo..
@@ -17,42 +15,44 @@ Using mojo3d..
 
 Class MyWindow Extends Window
 	
-	Global _res :Vec2i
+	Field _res :Vec2i
 	
 	Field _scene:Scene
 	Field _camera:Camera
 	Field _light:Light
+'	Field _fog:FogEffect
 	
 	Field _water:Model
 	Field _plane:Model
 	Field _pivot:Model		'Needs to be a Model instead of Entity otherwise the plane isn't rendered!
 		
 	Field _camTarget:Entity
-	
 	Field test:Model
 	
+	
 	Method New()
 		Super.New( "Toy Plane", 1280, 720, WindowFlags.Resizable )' | WindowFlags.HighDPI  )
 		_res = New Vec2i( Width, Height )
-		Layout = "letterbox"
+		Print _res
+		Layout = "fill"
 		
 		_scene=New Scene
 		_scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )
 		_scene.EnvTexture = _scene.SkyTexture
-		_scene.FogColor=New Color(0.69, 0.78, 0.82, 0.75 )
-		_scene.FogNear=1
-		_scene.FogFar=1000
+		_scene.FogColor = New Color(0.69, 0.78, 0.82, 0.3 )
+		_scene.FogFar = 5000
+		_scene.FogNear = 1
 		
 		'create light
 		_light=New Light
-		_light.Rotate( 54,144,0 )	'calibrated to match sky texture!
+		_light.Rotate( 45, 45, 0 )
 		_light.CastsShadow = True
 		
 		'create water material
 		Local waterMaterial:=New WaterMaterial
 		
-		waterMaterial.ScaleTextureMatrix( 100,100 )
-		waterMaterial.ColorFactor=New Color( 0.05, 0.25, 0.3 )
+		waterMaterial.ScaleTextureMatrix( 300,300 )
+		waterMaterial.ColorFactor=New Color( 0.025, 0.125, 0.15 )
 		waterMaterial.Roughness=0
 		
 		waterMaterial.NormalTextures=New Texture[]( 
@@ -64,8 +64,7 @@ Class MyWindow Extends Window
 			New Vec2f( .02,.05 ) )
 		
 		'create water
-		_water=Model.CreateBox( New Boxf( -2000,-1,-2000,2000,0,2000 ),1,1,1,waterMaterial )
-		_water.CastsShadow=False
+		_water=Model.CreateBox( New Boxf( -10000,-1,-10000,10000,0,10000 ),1,1,1,waterMaterial )
 		
 		'create bloom
 		Local _bloom := New BloomEffect( 2 )
@@ -75,24 +74,37 @@ Class MyWindow Extends Window
 		_pivot = New Model
 		
 		'create airplane
-		_plane = Model.LoadBoned( "asset::plane.gltf" )
-'		_plane.Animator.Animate( 0 )
+		_plane = Model.LoadBoned( "asset::plane/plane.gltf" )
+		_plane.Animator.Animate( 0 )
 		_plane.Parent = _pivot
 		_plane.Position = New Vec3f
-
+		
+'		Local matrix := New AffineMat4<Float>
+'		_plane.Rotate( 0, 180, 0)
+'		_plane.Mesh.TransformVertices( matrix )
+		
+'		Local mat := Cast<PbrMaterial>( _plane.Material )
+'		Local mat := New PbrMaterial( Color.LightGrey, 0.1, 0.1, True )
+'		Local tex := Texture.Load( "asset::plane_Oc.png", TextureFlags.FilterMipmap )
+'		mat.OcclusionTexture = tex
+		
+		Print _plane.Materials.Length
+		Print ( _plane.Material? "true" Else "False" )
+'		_plane.Material = mat
+		
 		'create camera target
-		_camTarget = New Entity( _plane )
+		_camTarget = New Entity( _pivot )
 '		_camTarget = Model.CreateSphere( 0.25, 12, 12, New PbrMaterial( Color.Red ) )
-		_camTarget.Parent = _plane
-		_camTarget.Position = New Vec3f( 0, 0, 10 )
+'		_camTarget.Parent = _plane
+		_camTarget.Position = New Vec3f( 0, 0, -10 )
 
 		'create camera
 		_camera=New Camera( _pivot )
-		_camera.Viewport=Rect
+		_camera.View = Self
 		_camera.Near=.1
-		_camera.Far=1000
-		_camera.FOV = 60
-		_camera.Move( 0,3,-12 )
+		_camera.Far=10000
+		_camera.FOV = 75
+		_camera.Move( 0,3,8 )
 		
 		'Control component
 		Local control := _pivot.AddComponent<PlaneControl>()
@@ -101,51 +113,30 @@ Class MyWindow Extends Window
 		control.target = _camTarget
 
 		_pivot.Position = New Vec3f( 0, 6, 0 )
+		
+'		Local ball := Model.CreateSphere( 2, 24, 24, New PbrMaterial( Color.Red, 0.1, 0.25 ) )
+'		ball.Move( 0, 4, 0)
 	End
 	
 	
 	Method OnRender( canvas:Canvas ) Override
 		RequestRender()
-		
-		_camera.Viewport=Rect
-		
 		_water.Position=New Vec3f( Round(_camera.Position.x/2000)*2000,0,Round(_camera.Position.z/2000)*2000 )
-
-		_camera.WorldPointAt( _camTarget.Position )
-		
+		_camera.PointAt( _camTarget.Position )
 		_scene.Update()
-		_scene.Render( canvas )
-		
-		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
-'		canvas.DrawText( _plane.Rotation,0,15 )
-'		canvas.DrawText( _plane.LocalRotation,0,30 )
+		_camera.Render( canvas )
+		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS + "    Aspect=" + _camera.Aspect,0,0 )
 	End
 	
-'	
+	
 	Method OnMeasure:Vec2i() Override
 		Return _res
 	End
 	
 End
 
-
-Class Entity Extension
-	
-	Method WorldPointAt( target:Vec3f,up:Vec3f=New Vec3f( 0,1,0 ) )
-		Local k:=(target-Position).Normalize()
-		Local i:=up.Cross( k ).Normalize()
-		Local j:=k.Cross( i )
-		Basis=New Mat3f( i,j,k )
-	End
-
-End
-
 Function Main()
-	
 	New AppInstance
-	
 	New MyWindow
-	
 	App.Run()
 End
-

+ 6 - 6
bananas/toy-plane/source/PlaneControl.monkey2

@@ -45,28 +45,28 @@ Class PlaneControl Extends Behaviour
 		If Keyboard.KeyDown( Key.Left )
 			_azimuthGoal += turnRate
 			_yaw = maxYaw
-			_roll = maxRoll
+			_roll = -maxRoll
 		Else If Keyboard.KeyDown( Key.Right )
 			_azimuthGoal -= turnRate
 			_yaw = -maxYaw
-			_roll = -maxRoll
+			_roll = maxRoll
 		Else
 			_yaw = 0
 			_roll = 0
 		Endif
 		
 		If Keyboard.KeyDown( Key.Up )
-			_pitch = maxPitch
+			_pitch = -maxPitch
 			_ySpeedGoal = -ascentionRate * 2.0
 		Else If Keyboard.KeyDown( Key.Down )
-			_pitch = -maxPitch
+			_pitch = maxPitch
 			_ySpeedGoal = ascentionRate
 		Else
 			_ySpeedGoal = 0
 			_pitch = 0
 		Endif
 
-		_zSpeed = speed * _throttle * delta
+		_zSpeed = -speed * _throttle * delta
 		_ySpeed = Smooth( _ySpeed, _ySpeedGoal, lag, delta )
 		
 		entity.Move( 0, _ySpeed, _zSpeed )
@@ -80,7 +80,7 @@ Class PlaneControl Extends Behaviour
 		
 		camera.LocalRz = plane.LocalRz/2.0
 		
-		target.LocalX = Smooth( target.LocalX, -_yaw/4.0, lag, delta )
+		target.LocalX = Smooth( target.LocalX, _yaw/4.0, lag, delta )
 		
 	End
 	

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff