Jump to content

Impostor bigger than the mesh after scaling


Dad72
 Share

Recommended Posts

Hi D72, how ya been?  I hope well. 

I can't get that PG to load... FF or IE.  Looks like security problem. 

Direct browse of http://www.babylon.actifgames.com/anim/walk.babylon works.

Many times I refreshed/reloaded,  +cleared cache... no success.  Ideas? 

FF console reports "failed to load [domain] walk.babylon". 

IE reports "Access Denied" but no URL reported.

Maybe only problem for me.  Anyone else having failed .babylon load-in on that URL?  (thx)

Link to comment
Share on other sites

Thx, Dad72, I am well.

Okay, so, problem is with bounding box size... after scaling, correct?

You could remove all physics, and problem can still be seen with ONLY showBoundingBox?

SO, boundingBox size problem, and perhaps NOT physics impostor size problem?

I think boundingBox size is based-upon first frame of animation.

https://www.babylonjs-playground.com/#1LNWLE#3

No matter what animation does, bounding box remains the same size/orientation. Impostor likely same.

So, perhaps physicsImpostor cannot change size or orientation... on each frame of animation.

In the picture, are we viewing first frame of character animation?  Or, later frame?


Adam once showed us how to set ANY boundingBox size.  https://www.babylonjs-playground.com/#BFM7EX  (line 26)

You COULD enlarge bounding box a small amount... before adding impostor.  *shrug*

When you change scale, then you could test character.getBoundingInfo().boundingBox.extendSize... check if it scaled proper amount.

I don't know if I am helpful.  Could be bug, too.  :)  Sorry if I am interrupting.  Wingnut thinking about issue.

Link to comment
Share on other sites

The thing is, I did not have this problem in previous development with the physic. The object falls back to the ground. But not anymore after resizing the object.

If I do not resize it, there is no problem, so I think there is a bug, it's not normal.

The boundingbox was to see the size of the object, but I can do without it, the problem is not there.

Link to comment
Share on other sites

@Wingnut  If I delete physics as you suggest, I do not see the bug, the object is on the ground. But as soon as I put the physics, the object goes up and floats when it is rescaled.

If I do not scale, it works fine, so I think there is a bug after rescaling. with Oimo and Cannon

I think it's because there are bones, a bone-free object, works even if it's resize.

5a4b889eb78c5_2018-01-0214_22_54-Greenshot.thumb.jpg.0b3f556e4063fd8d9537a18399482e67.jpg

Link to comment
Share on other sites

Interesting!  Thx for info/pic.  hmm.

https://github.com/BabylonJS/Babylon.js/blob/master/src/Physics/babylon.physicsImpostor.ts#L181

See that?  .setScalingUpdated(bool)

Possibly, impostors cannot scale, ever. 

So, forceUpdate() is needed... after any shape scaling... to install a NEW impostor... via calling init() in line 190.

Try it, if you please.  See what happens.  Maybe explosion, maybe solution.  :)

Link to comment
Share on other sites

Here using the Dube available on Babylon, the physics does not work at all, the dude falls through the ground.

I try the rabbit too, and the physics does not apply at all as if I do not add any.

As soon as there are bones, physics has problems.

I specify that in previous versions using the same model that I had it worked properly, so there is a bug that seems random from one model to another that contains bones

Here the Dude  falls through the ground.

http://www.babylonjs-playground.com/#GA8XI#91

Here my character floats in the air if he is put back on the scale :

http://www.babylonjs-playground.com/#GA8XI#89

Here the rabbit does not get any physics apply

https://www.babylonjs-playground.com/#1LNWLE#17

 

 

Link to comment
Share on other sites

The physics engine doesn't handle new scaling of objects. This is also written in the documentation - any physics engine (at least the ones we currently have) are based on rigid, unchanged bodies. Scaling changes the properties of the body, and requires a new impostor.

You did set the scaling-updated to be true, which should recalculate the impostor (and it does). I need to see why the box doesn't scale correctly.

Regarding the rabbit and the dude - if you checked what meshes[0] actually is, you would find out that both those models are built using many meshes, and that the first one is just a null-parent which has no vertex data. So, the dude won't work the way you wanted it to. you will need to set an impostor to each of the child meshes.

Link to comment
Share on other sites

Ok, thanks for the clarification Raanan. I did not know how the Dude and the rabbit were built. I do not use physics often, so I dont know very well how it works. I do not see anything in the documentation of the physics which speaks about the resizing (scale) after knowing reread the 3 available. 

thanks check why the impostor (bounding box) is not correct.

By cons what I do not understand, I already use this model with the physic and it worked after resizing (to version 2.5 it seems to me)

When I use a mesh without bones, even resize it works, but if there are bones, it does not work properly after resizing. Yet if I display the bones, it is correctly resize.

Link to comment
Share on other sites

So there might be an issue with bones and physics. I will see if I can make it work.

Note that bones are not supported in the physics engine. if a mesh is animated, it doesn't mean the impostor will change (it will stay the same size, and with the same transformation).

Link to comment
Share on other sites

Yes no worries, I use physics just to adjust my objects perfectly on the ground when I add them with my editor. Then I do not use physics anymore.

I know I can do it differently, but physics simplifies this step because even if I move my object with a gizmo, it stays on the ground with physics. But bone objects do not seem to work properly anymore.

Link to comment
Share on other sites

I just had the same problem at the moment with another object that has no bone.

This is a house that I already use before and that worked well even after being scaled up. But he now finds elevating like the character.

So it's not a question of bone. something to change since.

I have the impression that the pivot point is not properly modified after being rescaled.

Without rescaling we can see the pivot in the center of the object :

***

And with scaling back the pivot is no longer in the center :

***

Link to comment
Share on other sites

Yes, I use this function :

addMesh(root, file, type, scaling = 1.0, shadow = true)
	{
		BABYLON.SceneLoader.ImportMesh("", root, file, global.scene, (newMeshes, particleSystems, skeletons) => {
			let mesh = newMeshes[0];
			mesh.rotationQuaternion = null;
			if(type == "character" && skeletons[0]) {
				let skeleton = skeletons[0];
				mesh.updatePoseMatrix(BABYLON.Matrix.Identity());
			}
			mesh.layerMask = 3;
			if(shadow) this.addShadow(mesh);
			mesh.isPickable = true;
			mesh.metadata = {"type": type};
			mesh.scaling = new BABYLON.Vector3(parseFloat(scaling), parseFloat(scaling), parseFloat(scaling));
			mesh.position = global.editor.cameraUser.getFrontPosition(10);			
			mesh.physicsImpostor = new BABYLON.PhysicsImpostor(mesh, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 1.0, friction: 0, restitution: 0, nativeOptions: { collisionFilterGroup : 2, collisionFilterMask: 1 }}, global.scene);
			this.UI.windowClose();
		});
	}

I can send you the model by MP if you need it too.

Link to comment
Share on other sites

Without the physics on the house, the pivot point is shifted again after being scaled back.

Same thing for the character without the bones. On the other hand, on the character, the pivot point is always in the same place.

 

Link to comment
Share on other sites

What is strange is that even without the physics, the house have their pivot to move lower after the smaller resize. But without resizing its pivot is at the center of the object. (see the two pictures houses)

Maybe it's another problem besides physics where the object does not descend to the ground.

I know this model worked 1 year ago, but not anymore.

Link to comment
Share on other sites

I fixed the problem of the pivot, it was my fault, sorry. So I try again to re-export my object and load with physics, the object floats at the same height as the character.

The object has its pivot to replace its center, this problem is correct, but the object it does not fall to the ground.

Both objects float at the same height, I do not think this is a coincidence, my two object is exported with 3ds max. I think that all my export objects will have this object problem floating at the same height.

If I use primitives (box sphere ...) it works normally.

Would not it be a random inversion to what should be the top and the bottom, I'm looking for a track idea. But I have the impression that what is export blender will work but not 3ds max, but this is only a hypothesis.

I will try another object export with 3ds max.

PG wihtout bones: (use http if you do not see the object)

http://www.babylonjs-playground.com/#GA8XI#93

For the character I add a sphere parent to see where is its pivot point, it is also at his feet. But he also floats with physics.

PG with bones: (use http if you do not see the object)

http://www.babylonjs-playground.com/#GA8XI#94

It's not a question of bone, because I have a PG without the use of bone and another with the use of bone. The pivot point is ok, but the two object does not fall.

Link to comment
Share on other sites

I confirm that everything that is export with 3ds max, does not work with physics.

In this pg I made a simple primitive box with 3ds max, I export it and load and it also floats at the same height. (whatever the rescaling)

(use http for see object)

http://www.babylonjs-playground.com/#GA8XI#95

I add the object box made with 3ds max and export with also in a zip file attached

box3dsmax.rar

Link to comment
Share on other sites

@RaananW No, there is no problem with 3ds max, and the mistake is when I load the babylon scene with physics.

I made a mistake on the pivot that is correct, but the object does not fall to the ground on any object that I export with 3ds max (version 2017).

You can reopen the problem, but with a different title I think.

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