BangTao Posted March 1, 2017 Share Posted March 1, 2017 aha,hello to all the smarter and warm-hearted helper! let's get to the point/ I'm study the Tutorials about "How to use Facet data",and there is a description about mesh partitioning,and the Official PG is http://www.babylonjs-playground.com/#UZGNA and here is mine: http://www.babylonjs-playground.com/#1YTZAC#5 so,if i call "updateFacetData()" method,then there will be 10*10*10(default) blocks here,,right? i wanna know: if there is a way/method to check if a specific block contains/intersect some facet(the whole facet or part of it). thanks for u time. Quote Link to comment Share on other sites More sharing options...
jerome Posted March 1, 2017 Share Posted March 1, 2017 yep say x is the index of the block on the mesh X local axis, y is the index of the block on the mesh Y local axis, and z the index on the Z local axis. So if you want to know what is inside the (x-th, y-th, z-th) block when it's partitioned by 10x10x10, just compute i = x + 10 * y + 10 * 10 * z and call mesh.getFacetLocalPartioning() what returns an array of arrays of facet indexes : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.abstractMesh.ts#L1821 var i = x + 10 * y + 10 * 10 * z; var blocks = mesh.getFacetLocalPartioning(); blocks[i] // contains all the facets intersecting the block indexes Quote Link to comment Share on other sites More sharing options...
BangTao Posted March 1, 2017 Author Share Posted March 1, 2017 @jerome o,thx,so if it's 10*10*10,there should be 1000 blocks. console.log(blocks.length) http://www.babylonjs-playground.com/#1YTZAC#6 the result is >1000,why is that? console.log(blocks) the result is: does this means : block[23] contain(include intersect) the 349th、350th、351th、396th、397th、398th facet block[24] only contain(include intersect) the 349th facet? Quote Link to comment Share on other sites More sharing options...
jerome Posted March 1, 2017 Share Posted March 1, 2017 Nope, this is a flat array, for performance access reasons, with a max size of 10 + 10 * 10 + 10 * 10 * 10 But not all the elements are populated, only the one containing / intersecting a facet. This is why the actual size can be lower than this maximum. Example : block[6] = [12, 23] means the facet 12 and 23 intersects the 6-th block on the X axis yes, for your second question : the facets 349, 350, 351, etc, up to 398 have a least one vertex or their own center (barycenter) in the block[23] Quote Link to comment Share on other sites More sharing options...
BangTao Posted March 1, 2017 Author Share Posted March 1, 2017 @jerome oh,haha ,got it.Thank u Quote Link to comment Share on other sites More sharing options...
BangTao Posted March 2, 2017 Author Share Posted March 2, 2017 @jerome hi,jerome: when i use sphere to test "getFacetLocalPartitioning()" function.it works perfectly. mesh = BABYLON.Mesh.CreateSphere("sphere", 32.0, 10.0, scene); so if i change the mesh to a cube,i think it should be a cube made up with many little cubes.right? mesh = BABYLON.Mesh.CreateBox("box", 10.0, scene); but it seems that they didn't work well,the PG is : http://www.babylonjs-playground.com/#TQPS2 so if block != undifined as you said :the block will have a least one vertex or their own center (barycenter) ... can i check if a block contain part of the facet(Neither vertex nor center ,just part of it)? Quote Link to comment Share on other sites More sharing options...
jerome Posted March 2, 2017 Share Posted March 2, 2017 In order to work well, the facets must be in general far smaller than the blocks (if the facets are as big as the blocks, the results may be weird) and it's mostly intended to manage meshes with many tiny facets (several dozens, hundreds, thousands, etc) rather than meshes with few big facets. The box is, by definition, a mesh with few big facets, so the block partitioning is probably not the best tool here. You could try by reducing the block number for the box to 4 or 3 though. There's no provided method to check if just a part of a facet is in a given block : only the 3 vertices and the facet center are tested so far (this means 4 tests per facet, what can lead to high computation when dealing with 10K facets ex : the skull) 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.