Jump to content

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


ElemarJR
 Share

Recommended Posts

  • 11 months later...
5 hours ago, JKoehoorn said:


 

var contour = BABYLON.Polygon.Parse(PointsData);
contour.push(point)
var b = new BABYLON.PolygonMeshBuilder(name, contour, scene);

 

You could push points into the contour and then create tour polygon.

Job

What I couldn't understand before was that backslash in the string, but i realized its function was to concatenate. lol. Didn't find it good, cause it makes to lose the indenting.

Anyway, thank you.

Link to comment
Share on other sites

  • 2 weeks later...

I'm getting the "e.equalsWithEpsilon is not a function" error.

My code:

    var contour = BABYLON.Polygon.Parse('');
    for(var i in this.arrEstandes2)
    {
        this.arrEstandes2[i]['pontos'] = jQuery.parseJSON(this.arrEstandes2[i]['pontos']);
        for(var j in this.arrEstandes2[i]['pontos'])
        {
            contour.push(this.arrEstandes2[i]['pontos'][j].replace(',', ' '));
        }
        break;
    }
    var poly = new BABYLON.PolygonMeshBuilder('polygon', contour, this.scene);
    poly.build();
    poly.material = new BABYLON.StandardMaterial("mat", scene);

Am I not including something? Babylon and poly2tri are on...

Thanks

Link to comment
Share on other sites

Your problem seems to be here. it is expected vector2 and not a string

    var contour = BABYLON.Polygon.Parse('');
	contour.push('655.55 120.85');
	contour.push('655.55 65.3');
	contour.push('708.75 65.3');
	contour.push('708.75 120.85');

I think it must be something like this:

http://www.babylonjs-playground.com/#1LGENM#1

I have no error, but I do not know the result you expect this playgroud. (This is something that I have no experience yet poly2tri)

Link to comment
Share on other sites

Hey, it's me again! haha

I needed to extrude my polygons, so I switched to this:

        shape.push(...Vector3 here...);
        var path = [
            BABYLON.Vector3.Zero(),
            new BABYLON.Vector3(0, 0.05, 0)
        ];
        var extruded = BABYLON.Mesh.ExtrudeShape("extruded", shape, path, 1, 0, 0, scene);
        extruded.material = new BABYLON.StandardMaterial("mat", scene);

But i need my shape to be closed. I saw a lot of examples, but none helped me. Could any of you?

Thanks

Link to comment
Share on other sites

Don't be confused by this title post :

triangulation makes a plain polygon (so a surface) from a list of Vector3

extrusion makes a solid from a series of Vector3, what is a linear shape, not a surface

in other terms, extrusion extrudes a linear shape not a plain polygon. That said, extrusion can extrude any linear shape, closed or not. What is your problem ? Could you show us a PG repro ?

Link to comment
Share on other sites

Thank you for your reply.

Simple example: I got four points that turn into a square and i wanted it to be a cube.

Using the code I posted before, it does the job, but i need my square to be closed at its top. Should I put another shape above it? This should be a little heavy to my application.

And sorry about being a noob at 3D, i may be using wrong terms...

Link to comment
Share on other sites

well, to close an extruded shape, you've got two ways :

the most straigt forward is to use the CAP parameter of the extrusion method

if the way the cap is built doesn't fit your expectations, you can then use a polygon built by triangulation

please read the doc about extrusion to know how to add this cap :

http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion

http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes   if you use the MeshBuilder class instead of Mesh class, what is recommended

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