jerome Posted January 3, 2016 Share Posted January 3, 2016 continued from : http://www.html5gamedevs.com/topic/15523-getheightatcoordinates-alternative/?p=111175 same algo slightly modified for a ribbon : http://www.babylonjs-playground.com/#1QC4YQ#8 Quote Link to comment Share on other sites More sharing options...
jerome Posted January 3, 2016 Author Share Posted January 3, 2016 Stronger ! with a live morphed ribbon : http://www.babylonjs-playground.com/#1QC4YQ#10 obviously, this needs some GC optimizations but it still runs please don't mind about the balls jumping on the edges, I just return altitude == 0 when the balls are out of the ribbon, even if they are above the trough of the wave the same with lower ball velocities to better understand : http://www.babylonjs-playground.com/#1QC4YQ#11 note : there are no physics here (so no gravity, no friction, no acceleration, no mass, etc), the ball still roll from an edge to another following the waving surface Quote Link to comment Share on other sites More sharing options...
Convergence Posted January 3, 2016 Share Posted January 3, 2016 Great work on a staple function of game-making How about a getAngleAt(x, z, rotation) ? to make it work for cubes Quote Link to comment Share on other sites More sharing options...
jerome Posted January 3, 2016 Author Share Posted January 3, 2016 quick and dirty GC optimization : http://www.babylonjs-playground.com/#1QC4YQ#12 about the angle, I'm thinking about it ... something like getNormalsAt() and/or getSlopeAt() this runs at 58 fps on my laptop : http://www.babylonjs-playground.com/#1QC4YQ#13as you can see there many subdivisionsthis would run faster with far less subdivisions Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted January 3, 2016 Author Share Posted January 3, 2016 I reduced the number of subdivisions, now this runs at 60 fps on my laptop with 100 balls : http://www.babylonjs-playground.com/#1QC4YQ#14 Quote Link to comment Share on other sites More sharing options...
jerome Posted January 3, 2016 Author Share Posted January 3, 2016 500 balls floating on the waving surface at 35 fps on my old laptop : http://www.babylonjs-playground.com/#1QC4YQ#15not that bad if I don't care about the erratic movement on the edges 2000 tiny floating balls : http://www.babylonjs-playground.com/#1QC4YQ#16still 25 fps in full screen on my pushcart computer ... I love this framework ! Quote Link to comment Share on other sites More sharing options...
jerome Posted January 4, 2016 Author Share Posted January 4, 2016 up @DK : let me know if you want it as a new function or in replacement of getHeightAtCoordinatesknowing this : http://www.html5gamedevs.com/topic/15523-getheightatcoordinates-alternative/?p=110994 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2016 Share Posted January 4, 2016 As long as this produces the same result, we can use the new algorithm in the previous function Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2016 Share Posted January 4, 2016 Or perhaps keep the current implementation and hide it under a flag in the function signature (In order to keep it working with tiled grounds) Quote Link to comment Share on other sites More sharing options...
jerome Posted January 4, 2016 Author Share Posted January 4, 2016 Actually to get the height of a flat tiled ground is not that pertinent imho ... Ok, what I propose is to keep aside the current implementation within the function code and add a boolean to the tiled ground constructor : isTiled = true If isTiled, the function will do the same as currently (ray intersection)else :on first call, it will generate the underlying quad array (if it doesn't already exists)on each call, it will compute the height from this array Oki doki ? Unless you prefer, I just add a flag in the signature of getHeightAtCoordinates() to allow the user to explicitly choose the way he wants (more simple to code for me) And I will also provide the almost same for ribbons/grounds/whatever with the same geometry in vanilla JS in UserFunction repository. This version will have an updatable quad array in the render loop, like I did in the PG with the waving ribbon. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2016 Share Posted January 4, 2016 oki doki Quote Link to comment Share on other sites More sharing options...
jerome Posted January 4, 2016 Author Share Posted January 4, 2016 BTW, as the facet plane equations are pre-computed also in the array, I would like to provide a fast method to get them at will : getFacetNormalAt(x, z) ? => returns a Vector3, the normal to the map at the coordinates (x, z)orgetFacetPlaneEquationAt(x, z) ? => returns a Vector4(a, b, c, d) , the plane equation ax + by + cy + d = 0 at the coordinates (x, z) , knowing that (a, b, c) is actually the normal described in getFacetNormaAtl()Which one do you prefer ? Or any other more pertinent name, let me know ... This could be very useful for the users to set mesh orientations/rotations on the map surface. Note : for a tiled ground, this would return (0, 1, 0) for instance, in any case. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2016 Share Posted January 4, 2016 For the sake of comprehension I prefer the first one! Quote Link to comment Share on other sites More sharing options...
jerome Posted January 6, 2016 Author Share Posted January 6, 2016 mmh.. after reading the code in the class meshBuilder, I can see that the TiledGround is NOT an instance of the class GroundMesh, but only an instance of the class Mesh.In other terms, the current method getHeightAtCoordinates() is not a method of a TiledGround object : http://doc.babylonjs.com/classes/2.2/TiledGround I should have checked this before ! (that's why it wasn't pertinent)This means I can simply replace the current code of getHeightAtCoordinates() by the new one No need for special tips, flags, etc. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 6, 2016 Author Share Posted January 6, 2016 PRed in replacement of the current oneworks pretty well on my test scene Quote Link to comment Share on other sites More sharing options...
jerome Posted January 6, 2016 Author Share Posted January 6, 2016 BTW, it returns y from x, z in the ground local system as it doesn't really make sense to return an altitude from the ground in the world system but if it's expected in the world system I can fix it as well Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.