rohan1231 Posted January 29, 2016 Share Posted January 29, 2016 Hi, I am a newbie with babylon.js and web gl. I want to create a grid ex, 3 x 3 grid and place objects in the cells. Also, I always want to know in which cell the object is present if there. Can someone guide me doing it ? Thanks !! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 29, 2016 Share Posted February 29, 2016 Hi Rohan! Wow, sorry you have not gotten any replies in SO LONG. This is insane. Have you had any success? Generally speaking, you will need to determine which "tile" (which subMesh) of a tiled ground ...a mesh is located-over... by doing some calculating. And you don't NEED to use tiled grounds, either. A standard ground would work just fine, too, if you know the number of subDivisions and the size of the ground. There are fancy methods, too, possibly by shooting a "picking ray" straight down from the mesh, and gathering the ground location from the 'pickingInfo' object that returns. Here is a playground demo that uses it... http://playground.babylonjs.com/#1LZVU4#0 Open your console. You'll see the X and Z values displayed. The picking ray stuff is at lines 137-145 area... inside the renderLoop. In your case, I don't think you will need to put it inside the renderLoop. Your issue might be more... "Hey mesh... run your mesh.whatsMyLocation() function and report.". But then again, you could just check the mesh.position and learn where it is. *shrug* But, the picking ray version does have ONE advantage. If the mesh is not 'over' the ground, the picking ray will report NO HIT... and you might want to know when that is true. *shrug* Then again, it will be a simple calculation to determine if your mesh is off-ground... by analyzing its .position and knowing the dimensions of your ground plane. Tiled grounds are a bit different... and I'm far from an expert on them, and the 'subMesh' that they use. It may be possible to use the picking ray to determine which subMesh (which tile) the picking ray 'hit'. Not sure. I hope some of this helps, and sorry again for the slow response. Be well! GameMonetize 1 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.