Jump to content

Create a new mesh with a polygon points list (Triangulation)


ElemarJR
 Share

Recommended Posts

I intend to implement (after seeing the whole video tutorial and I'm only at the end of first chapter, arrg ... great job, guys !) some kind of ribbon mesh :

- two arrays A and B of vertices, each being a kind of curve/path points : A1, A2, ... for array A and B1, B2, ... for array B

- then creation of adjacent triangles between these two pathes A1-B1-A2, B1-A2-B2, A2-B2-A3 and so on until the first end reached on one of the arrays

 

BABYLON.mesh.createRibbon(arrayA, arrayB)

 

not sure I'm very clear :-P

I will try in the playground next weeks

 

I think it could be a light usefool tool to create easily many types of surfaces.

 

By the way, why the name "BABYLON" was chosen ?

Link to comment
Share on other sites

You can certainly create a Mesh in the playGround.  Write a function:

function createRibbon(mesh, arrayA, arrayB){   var positions = [];   var indices = [];    // process Arrays into positions & indices    ...      var normals = new Array[positions.length];    BABYLON.VertexData.ComputeNormals(positions, indices, normals);    mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false);    mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals, false);    mesh.setIndices(indices);}

If you think it needs to become part of the repository though, I think it should be a sub-class, in its own file.  The body of the function the constructor.  Make it possible to exclude for Make your own babylon.

Link to comment
Share on other sites

Perfect! I already forked the repository. What's the policy about using external libraries? I was thinking about implement a Constrained Delaunay triangulation algorithm, to support holes, but there are good implementations available (poly2tri in https://github.com/r3mi/poly2tri.js, for example).

 

Could I use it? should I reimplement everything? Should I think about some plugin system to use it?

Link to comment
Share on other sites

 

 

By the way, why the name "BABYLON" was chosen ?

I'm also not to sure about the name, why not call it Athens? :)

 

btw I'm wanting to create some more primitive meshes , is this of sort of thing we can contribute to the babylon github repo?

Link to comment
Share on other sites

I'm also not to sure about the name, why not call it Athens? :)

 

It's a joke ??? At this stage of development, it's a little late to suggest another name. So why a name is better than another ? And Three.js, why not name it Four.js ? Athens? Why is it better than Babylon?

Link to comment
Share on other sites

Hello,

 

The implementation of triangulation with constrained delaunay (support to holes it's not trivial). poly2tri implements the algorithm in a good way and I don't think so that reimplement it is a good idea.

 

screenshot1.jpg

 

screenshot2.jpg

 

 

To create the mesh of the screenshots I wrote, using my current implementation, something like that:

var rectangle = BABYLON.Polygon.rectangle(-15, -15, 15, 15);var ground = new BABYLON.PolygonMeshBuilder("ground", rectangle, this.scene)    .addHole(BABYLON.Polygon.bird())    .build();

Do you really think that create a "PolygonMesh" class could be simpler to use? I think that is best to verify the reference to poly2tri in the build method.

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

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...