Jump to content

CreateTiledGround Submeshes


Recommended Posts

Hi am having some problems with the createTiledGround function.

I followed this tutorial and have a tilted ground but I will like to detect a mesh colliding with one of the tiles but when I try and get the boundingInfo for the submeshes its always the same as the Main Mesh.

using the showSubMesesBoundingBox shows me all the bounding boxes


but am struggling to do the collision on a submesh by submesh bases

Any help would be great

Link to comment
Share on other sites

Hi guys!

I had a nice post here, with a playground example, and then I realized I was off-topic.  :)

Ok, attempt #2.  hehe. 

Codelain needs collision detection at tile/submesh level, so PickingInfo.subMeshId is nice, but that's for picks/clicks.  http://playground.babylonjs.com/#1XBLWB#84 has .subMeshId being printed to console when tiles are clicked-upon.

ActionManager's OnIntersectionEnterTrigger doesn't return subMeshId, nor return exact point of intersect... so that won't work.  And you can't put an action manager on each tile, but maybe an actionManager on base mesh or Scene would work.  (I don't understand actionManagers placed on Scene very well yet.)  Still, there appears to be no actionManager trigger that carries subMeshId or any X/Y coords.

Notice the OnIntersectionEnterTrigger in our actionManager playground... lines 124 - 134... but it is a mesh intersecting with another mesh, with no subMesh involved.  Darn.

Notice the Scene-based actionManager in line 113.  It rotates three boxes... like magic!  Off-topic but coooool, sorry.

Now let's go to http://playground.babylonjs.com/?10

Here we see three intersects wired-up... lines 61-80.  We have TWO intersectsMesh and ONE intersectsPoint... but no intersectsSubMesh.  Darn!  :)

Ok, let's pretend we drop a sphere somewhere on the tiled ground.  IntersectsMesh WILL trigger but won't give much information... except which two mesh.  At the time of intersect... a picking ray could be used from the bottom of the sphere, and more information could be gotten... such as a pickingInfo object... which has a .subMeshId property (yay!)  Sigh.

DellaFree's terrain-following sphere uses a picking ray to do its magic.  It can be seen here... http://playground.babylonjs.com/#1L0CBO#2 ... lines 126-135.  Get DellaFree's sphere rolling around on the tiled ground, and have each tile change color when the sphere is intersecting it... and there ya go!  Mesh-to-subMesh collision activated.  ;)

Maybe this kind of thing would work. There's likely other ways and better ideas, too  :)

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.

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.


  • Recently Browsing   0 members

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