jerome Posted January 8, 2016 Share Posted January 8, 2016 http://www.babylonjs-playground.com/#1LEGTP#1 Commented code : each rolling ball has a tiny line on its top, normal to terrain. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted January 8, 2016 Author Share Posted January 8, 2016 Iiceman asked once what was the potential utility of the method getNormalAtCoordinates() ... http://www.babylonjs-playground.com/#RBXBG#1 No physic engine.Actually I compute 3 orthogonal axis (with the cross product) from the particle plane velocity vector and the current ground normal. These 3 axis are the target system where I want to rotate each particle into.So then the power of RotationFromAxisToRef() and that's all. I need to optimize this method a bit so it won't allocate any temporary vector3 : currently only 6 per call. That's not that much, but if you call it 8000 times per frame for 8000 particles for instance, I guess the GC will start to shout. [EDIT] : this one has 2000 boxes and still run at 60 fps on my computerhttp://www.babylonjs-playground.com/#RBXBG#2 JackFalcon, Wingnut, iiceman and 2 others 5 Quote Link to comment Share on other sites More sharing options...
chg Posted January 8, 2016 Share Posted January 8, 2016 http://www.babylonjs-playground.com/#1LEGTP#1 Commented code : each rolling ball has a tiny line on its top, normal to terrain.Is it wrong to say this looks cute for some reason it reminds me of Pikmin or something (I know it's just to demonstrate the feature, but still somehow it seems expressive despite being so simple, lol) jerome and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Dal Posted January 8, 2016 Share Posted January 8, 2016 This seems to have broken something for me... all my trees started floating on the 0 plane when I updated :SDoes it take into account if the groundmesh is translated? Quote Link to comment Share on other sites More sharing options...
jerome Posted January 9, 2016 Author Share Posted January 9, 2016 No, the returned height is the height from the ground, so in the ground local system. This makes sense because the passed x,z are the coordinates an the ground map also.I should document this better. Just add the ground position to your passed or return values : tree.position = ground.position.add(new BABYLON.Vector3(x, y, z);where x, y, z are the coordinates passed and returned from the function or just tree.position.y = ground.position.y + ground.getHeightAtCoordinates(x, z);if you have just a vertical translation Unless everyone prefer that I switch everything to the World system ?I asked this before recoding it but got no answer, so I guessed my assumption was the expected one because of my arguments (local system) Quote Link to comment Share on other sites More sharing options...
jerome Posted January 9, 2016 Author Share Posted January 9, 2016 Wait please As the former version of this function used the ray intersection, so World coordinates, I will change the new function behavior so you can pass (x, y) in the World system and get y in the World system also. I'll do it as from monday. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 11, 2016 Author Share Posted January 11, 2016 fix PRed Quote Link to comment Share on other sites More sharing options...
jerome Posted February 16, 2016 Author Share Posted February 16, 2016 I just added a new complementary method called : updateCoordinateHeights() This function can be called at any time, even within the render loop, and recomputes quickly all the heights of your ground if this ground has been updated (morphed, etc). myMorphFunction(ground); ground.updateCoordinateHeights(); ground.getHeightAtCoordinates(x, z); Moreover, all the algo under the hood now never reallocate any new memory, so the GC is happy and you can morph your ground and recompute the heights in the render loop as many times you want [EDIT] commented PG : http://www.babylonjs-playground.com/#1JXJVF#3 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.