Jump to content

surfacic mesh intersecting with a polygon


seb75
 Share

Recommended Posts

Hey,

I use a mesh representing an surface, defined with customMesh. I want to crop the part of this surfacic mesh which goes outside of a given solid defined by an extruded polygon.

I tried to do this using BABYLON.CSG, but my mesh is not a solid, only a surface, so iI does not work.

Do you know any method to crop a mesh given a closed mesh ?

thanks!

Link to comment
Share on other sites

@adam  thanks, the CustomMaterial function would be working, but i'm unable to use custom function within the condition of the function. 

https://playground.babylonjs.com/#AFRP1L

This simple example is working, but not when I change the vPositionW.x -vPositionW.z > 5  test to a more complex one using one my my own function.

mat.Fragment_Custom_Diffuse('if( vPositionW.x -vPositionW.z > 5.){ discard; }');

Do you have any idea how to use custom function in this .Fragment_Custom_Diffuse ?

@JohnK thanks for the idea to create a solid instead of a surface. However, as I'm using several hundred copies of the same mesh, I think performances would be worse if I complexify the mesh from a surface to a solid, isn"t it ?

Link to comment
Share on other sites

4 minutes ago, seb75 said:

I think performances would be worse if I complexify the mesh from a surface to a solid, isn"t it ?

Possible, however if your surface is already double side you would use single sided for 'top and 'bottom' and you would only be increasing the number of indices when forming the edges not the number of vertices so performance may not be worsened too much. Also using the solid particle system for your copies would help.

Here is an example with 1000 cropped meshes https://www.babylonjs-playground.com/#RS3L95#1

Link to comment
Share on other sites

44 minutes ago, seb75 said:

This simple example is working, but not when I change the vPositionW.x -vPositionW.z > 5  test to a more complex one using one my my own function.

This is because the value of 5. gives a plane not intersecting the torus. It is a matter of getting the correct condition.

https://playground.babylonjs.com/#AFRP1L#9

Link to comment
Share on other sites

@JohnK you're right, the plane is not intersecting the torus, it was just an example.

I tried to use a custom function checking if the contemplated point is within a polygon, such function being defined somewhere else in my code, but I'm unsure about how to use this function within Fragment_Custom_Diffuse function. Is it possible to give as condition a custom function returning a boolean ?

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