plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.


Please take a moment to read the platform’s guidelines before you get started!


question

virtuali avatar image
virtuali asked FlyingRaccoon commented

Bounding Box for Skinned/animated objects issue

There might be a problem with the simulator culling using the objects bounding box.

If an object moves away its position from its original bounding box due to vertex skinning ( for example, a character walking around an area, not "in place" ), the culling still acts on the position of the bounding box, so (depending on the viewing angle) it assumes the object is outside the screen and culls it, when in fact the object should still be visible.

This it's very easy to troubleshoot, by placing the object with the Scenery Editor, that shows the bounding box, and the object being culled away as soon the bounding box crosses the screen boundary due to the camera angle. But the object is not really there anymore, since it exited from its original bounding box because of the skinned animation.

I tried adding dummy geometry ( flipped triangles ) to enlarge the bounding box but, this seems to affect the LOD radius "Sphere" ( as seen in the LOD debugger ), but doesn't fix the problem with the Skinned object. I tried adding the extra triangles both as separate objects and as attach to the skinned mesh ( under the Skin modifier ), but the object still get culled.

A similar object, which is moved due to its parent node being animated but is NOT skinned, is not culled in the same way.

Is there any way to fix this ? Would be possible to tweak the bounding box, perhaps with an exporter option, so we could override the automatic bounding box calculation, and provide it with a bigger one, that covers the whole area in which the skinned animation takes place ?

modelinganimation
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

rhumbaflappy avatar image
rhumbaflappy answered rhumbaflappy edited

Could you just add an invisible cube around the extent of the animation in the model? This would give it a huge bounding area.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

virtuali avatar image
virtuali answered virtuali edited

@rhumbaflappy, as I posted, I already tried that, in two different ways:

- with small triangles placed around the animation extent as separate objects. Didn't work, even if the LOD radius sphere clearly increased.

- with the same small triangles, this time as part of the skinned mesh itself, making the skinned object bigger. Didn't work as well.

The problem is not just a generic culling issue, it seems that skinned objects are handled differently because, in the same object, I have another item that moves together with the skinned character, but it's not moving "because it's skinned", it's really moving its center, and this item is not culled.

I think this is somewhat related to the fact the .GLTF format doesn't have an overall bounding box stored in the file ( like the .MDL format ), but rather each part has its own extension values so, it's likely up to the app that loads the file to calculate the overall bounding box, and cleary a skinned mesh that moves outside the boundaries would confuse it, because the only way to know the real bounding box in that case, would be scanning the skinned animation and figuring it out what the real extents would be.

This is tricky, that's why maybe a way to override the bounding box in another way ( maybe in the object XML file ? ) might be useful.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Simbol avatar image
Simbol answered

@virtuali, Umberto I have the same issue with a project I am working with, the object transform from small to large.. so the bounding box being calculated at the smaller size causes issues.

You will need to add a cube as suggested by rhumba, however the caveat is, it needs to be done to all LODs.. the bounding box is currently calculated based on the last LODs loaded.. so if you add this cube only to your LOD0, since LOD5 is loaded last.. the bounding box will remain small.

If you add the cube to all LODs.. the bounding box will be calculated properly.

Hope this helps.

S.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

virtuali avatar image
virtuali answered virtuali commented

@Simbol,

Please read my message carefully, I'm perfectly aware we can place extra geometry to artificially enlarge an object bounding box AND we should do it for all LODs, this usually works, but it's not the issue here.

The issue here is a DIFFERENCE due to the fact my object is made of just two meshes, both animated, but ONE is Skinned, the other one it's not. And it's ONLY the Skinned mesh that gets culled, even if it's part of the same gltf and the same LOD ( I only have 1 LOD, btw ) and their animation covers exactly the same area. The only difference between them is the static mesh moves because its animated itself, while the Skinned object moves because its *Bones* are controlling it.

I even tried to add those extra polygons ( covering the whole animation area ) directly attached to the Skinned Mesh, effectively making the skinned mesh itself larger, but it still gets culled as soon the screen crosses the bounding box, but the skinned object is not there anymore, so it shouldn't be culled.

I wouldn't expect the sim to be able to deal automatically with these fringe cases, that's why having the ability to set some kind of parameter in the object XML, to override the automatic calculation of the bounding box, could be useful.

Or, if anybody found a workaround that would work for SKINNED meshes, I would be happy to hear it.

2 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Adding degenerate geometry that covers, at frame 0, the whole animation area is supposed to work. Not sure what happens in your case.

Could you provide us with a 3ds max file of the object producing this issue so we can investigate further?

Regards,
Sylvain

0 Likes 0 ·
virtuali avatar image virtuali FlyingRaccoon ♦♦ ·

@FlyingRaccoon, I replied with a private message with a sample 3ds max file you can try, but I'm not sure if I set the visibility permissions correctly, let me know if you have it.

0 Likes 0 ·
FlyingRaccoon avatar image
FlyingRaccoon answered virtuali commented

@virtuali I checked your sample and it makes sense it's not working.

- You tried to extend the skinned object bounding sphere by adding an independent "Plane001" object. That won't help, it will just create an independent object with a dedicated bounding sphere.
What you want to do is add geometry to the skinned mesh directly.

- In this particular case, there's a better alternative. Your skinned animation shouldn't move the character and you would have to use the root node to move him around so that the bounding sphere moves with him. (That's why the kart doesn't disappear, you're moving the node so the bounding sphere is following)

Does that make sense to you?

Regards,
Sylvain

1 comment
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

@FlyingRaccon, as I posted before, I already tried adding the extra geometry directly to the skinned mesh, but the result was the same.

I suspected the problem was caused by the fact the skinned animation is translating the object too, so I hope there was another solution, rather than having to redo the animation to remove any translation component and add it back to a dummy. This would require lots of work to redo many existing animations.

None of this would be an issue, if there was a way to override the bounding box, maybe as a parameter in the object XML.

0 Likes 0 ·
virtuali avatar image
virtuali answered FlyingRaccoon commented

UPDATE


I finally found a workable solution:


When I just added the dummy geometry to the actual skinned mesh, it didn't work very well, the skinned object was still getting culled from some angles.

What seemed to work, was adding the dummy geometry AND remove all the bones influences from their vertexes, so instead of wobbling/moving around with the skinned mesh, they just stayed in place to create the larger bounding box.

This resulted in good visual culling.

1 comment
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

That's surprising. At frame 0, the dummy geometry was correctly positioned to cover the animation area?

Allowing people to define the bounding sphere is something we think about. :)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.