About Monkey 2 › Forums › Monkey 2 Programming Help › 3d – CreateTerrain is in yet?
This topic contains 5 replies, has 4 voices, and was last updated by
DruggedBunny
1 year, 3 months ago.
-
AuthorPosts
-
November 1, 2017 at 3:23 pm #11416
I noticed my older terrain code does not work anymore. I checked the docs in ted2go and there is a CreateTerrain function. But it is not found by the compiler. Maybe I am not doing it right though. Is the docs correct in ted2go? If it does work how do I get it working now? I noticed no example in the mojo3d tests tree.
Mark mentioned new terrain. So it must be something to do with it not working anymore.
It was 4 months ago since I last checked the terrain in mojo3d. Do I need to set it up as a model now?
November 1, 2017 at 8:48 pm #11419There is no specialized terrain class as yet (I am working on one), however there are Mesh.CreateTerrain and Model.CreatTerrain extensions for creating plain mesh based terrains. Here’s a quick, somewhat ropey demo:
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384Namespace myapp#Import "<std>"#Import "<mojo>"#Import "<mojo3d>"#import "assets/terrain_256.png"#Import "util"Using std..Using mojo..Using mojo3d..Class MyWindow Extends WindowField _scene:SceneField _camera:CameraField _light:LightField _terrain:ModelMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )Super.New( title,width,height,flags )'create scene'_scene=Scene.GetCurrent()_scene.ClearColor=Color.Sky'create camera'_camera=New Camera_camera.Near=.1_camera.Far=100_camera.Move( 0,15,-20 )Local fly:=New FlyBehaviour( _camera )'create light'_light=New Light_light.RotateX( 60 )'create terrain''heightmapLocal terrain_hmap:=Pixmap.Load( "asset::terrain_256.png" )'materialLocal terrain_material:=New PbrMaterial( Color.Green )'model+mesh_terrain=Model.CreateTerrain( terrain_hmap,New Boxf( -256,0,-256,256,32,256 ),terrain_material )_terrain.CastsShadow=FalseEndMethod OnRender( canvas:Canvas ) OverrideRequestRender()_scene.Update()_scene.Render( canvas,_camera )canvas.Scale( Width/640.0,Height/480.0 )canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndStick this in mojo3d tests/ dir. It would of course look a lot better with textures and there’s no easy way to do collisions yet (possible-ish though, see mojo3d-physics tests).
November 2, 2017 at 1:59 am #11424Ok, thanks. I was able to get it working.
I forgot to use the Model. before the createterrain. That is why it said the command was not found.
December 29, 2017 at 8:41 pm #12512Out of interest, what’s the state of the new terrain stuff? Do you still work on it?
January 7, 2018 at 8:20 pm #12742BTW: using your collider works great with the terrain. AWESOME! Still testing a lot…
I’ve noticed that the mojo3d-physics is gone in your dev branch, I guess it’s within mojo3d itself now?
January 7, 2018 at 9:26 pm #12744It is.
-
AuthorPosts
You must be logged in to reply to this topic.