Jump to content

Camera's ellipsoid from above missing


kurhlaa
 Share

Recommended Posts

I think our assumption about how the ellipsoid is positioned in the mesh might be incorrect.

See the discussion below, on how I think the ellipsoid is actually positioned  in the mesh

Also, as noted in that discussion, collision between two meshes is not between ellipsoid of one colliding with the ellipsoid of the other .
It is between ellipsoid of one colliding with the surface of the other.

 

Link to comment
Share on other sites

Wow, what a discussion THAT thread is/was!  Phew.  Yep, that throws a monkey wrench into everything we have going, here.

Thanks for that "lead", Sat-g!  Excellent new info.

Update:  My goofy showEllipsoid() and setEllipsoidPerBoundingBox() are going to need a re-think, that's for sure.

Link to comment
Share on other sites

@satguru, thanks! Useful info. So the ellipsoid by default isn't symmetrical to the object's center.

But this doesn't work for me:

camera.ellipsoid = new BABYLON.Vector3(1.5, 1.5, 1.5);
camera.ellipsoidOffset = new BABYLON.Vector3(0, 1.5, 0);
 
.. the ellipsoid's size above the camera is still 0 and big below it, like the offset is being ignored.
 
And just to clarify - in my case I use and move camera (which has no size) with it's ellipsoid (which size is (1.5, 1.5, 1.5)), so the minimal distance to the box must be identical from all the sides - it doesn't happen to me.
Link to comment
Share on other sites

In fact I think it is according to the size of the mesh. If the mesh is 4 units and the elipsoid is 1.5 units (3 units total) it (the camera) will go into of 0.5 in the mesh.

On the other hand with the offeset, there is indeed a problem, because if one shifts it from 0.5 to the top, it should correct the problem, (the camera also goes down 0.5 when the ellipsoid goes up.) I notice that the offset works on the mesh, but it is not taken into account by the collision system. In other words, the offset works, but the collision does not take it into account.

Conclusion, the bug is on the fact that the offet is not taken into account by the collision system, it correctly takes into account the initial elipsoid, but not after shift, even if the offset works correctly on the mesh .

What do you think about @Deltakosh?

Link to comment
Share on other sites

Thx Dad!  Good thinkin's. 

Meantime... Another test:  https://www.babylonjs-playground.com/#WWCK0#86  Basic barrels demo with .setEllipsoidPerBoundingBox() disabled.

Baby 'zoids'.  :)   "zoid" or "soid" are easier to type.  Shift-Q and 'E' tests are different, now.  No freezes, either, so E, Q, SHIFT-E and SHIFT-Q all work, even after collide.  hmm.

Those zoids "look" centered-on-mesh, by default.  I suppose we could add a wireframe zoid to the camera, eh?  Not for arc cams, though.  Only free cams have zoids.  Here is a barrels demo with a freeCam with 1.1, 1.1, 1.1 zoid radius... and we're looking-out thru the camera's zoid-sphere.  Interesting-looking - a little camera.minZ corner clipping.  Tweak camzoid size at line 63.

We can even look-at the freecam with its new ellipsoidMesh...  from a 2nd camera point-of-view.  Can we "sim" cursoring that freecam, now?  Then, we can watch it collide with junk, from arcCam view.  :)  Warning:  I parented that camzoid to the freecam (line 77), and that might be a mis-positioning, per the Satguru info.

Line 18 within my showEllipsoids() func... adjusts position for ellipsoidOffsets, in case anyone was curious about that.  I hope I'm doing that correctly.  I think showEllipsoids() is important for us.  But, it was coded by me, and that means mistakes are likely.  Anyway, moving-on...

Notice the constructor in line 10.

    var sphere = BABYLON.MeshBuilder.CreateSphere("elli", { 
        diameterX: this.ellipsoid.x * 2,
        diameterZ: this.ellipsoid.z * 2,
        diameterY: this.ellipsoid.y * 2
        },
    scene);

Ellipsoid values are radii.  I keep forgetting that, so I thought I would remind myself, and perhaps others. 

I love this type of studying, guys.  Thx for tolerating me, and my sometimes-slow comprehension.  We're still welcoming comments from everyone.

Link to comment
Share on other sites

I meant: a simple PG :)

Ok le'ts try this: https://www.babylonjs-playground.com/#X2LMYT

As you can see in the PG, I set the ellipsoid to 1 (let's only consider y azis so far). This is expected because the box is 2 in height. so it is contained in an ellipsoid with a radius of 1

But (and this is maybe something we need to change), by default, the ellipsoid is offset by its radius. so I need to set an ellipsoidOffset of 1 to compensate.

 

Here is my proposal: I remove the ellipsoid automatic offset (which was done because this was done initially for camera and you want to the view to be on the "head" of the camera).

Thoughts?

Link to comment
Share on other sites

1 hour ago, Deltakosh said:

by default, the ellipsoid is offset by its radius

I assume Y-offset by Y-radius.  :)  (duh, Wingy)

@Dad72, yep, your video is showing exactly what K and I saw... but I/we thought that was incorrect, until I/we learned more stuff.  :)  Sorry for confusion.  Thx for video!

Quote

Remove the auto offset on the meshes

Is that we/they want?  Or, should we/them still keep auto-offset, but set it to default 0,0,0 ?  *shrug*  Is that what was meant?  (I guess I can test and find out)  :)

Link to comment
Share on other sites

https://github.com/BabylonJS/Babylon.js/blob/master/src/Collisions/babylon.collider.ts#L191

embeddedInPlane.  hmm.  Makes ya wonder, eh?  Special processing for when ellipsoid is completely flat, perhaps?

Anyway, adjusted scene...

https://www.babylonjs-playground.com/#MJRGPB#6

Left plane facing forward, right plane reversed, and yep, I see some major differences between the two.

Let's ping our superhero again, huh?  @Deltakosh, we are already missing you.  Come tell us another bedtime story, ok?  ;)

Link to comment
Share on other sites

@Deltakosh Do you have a moment to address kurhlaa's last post.  (and mine, too).

We are seeing shallow collision on ONE side of planes, deep collision (or no collision) when plane is reversed.

https://www.babylonjs-playground.com/#MJRGPB#6

Left plane is forward, right plane is reversed.  Thx for any words/thoughts.

Advice/info from others... welcomed too, of course.  thx.

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