oschakravarthi Posted November 23, 2018 Share Posted November 23, 2018 Hi all, I have a simple requirement but i have no clue how to do it. I have a mesh (may look like box). 1. I need to identify its top/roof facing facet(s). 2. Devide this plane into cells (like each cell is a 5*5 in size) and get the coordinates of these cells. Please help me. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 23, 2018 Share Posted November 23, 2018 1. for each facet look at the direction of normal in world space (compute dot of face normal and vector up or down for instance). 2. I do not understand the question or goal (seems similar to what facet partitioning is doing) Quote Link to comment Share on other sites More sharing options...
jerome Posted November 24, 2018 Share Posted November 24, 2018 https://doc.babylonjs.com/how_to/how_to_use_facetdata Quote Link to comment Share on other sites More sharing options...
oschakravarthi Posted November 24, 2018 Author Share Posted November 24, 2018 Thank you @sebavan and @jerome. I have gone thru this but I could not understand as I am new to these concepts. What I understood is each facet is a triangle. Now, how to get the 3 points (world coordinates) of a facet? Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 24, 2018 Share Posted November 24, 2018 You will need to find out more about the data structure of a mesh from https://doc.babylonjs.com/how_to/custom https://doc.babylonjs.com/how_to/updating_vertices Quote Link to comment Share on other sites More sharing options...
oschakravarthi Posted November 25, 2018 Author Share Posted November 25, 2018 Thank you @JohnK I now understood how the information is stored internally. The below function get the details. var getFacetTrianglesOfMesh = function (mesh) { var indices = mesh.getIndices(); var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); var nbFaces = indices.length / 3; var triangles = []; for (var i = 0; i < nbFaces; i++) { var triangle = []; for (var j = 0; j < 3; j++) { var ind = (i * 3) + j; var point = new BABYLON.Vector3(positions[ind], positions[ind + 1], positions[ind + 2]); triangle.push(point); } triangles.push(triangle); } return triangle; }; Now I need to do face sampling. I need to divide each facet into a grid of equal sized cells. Any clue how to do this? Gone thru this article but could not understand. https://chrischoy.github.io/research/barycentric-coordinate-for-mesh-sampling/ Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 26, 2018 Share Posted November 26, 2018 You can look at the partitioning code from @jerome in the facet tools. Basically go over each face compute if center is in a box or if area in > area out (depending on the precision and time you have) put in a list of triangle for this box. 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.