Jump to content

NULL ENGINE behaviour using setPivotPoint and CSG


Arte
 Share

Recommended Posts

If you are performing logic on the server side and passing only data such as position to the client you might run into errors because the way the pivot works, changing the pivot may not update the position. I would recommend using a parent object instead of the pivot, see first paragraph here https://doc.babylonjs.com/how_to/pivots and this PG: https://www.babylonjs-playground.com/#GH4N1R#1

Link to comment
Share on other sites

38 minutes ago, trevordev said:

If you are performing logic on the server side and passing only data such as position to the client you might run into errors because the way the pivot works, changing the pivot may not update the position. I would recommend using a parent object instead of the pivot, see first paragraph here https://doc.babylonjs.com/how_to/pivots and this PG: https://www.babylonjs-playground.com/#GH4N1R#1

That's exactly what's happening now. I like what you suggested, but. I think NullEngine should mach client side :huh:.

Link to comment
Share on other sites

My guess is they are the same in data. Like if you print out the positions, they should be the same if the logic was done in the exact same order in the client vs the server's null engine. If you have a repro where numbers printed out by null vs non-null engine are different please do share.

Link to comment
Share on other sites

1 hour ago, trevordev said:

My guess is they are the same in data. Like if you print out the positions, they should be the same if the logic was done in the exact same order in the client vs the server's null engine. If you have a repro where numbers printed out by null vs non-null engine are different please do share.

All numbers a same.

Link to comment
Share on other sites

100%

Same as in PlayGround

///////////////////////////////
// CODE FROM NULL ENGINE
var parent = BABYLON.MeshBuilder.CreateBox("Parent", {height: 3.2, width: 2.2, depth: 1.2,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
var mat = new BABYLON.StandardMaterial("material", scene);
mat.alpha = 0.3;
parent.material = mat;
 
var part = BABYLON.MeshBuilder.CreateBox("Part", {height: 3, width: 2, depth: 1,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
 
part.setPivotPoint(new BABYLON.Vector3(0,1,0));
part.position.x = 1;
// part.rotation.x = -1;
part.parent = parent;
 
var tool = BABYLON.MeshBuilder.CreateBox("Tool", {height: 1, width: 2, depth: 2,sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
tool.material = mat;
tool.setPivotPoint(new BABYLON.Vector3(5,-1,0));
tool.position.x = 1;
tool.rotation.x = -1;
// tool.parent = parent;
 
var partCSG = BABYLON.CSG.FromMesh(part);
var toolCSG = BABYLON.CSG.FromMesh(tool);
var newPartCSG = partCSG.subtract(toolCSG);
 
var newPart = newPartCSG.toMesh("csg", part.material, scene);
 
// tool.dispose();
part.dispose();
// CODE FROM NULL ENGINE
///////////////////////////////
Link to comment
Share on other sites

OK can you repro on a page with the NullEngine (using Babylon.max.js) I will try to debug it.

Also (I am traveling and I don't have too much free time this week), perhaps you could try to do a per mesh comparison between engine and NullEngine regarding properties like world matrix (is this matrix the same on all meshes between both engine)

 

Can you also try to force a mesh.computeWorldMatrix(true) on all meshes before doing csg?

Link to comment
Share on other sites

40 minutes ago, Deltakosh said:

OK can you repro on a page with the NullEngine (using Babylon.max.js) I will try to debug it.

Also (I am traveling and I don't have too much free time this week), perhaps you could try to do a per mesh comparison between engine and NullEngine regarding properties like world matrix (is this matrix the same on all meshes between both engine)

 

Can you also try to force a mesh.computeWorldMatrix(true) on all meshes before doing csg?

Okay

 

38 minutes ago, Deltakosh said:

Also how do you render on client side when using NullEngine? Are you sure your local renderer interpret the pivot like Babylon.js?

I'm creating everything on server side and passing data through assetsManager.addMeshTask. Does that make sense?

 

Thank you for your time. :)

Link to comment
Share on other sites

@Deltakosh 

Shared files:

index.html // create and download (serialised scene)

serializedScene.json // downloaded json file (serialised scene)

Loader.html // load serialised scene

https://github.com/Gal-Arte/BabylonTest/tree/master/NULL ENGINE using setPivotPoint and CSG

Playground to compare https://www.babylonjs-playground.com/#8PIKRZ#1

Lets hope for the best :)

Link to comment
Share on other sites

Can I ask you something else? Can you serialized the scene from a regular PG and reload it?

I'm pretty sure this comes from the serializer which does not take the pivot correctly in account

Link to comment
Share on other sites

@Deltakosh

I updated npm babylonjs "Babylon.js null engine (v3.3.0)" , but for some reason I have same results as before. On PG is working perfect. ?

***EDITED***

I tried what @trevordev suggested "I would recommend using a parent object instead of the pivot" 

Results: https://www.babylonjs-playground.com/#8PIKRZ#3

BABYLON.CSG ignoring not just pivot but parenting as well???

My bad. I forgot sphere.computeWorldMatrix(true);

https://www.babylonjs-playground.com/#8PIKRZ#4

 

But npm babylonjs still issue.

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