Roof facing facet.

Recommended Posts

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.


Share this post

Link to post
Share on other sites

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)

Share this post

Link to post
Share on other sites

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]);


            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/


Share this post

Link to post
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.