Forum Replies Created
-
AuthorPosts
-
thank you Jesse!
OK now my model is on the screen
thank you!
ohh sorry, here is full code
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150Namespace test3#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"#Import "assets/"Using std..Using mojo..Using mojo3d.. 'The new mojo 3d module.Class MyWindow Extends Window' What are we going to use.Field myscene:SceneField mycamera:CameraField mylight:LightField ship:ModelField yawEntity:EntityField pitchEntity:EntityMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )Super.New( title,width,height,flags )' Get the current scenemyscene=Scene.GetCurrent()'create camera'mycamera = New Cameramycamera.Viewport=Rectmycamera.Near = 1 '??mycamera.Far = 1000 'how far should we rendermycamera.FOV = 60'create light'mylight = New Lightmylight.RotateX(Pi/2) 'aim directional light 'down' - Pi/2=90 degrees.ship=Model.Load( "asset::test2.gltf" )Assert( ship )ship.Mesh.FitVertices(New Boxf(1,1),False)mycamera.Move(0,10,250) 'move the camera to position x,y,zmycamera.PointAt(ship)'ship = Model.Load( "asset::test.gltf" )yawEntity = New EntitypitchEntity = New EntitypitchEntity.Parent = yawEntitymycamera.Parent = pitchEntity'testing FMOD function (METHOD)End Method' This method is the main loop.Method OnRender( canvas:Canvas ) OverrideRequestRender()myscene.Update()UpdateInput()'mybox.Rotate(3,3,3) 'rotate the box (x,y,z)mycamera.Render( canvas )'myscene.Render( canvas,mycamera ) 'render the 3d sceneIf Keyboard.KeyReleased(Key.Escape) Then App.Terminate()canvas.DrawText("FPS = " + App.FPS,0,0)End MethodMethod UpdateInput()Local mousePos:Vec2f = Mouse.LocationmousePosDelta.x = mousePos.x - previousMousePos.xmousePosDelta.y = mousePos.y - previousMousePos.ypreviousMousePos = mousePos'Print mousePosDelta.x + " -- " + mousePos.xIf Mouse.ButtonDown(MouseButton.Right) Then'Local yaw:Float = mousePosDelta.x'Local pitch:Float = mousePosDelta.yPrint mousePosDelta.x'Mouse.PointerVisible = FalsemouseX = Mouse.X'FMOD(pitch - mouseX * 0.3 * 0.05, 360)'yaw = FMOD(yaw - mouseX * 0.3 * 0.05, 360)'pitch = pitch * (Pi/180)'Print FMOD(pitch - Mouse.X * 0.05, 360) + " -- " + RAD2DEG(pitch)yawEntity.Rotate(0,yaw,0)'pitchEntity.Rotate(-pitch,0,0)mousePosDelta = New Vec2f(0)mouseX = 0EndifEnd MethodMethod FMOD:Float(x:Float, y:Float)Local d:Floatd = x / yd = Floor(d)'d = Round(d)d = d * yd = x - dReturn dEnd MethodMethod DEG2RAD:Float (r:Float)r = (r * Pi) / 180Return rEnd MethodMethod RAD2DEG:Float (r:Float)r = (r * 180) / PiReturn rEnd MethodEnd ClassFunction Main()New AppInstanceNew MyWindowApp.Run()End FunctionHi Mark, Assert(model) did not output anything, anyway here is all code:
Monkey1234567891011Namespace test3#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"#Import "assets/"Using std..Using mojo..Using mojo3d.. 'The new mojo 3d module.Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273Class MyWindow Extends WindowField myscene:SceneField mycamera:CameraField mylight:LightField ship:ModelField yawEntity:EntityField pitchEntity:EntityMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )Super.New( title,width,height,flags )' Get the current scenemyscene=Scene.GetCurrent()'create camera'mycamera = New Cameramycamera.Viewport=Rectmycamera.Near = 1 '??mycamera.Far = 1000 'how far should we rendermycamera.FOV = 60'create light'mylight = New Lightmylight.RotateX(Pi/2) 'aim directional light 'down' - Pi/2=90 degrees.ship=Model.Load( "asset::test2.gltf" )Assert(ship)ship.Mesh.FitVertices(New Boxf(1,1),False)mycamera.Move(0,10,25) 'move the camera to position x,y,zmycamera.PointAt(ship)'ship = Model.Load( "asset::test.gltf" )yawEntity = New EntitypitchEntity = New EntitypitchEntity.Parent = yawEntitymycamera.Parent = pitchEntityEnd Method' This method is the main loop.Method OnRender( canvas:Canvas ) OverrideRequestRender()myscene.Update()UpdateInput()mycamera.Render( canvas )'myscene.Render( canvas,mycamera ) 'render the 3d sceneIf Keyboard.KeyReleased(Key.Escape) Then App.Terminate()canvas.DrawText("FPS = " + App.FPS,0,0)End MethodEnd ClassFunction Main()New AppInstanceNew MyWindowApp.Run()End FunctionOK when I did as you told but still can’t see my model and no errors what so ever… sometimes I getting “Memory access violation” here is code:
Monkey123456mycamera.Move(0,10,25)ship=Model.Load( "asset::test2.gltf" )ship.Mesh.FitVertices(New Boxf(1,1),False)mycamera.PointAt(ship)Any ideas what is wrong?
Than you, will look at these examples!
Thank you for answers
Alpha looks like not working (at least for me, no matter alpha = 0 or =1 result the same).
I loaded GLTF model but still can’t see in my scene… What can be wrong?
Thank you!
Thank you again, I trying to rotate parent but parent and child not rotating
did something wrong. And about blitz no I did not use, I heard about Monkey2 2 days ago and I like so far!
Thank you again!
Thank you Mark! And how about Parent rotation will it apply to its children automatically?
-
AuthorPosts