Jump to content

getAltitudeAt()


jerome
 Share

Recommended Posts

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

Link to comment
Share on other sites

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#13

as you can see there many subdivisions

this would run faster with far less subdivisions

Link to comment
Share on other sites

500 balls floating on the waving surface at 35 fps on my old laptop : http://www.babylonjs-playground.com/#1QC4YQ#15

not that bad  ;) if I don't care about the erratic movement on the edges

 

 

2000 tiny floating balls : http://www.babylonjs-playground.com/#1QC4YQ#16

still 25 fps in full screen on my pushcart computer ... I love this framework !

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

or

getFacetPlaneEquationAt(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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...