Boolean Operations in Newton 3xx ?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Boolean Operations in Newton 3xx ?

Postby Marc » Tue Jul 03, 2012 7:06 am

Hi !

I just saw commits in svn about simpleboolean and investigated. It looks like there are Boolean Operations implemented in Newton 3xx? So I checked out the current svn compiled it and tried the sandbox-application and the simpleboolean. According to the code and what I saw in the application, cubes are merged and subtracted to form new shapes afterrwards used by newton. Very nice. :)

Ok, I then tried to change the box with a sphere in the code, and the result was this:

Image

It looks wrong and the physics are off as well, those things move around very slowly on the ground and suddenly start jumping and things like that. Besides that, it took about 20s to build the objects.

Is this to be fixed or is there some intended limitation of simple booleans I ignored? Maybe simple booleans are only supposed to work with boxes?

According to MakeBox I created a MakeSphere function:
Code: Select all
static NewtonMesh* MakeSphere (DemoEntityManager* const scene, const dFloat& radius, const char* const texture)
{
   NewtonWorld* const world = scene->GetNewton();

   // create a mesh from a collision object
   NewtonCollision* const sphere = NewtonCreateSphere(world, radius, 0, NULL);
   NewtonMesh* const sphereMesh = NewtonMeshCreateFromCollision(sphere);

   int texID = LoadTexture(texture);
   NewtonMeshApplyBoxMapping(sphereMesh, texID, texID, texID);

   // delete auxiliary collision shape
   NewtonDestroyCollision(sphere);

   return sphereMesh;
}

and in MakeCruz I replaced the 3rd call to MakeBox with my MakeSphere call
Code: Select all
   //NewtonMesh* const boxMesh2 = MakeBox (scene, size2, texture);
   NewtonMesh* const boxMesh2 = MakeSphere (scene, width, texture);
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Boolean Operations in Newton 3xx ?

Postby Julio Jerez » Tue Jul 03, 2012 7:40 am

oh that is not a bug, I saw that as well an dit took me a while to figure it out.
the problem is that the objects are place usin ray cast, and if you place shot a ray over a body thay has a hole, of it teh ray fail it will report teh wrong high an dteh tow bodie will spawn in very deep penetration.
I will solve that by reap[lacin teh ray cast for object placement with convex cast, an dthey it will be all fine.


and for the secund boolean are suppoty to work on any mesh that can be represendt by a manifold. taht a very long range of meshes, teh NetwonMesh is a data structute to represent them.
but the boolean code is still under debugging, this is why the demo are using boxes
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Boolean Operations in Newton 3xx ?

Postby Marc » Tue Jul 03, 2012 10:05 am

I see. I just wanted to note that the strange physical behaviour only happens which those spheres included in the boolean operations. I guess because of the crippled generated meshes, the physics just do strange things. When I use the original boxes-only version, the physics look correct :)

Has NewtonMesh some special properties like it ahs to be watertight or is a NewtonMesh a triangle soup? Because for the later, I'm not sure how to define boolean operations on those.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Boolean Operations in Newton 3xx ?

Postby Julio Jerez » Tue Jul 03, 2012 11:41 am

yes I know like I said it teh phsics look wrong becaus ethe ray cast pass trough the empti space o fteh boolean diff, do no worrire about that for now. It will no happen afte I fix the last bug

for teh secund question, the NewtonMesh is a maniforld mesh yes. teh mean that face that shred an edge are conected.
howere teh enewton mesh also upport arbitart poligin soups, and teh bullen will also work on open mesh.

the boolean will work on all kind o mesh open close, maniford or non manifold, but for now To get teh algortim going a perfectly debuge I am testing is with just watertight meshes, since this is what I need to complete the destruction feature.

some time next week I will check in the part that handle open meshes.
basically with that tool you will be able to make a very powerful solid modeler similar to all quakes, Valve worldhammer, or Unreal, with the the different that this will be totally general, brushe can be anythong you want, even a single face face
The bollean has also the property that is local, which mesh it can be use at interative time in an editor
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Boolean Operations in Newton 3xx ?

Postby Marc » Tue Jul 03, 2012 12:23 pm

Ok that sounds awesome.

Out of curiosity:

Image

What would be blue - red? Just blue? blue with an the additional green edge leaning into blue?
What would be blue + red? Just the two triangles or the two triangles divided into smaler ones to have the green edge there somehow?

In general, I thought to do boolean operations, you need to have a concept of inside and outside. If you have a triangle soup, that concept get lost. Is it enough in the polygon soup case to use the direction of the normal to decide if something is inside or outside?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Boolean Operations in Newton 3xx ?

Postby Julio Jerez » Tue Jul 03, 2012 12:51 pm

In that case the answer is a NULL mesh beacause two flat surfaces can only intersect on a straight line.

That hoaever is a very trivial case, The more general case if that two triangle ar apart of a curve surface that are was aproximnet by a mesh.
The critiria for a boolean is that the intesection of two suface form are closed curved line. This is a theorem than can be proven.

so ift the above theorem is correct then a boollean operator on susraces is quite simple, all you have to do is as followe these steps.

-interset suface A with surface B
-in surface A, seperate all close loops by coloring all edges inside of every loop Black, and all other edges red
-do the same for surface B
-Merge edges in one side of surafeA with edges in one side of surface B

ex: a union is the mesh formed by all black edges in A an all black edges of B
a difference is the mesh formed by all black edges in A an all red edges of B
an so on

of course this is a lot eassy to say than done it. the algorithm is full of round error and special cases.

in your case say that on tringle is a floor, an dteh othe is say a curve suface in the form of a dem.
you can carve the dem or part of teh dem on the triangle, if the inestion forc a loop loop.


the you can cut open the mesh, for make the union.

cutting open meshes is a functionlity that will be use later to make the Trim Nurb feature for full cuve surfaces. yes that is righ will will also support curve sufaces.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Boolean Operations in Newton 3xx ?

Postby Marc » Wed Jul 04, 2012 6:09 am

Hmm. Sounds reasonable. So far I only knew about the BSP-Tree approach for doing booleans. Your approach is mightier. Really cool. I'm looking forward to see this implemented bug free. :)
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron