Page 1 of 3

3D subtraction of parts ...

Posted: Tue Oct 22, 2024 10:31 pm
by marc_256
Hi,

For my cnc (lathe) simulator,
I want to create a WYSIWYG tooling evolution of the part.

What I mean is, when the tool (#1) is moving inside the part (#2), from right to left.
I want to subtract the tool motion from the part with the result (#3).

I don,t know I'm explaining this well ...

Is this possible to do with OGRE ?
This is a 3D substraction.

Thanks,
Marc

Image

Image

Re: 3D subtraction of parts ...

Posted: Wed Oct 23, 2024 6:13 am
by IceSoft
marc_256 wrote: Tue Oct 22, 2024 10:31 pm Is this possible to do with OGRE ?
This is a 3D substraction.
I would ask on a native OGRE forum first

Re: 3D subtraction of parts ...

Posted: Thu Oct 24, 2024 6:56 pm
by SMaag
As I found out until know: it is not possible!
What we need for such 3D solid model calculations is a system like OpenSCAD.

A second way with meshes might be to do somthing like clipping where we use the postion
of the tool as the drawing limit and we do a clipping at this position.
(Adding a new point there and remove all points outside in direction to the tool)
but that's manual work and has to be done with the CPU.

You/We have to solve some other problems:
- Converting solid 3D Models into a surface Mesh
- parsing 3D solid gemotry files like .iges or .Step

Once again I want to set the focus on the Vector Modules VECf and VECd which I started to do
optimized 3D Vector calculations and on my tries to implement iges and step.

Maybe take a look on my first try for 2D/3D Vector Objects at
https://github.com/Maagic7/PureBasicFra ... le_VObj.pb
it's the Brainstorming how to implement basic 3D solid Objects and convert it into a Mesh.
But completely untested Brainstorming code!

Re: 3D subtraction of parts ...

Posted: Fri Oct 25, 2024 11:17 am
by marc_256
Hi IceSoft,

Yes, I need to do that ...
PB forum is not the place for this type of questions ...


And sMaag,

Thanks again for your reply,
I think we are the only one on this forum who are doing/developing some 3D CAD stuff.

- What we need for this example, is a editable hollow cylinder,
that we can subtract from the workpart.

- For the cutting tool, we need a editable hollow ring.



In some days I will have some time, to restart the development of my CAD/CAM/CNC/PLC program.
And will take a look on your STEP work as well...



- For my 2D work, I'm refining my import HPGL2 -> PB graphics converter (85% done).
- For my 3D work, I'm continuing my import COLLADA -> Ogre Mesh Converter (0% done) what I'm doing now via BLENDER.
- After that, I will go for the 3D CAD/CAM editing tools ...


PS: take a look at this: www.CGAL.org (france)
I found this very interesting stuff.
But I don't know how to implement this in my software.


Marc,

Re: 3D subtraction of parts ...

Posted: Fri Oct 25, 2024 3:45 pm
by SMaag
PS: take a look at this: www.CGAL.org (france)
I found this very interesting stuff.
But I don't know how to implement this in my software.
We can't implement this in PB! That are C++ classes. Same problem as with OpenSCAD.
I did a little reasarch and found OpenSCAD uses CGAL too.

Re: 3D subtraction of parts ...

Posted: Sat Oct 26, 2024 5:27 pm
by SMaag
Here I found an OpenSource Project of the basic functions you need. A really good documentation. Usable in PB, because all is done with standard C-Fuctions. Professional Code, seems to be from Berkley University.
libCSG:
This library implements the three core CSG operations (intersection, union, and difference) on triangulated meshes. Unlike typical CSG implementations, the meshes to be operated on do not need to be solid (i.e. watertight) or even manifold.

https://github.com/robonrrd/csg/tree/master

Re: 3D subtraction of parts ...

Posted: Sat Oct 26, 2024 10:39 pm
by marc_256
Hi sMAAG,

YES, that's what I need, a csg program ... 8)

I also found this, www.opencsg.org, but is also written in C++
and I also checked openCAD for learning some stuff.

I worked all day on my COLLADA importer, this is again, not so easy ... :? :!:


Thanks for your help,
Marc

Re: 3D subtraction of parts ...

Posted: Sun Oct 27, 2024 8:04 am
by pjay
When I first learnt some basic 3d math, way back in the 80s on a C64, I wrote a program that revolved a defined profile about an axis. This method easily created shapes such as pencils, vases and wine glasses.

A lathe product works identically, so simulating it should also be this simple - IMO there's really no need for the complexity of CSG operations (save that for when you add milling into your simulator!)

Re: 3D subtraction of parts ...

Posted: Sun Oct 27, 2024 11:31 am
by marc_256
Hi pjay,


Hmmm,
you're right, about that ...
for simple lathe work it is the best,
but with threads for screws, it isn't possible anymore.

ok, then I need to restart my research,
and split my program into simple parts and complex parts.


Do you have a snipper of that program, I can start with ?


thanks,
marc

Re: 3D subtraction of parts ...

Posted: Sun Oct 27, 2024 11:56 am
by DarkDragon
I just wanted to throw in that some guy named Shadowturtle made a 3D engine in 2004 where the editor had true CSG functionality. I was highly impressed by that:

https://www.purebasic.fr/german/viewtopic.php?t=1085
https://web.archive.org/web/20070821054 ... iewpage=73
https://web.archive.org/web/20070828000 ... ngine.html

But you can implement CSG in multiple ways.

1. Geometrically:
1.1. Clipping polygons, i.e. calculate their intersection, build new polygons with the non intersecting parts, ...
1.2. Approximately through converting the surface representation into a volumetric representation, subtracting volumes is easy then and converting them back to a surface representation.
2. Rendering only approach: keep track of all geometry and operation and render it using depth and stencil buffer tricks ( https://www.opengl.org/archives/resourc ... ode33.html )

And please let me know how far you get with supporting collada. If it's anywhere near complete let me know, this huge model file format is something I would never want to load by myself. I'd rather stick to gltf.

Re: 3D subtraction of parts ...

Posted: Mon Oct 28, 2024 12:56 pm
by benubi
You are not the only ones thinking about this subject, even though I have no project, just wishes. It would be awesome if creating dev tools could be easier achieved, or the integration of 3d party tools. I can't give any advice since my math skills are very low compared to what is required :/

I remember an age old post on this forum about cutting holes into a "3d surface", but it must be deprecated by now.

On my side of the question I'd also wish to generate a few "prefabs" programmatically (doors, walls, windows, corridors etc.), and make some tunnel/landscape things. You know that RT universe thing everybody does already :lol: I'd like to merge "tunnels" of arbitrary shapes into different arbitrary shapes; for example a room that has multiple "pipes" connected to it...

But I am afraid this won't just happen by itself for me, a "math illiterate" :cry:

Re: 3D subtraction of parts ...

Posted: Mon Oct 28, 2024 8:41 pm
by SMaag
But I am afraid this won't just happen by itself for me, a "math illiterate"
you do not have do design mathematics by yourselfe. The most is ready done. But most in other languages.

If you want to be part of the 3D development you can convert some algorithms to Purebasic.

What's missing is:
1. Ramer-Douglas-Peucker Poly-Line simplification. (with that it is possible to smooth shapes)
https://rosettacode.org/wiki/Ramer-Doug ... lification#
https://en.wikipedia.org/wiki/Ramer%E2% ... _algorithm

2. A Polygon to Triangle converter (Polygon Triangulation)
search a code and/or convert it to PB
That's needed to create a Mash from Polygon Shapes, like your walls, tunnels, doors ...

3. Try to prepare for PB use: the libCSG - A constructive "solid" geometry library
a) build the lib/dll for Windows, Linux, Mac
b) write the PB import file for the Lib

https://github.com/robonrrd/csg/tree/master

That's neede to combine 3D Elements to a single one, or cut holes into a 3D Element!

Re: 3D subtraction of parts ...

Posted: Thu Oct 31, 2024 6:13 pm
by threedslider
benubi wrote: Mon Oct 28, 2024 12:56 pm But I am afraid this won't just happen by itself for me, a "math illiterate" :cry:
Don't be by yourself in downside, instead educate yourself nothing is too late you will see it's so fun to do 3D and you will understand it why i encourage you by doing this math ;)

There's nothing mysterious about math, learn the rule and everything will be ok :mrgreen:

I am myself to learn still to math and it is very beautiful math i love so much too :D

Re: 3D subtraction of parts ...

Posted: Fri Nov 01, 2024 11:17 am
by SMaag
if anyone is interested in the Matric/Vector math of 3D operations.
I documented at lot of sources where you can look for further informations
and the most MATRICES for the basic operations including the mathematical operations in

https://github.com/Maagic7/PureBasicFra ... VECTORf.pb

like this crazy Matrix for an univeral rotation arround an axis:

Code: Select all

; Rotation arround an Axis - AxisUnitVector[x, y, z]
; whre sin and cos is the sin(angle) and cos(angle)
    
    ; | x²(1-cos)+cos       x*y(1-cos)-z*sin    x*z(1-cos)+y*sin     0 |
    ; | x*y(1-cos)+z*sin    y²(1-cos)+cos       y*z(1-cos)-x*sin     0 |  
    ; | x*z(1-cos)-y*sin    y*z(1-cos)+x*sin    z²(1-cos)+cos        0 |
    ; | 0                   0                   0                    1 |  


Re: 3D subtraction of parts ...

Posted: Sun Nov 03, 2024 11:23 am
by pjay
Hi Marc,
Do you have a snipper of that program, I can start with ?
I'm afraid I probably binned the floppy disk it was on about over 30 years ago :lol:

I wrote a similar function (to create a cylinder) about 15 years ago for an opengl based 3d modelling app; no matrix math was required, just sin() & cos().

I'll see if i can find the archive & post that particular function, although I'm not sure how useful it would be to you in isolation.