Author Topic: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH  (Read 2282 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 724
INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« on: May 30, 2023, 01:33:08 PM »
Is there anyone who can suggest me some (preferably SIMPLE) algorithm
to INCREASE and REDUCE the NUMBER of TRIANGLES
(and therefore of vertices) of a 3D MESH?

And in case you increase vertices, these new vertices should be a LITTLE bit, RANDOM ...

Let's imagine a terrain defined by a 3D MESH, and to make it look MORE REAL
we want to make it more DETAILED and a little more IRREGULAR ...

a kind of NOISE of 3DSMAX and not only ...

But also the algorithm to REDUCE the number of triangles and vertices
is VERY USEFUL, because sometimes there are too many points and too many triangles
and then you need to lighten the file size ...
« Last Edit: May 30, 2023, 02:41:05 PM by domenicomaria »

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #1 on: May 30, 2023, 11:40:38 PM »
"Let's imagine a terrain defined by a 3D MESH, and to make it look MORE REAL we want to make it more DETAILED and a little more IRREGULAR "

If your a civil Engineer then you will know about breaklines and the effect they have on surface triangles, which sounds like what you want.

A man who never made a mistake never made anything

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #2 on: May 30, 2023, 11:55:59 PM »
I am not a civil Engineer ...

I'm just a draftsman
(and almost an architect ... I never completed my studies even though I was quite advanced)

I still prefer to solve as many things as possible
(although sometimes it's slow) with Lisp ...

without using other software, which certainly do this and many other things
and they do it very well too...

... because if I wrote the functions,
I have much more control over them and can modify them whenever I want


domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #3 on: May 31, 2023, 12:19:38 AM »
I want to use LUMION or TWINMOTION ...

... and to create the 3D model to export
and to manage landforms and also to create some simple roads
I don't want to switch to CIVIL 3D or to a similar software ...

and I would like to have a set of functions that help me
to do at least some of these things ...

I know the "Tin surfaces", the "corridors" and "breaklines" of Civil 3D ...

but for the moment, I want to try to create some Lisp functions
that help me to do something similar ...

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #4 on: May 31, 2023, 03:39:08 AM »
for example, this is an initial and rudimentary attempt to simulate Civil3D breaklines...


https://drive.google.com/file/d/1c-IxzPLYquF_TcHKO6nUIPqmQ3NK3tzp/view?usp=sharing

ribarm

  • Gator
  • Posts: 3257
  • Marko Ribar, architect
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #5 on: May 31, 2023, 08:11:26 AM »
for example, this is an initial and rudimentary attempt to simulate Civil3D breaklines...


https://drive.google.com/file/d/1c-IxzPLYquF_TcHKO6nUIPqmQ3NK3tzp/view?usp=sharing

You will need additional embarkment and cutting areas left and right from breaklines...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #6 on: May 31, 2023, 09:21:17 AM »
@MR
I will need many things ...
...
But for the moment
i need to understand how to
INCREASE and REDUCE
the NUMBER of TRIANGLES ...
« Last Edit: May 31, 2023, 09:25:35 AM by domenicomaria »

ribarm

  • Gator
  • Posts: 3257
  • Marko Ribar, architect
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #7 on: May 31, 2023, 11:13:28 AM »
For INCREASE :
create additional points at mid of each edge...

For DECREASE :
create points at center of gravity of each triangle - ommit already existing original triangulation points...

- Retriangulate -

But real pain in the neck is embarkment and cutting areas (if you need terrain mod...)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #8 on: May 31, 2023, 12:19:01 PM »
For INCREASE :
create additional points at mid of each edge...

For DECREASE :
create points at center of gravity of each triangle - ommit already existing original triangulation points...

- Retriangulate -

But real pain in the neck is embarkment and cutting areas (if you need terrain mod...)...

I already did exactly as you say,
but it's not enough for me
because I would like to obtain a more uniform network of triangles.

And now I'm working out a solution where,
I first calculate the mean area of the triangles
and increase the number of vertices
(adding the midpoints of each side and the center of gravity)
only in triangles that have an area above the average ...
...
...and I probably have to do the same thing
for vertex reduction,
eliminating (but replacing them with the center of gravity)
only the vertices of the triangles they have
a smaller than average area ...
... and this to obtain a more uniform result ...

in addition, with a pseudo-random number generator,
and taking into account the coordinates of the closest vertices,
all new points are slightly random ...
this is to give a more realistic look...

"the embarkment and cutting areas" ...
I don't want to and I could never, and then with lisp, rewrite Civil 3D !

I just want to be as self-sufficient as possible
to be able to draw terrain models and roads and something else ...

and that's already a lot (maybe too much) for me ...

(to then generate solids to export to Lumion or Twinmotion)

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #9 on: May 31, 2023, 08:40:49 PM »
Adding roads as Ribarm has hinted is more complex than just adding breaklines. I did a project that had multiple pathways threading through a very large park, some pathwys crossing each other, there was like 15 surface edits as needed for each pathway to be added.

You need maybe ask some one nicely to do the add road to your surface model. Maybe beer money. There is some triangulation lisps out there but have not seen any do primitive add road. Thats why CIV3D exists.

For me starting in the 80's road design software,  I use now Civil Site Design. Look at the batters in this image.

A man who never made a mistake never made anything

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #10 on: June 01, 2023, 03:28:32 AM »
@BIGAL

for some time now, I've been watching Civil3D tutorials ...

and I also had the chance to "play" a little with Civil3D
and I imported a text file containing a collection of points,
generated a Tin surface, drew an "alignment",
I used sub-assemblies and assemblies to define the "type section" of a road,
I "drew" the profile of this road and finally I created a "corridor"
and used also the "drive" command which is a lot of fun ...

and I know that CIVIL3D is very powerful,
and that there are good reasons why it exists.

And I want to learn how to use it.
At least at a minimal level.
To bring out the 3d models I need.

But still I want to continue building a library of functions on meshes,
because it will still be useful in many situations.

I have seen the picture of your work.

It's not difficult to understand that making all these roads,
which go up and down,
with all these intersections of various types ... is a mess.

. . .

Anyway ... do you drink a lot of beer ?

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #11 on: June 01, 2023, 09:21:43 PM »
Get a copy of TriangV0.5.9.lsp by YMG it will make triangular surfaces. Plus other stuff.

Thinking more if you were to convert a surface to a solid you could draw a 3d path and add a road shape along the path so have 2 solids, subtract road and you have what your looking for. the road shape could have batter slopes need to make sure are wide enough for the subtraction, this is what the "merge surfaces" does in the civil software.

Also look at Civil Site Design.
A man who never made a mistake never made anything

domenicomaria

  • Swamp Rat
  • Posts: 724
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #12 on: June 02, 2023, 12:56:18 AM »
I am not able to find TriangV0.5.9.lsp
. . .
where is it ?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #13 on: June 02, 2023, 01:20:54 AM »
Someone should port Delaunator to lisp as it can keep track of the half edges

I had some stuff here https://www.theswamp.org/index.php?topic=58049.msg613573#msg613573
But it’s been a while, if you follow the link in that post, it explains how to iterate triangles in order

I would have no clue how to change the resolution of a point set, except maybe eliminate nearest neighbors that are not on the edge and under some tolerance

The routine has been ported to Python, JavaScript, C++, a master lisper should be able to port it

 

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: INCREASE or REDUCE the NUMBER of TRIANGLES in a 3D MESH
« Reply #14 on: June 03, 2023, 02:45:04 AM »
Here is the triangulation.

;; C:TIN, Generates Delaunay Triangulation and Voronoi Diagram.   
A man who never made a mistake never made anything