Geometry primitives and boolean operations

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
John38F
Gnoblar
Posts: 1
Joined: Fri Jan 10, 2025 4:17 pm

Geometry primitives and boolean operations

Post by John38F »

Dear All,

I'm considering migration from the old OpenCascade to OGRE 3D.
My need is 3D visualization of optical lenses.
Those components geometry is easily derived from boolean operations on basic primitive shapes : sphere, cylinder, plane,... (see picture).

I would have two questions :

  • Does OGRE include primitive shapes such as sphere, cylinder, plane ?
  • If yes, is it possible to perform boolean operations between those primitives to get my targeted result ??

Thank you for your help !!
With best regards,
John
Image

rpgplayerrobin
Orc Shaman
Posts: 710
Joined: Wed Mar 18, 2009 3:03 am
x 391

Re: Geometry primitives and boolean operations

Post by rpgplayerrobin »

I don't think Ogre can by itself perform boolean like that, as it is mainly a rendering engine.

But, can use SDF as a post processing effect in Ogre to perform 100% perfect (better than any mesh could ever create) shapes with boolean operations:
https://iquilezles.org/articles/distfunctions/

Using shadertoy, you can also easily check that it works with your specific needs as well, like this: https://www.shadertoy.com/view/lt3BW2
You can also remove its smoothness in real-time (and then the little arrow button to compile) by altering the "opSmoothUnion" function to this:

Code: Select all

float opSmoothUnion( float d1, float d2, float k )
{
    return min(d1,d2);
}

However, SDF are quite heavy on the GPU, so if your target machines are not that great, SDF is probably not the solution.

Here are also some other libraries you can use to perform boolean operations, which you could then possibly visualize as a mesh in Ogre afterwards:
https://opencsg.org/
https://www.cgal.org/

Also, maybe it can be done using Ogre Procedural using meshes? I am not sure though, but you can check it out: https://github.com/OGRECave/ogre-procedural