is result of setboundingbox permanent?

Started by MichaelJPCT, June 05, 2017, 07:31:54 AM

Previous topic - Next topic

MichaelJPCT

i want to enlarge a bound box as the shader for the object3d enlarges the object.
after i setboundingbox, is there anything in the engine that may reverse the bound box back to the smaller one?
i ask this question because another engine would recalculate the bound box automatically.

MichaelJPCT

i tried setboundingbox at runtime, after build(), but i didn't see any effect - the bound box was still small.

EgonOlsen

It's permanent until you call build() again. What do you mean by "I didn't see any effect"?

MichaelJPCT

my shader modifies vertex position so that the model look larger than the actual Mesh defined.
but the bound box is as large as the defined Mesh.
so if a small portion of the modified model should be visible but the defined Mesh is out of view, the model is not rendered.
so i want to enlarge the bound box to be the same as the modified model.
but it didn't work - the model is still not rendered if the defined Mesh is out of view.

EgonOlsen

Then you are doing something wrong. Make sure to set the bounding box after calling build() and that you neither call build() or calcBoundingBox() afterwards at any time.

MichaelJPCT

i am sure setboundingbox is called after build().
after i create the object3d, i call getMesh().compress() -> build() -> strip(), can these affect the result?

EgonOlsen

No, actually not. You can obtain the bounding box from the object. Just log the results while the app is running and see if that fits the values that you have set. If yes, then maybe your BB hasn't the size that it has to have. If no, something modifies the BB later in the process.

MichaelJPCT

how to obtain the BB? i don't see getBoundingBox() method.


MichaelJPCT

#9
i called setBoundingBox with larger values, then called getMesh().getBoundingBox(). i got the small , original values.
and i am sure my program doesn't change the BB after i call setBoundingBox.

EgonOlsen

That can't be!? Some code changes the bounding box afterwards, either explicit by calling build() or calcBoundingBox() or implicit by cloning the Object3D and letting jPCT-AE auto-build the cloned object or something like that. Keyframe animations will modify the BB as well.

But just to be sure: After setting the new bb...if you then call getBB immediately after, are you getting the correct results?

MichaelJPCT

i tried calling getBoundingBox immediately after setBoundingBox, the value i got was the small, original one, not the larger one i set.
but the javadoc says getBoundingBox triggers a recalculation, so getBoundingBox  should output the original value, right?

EgonOlsen

You are of course right...sorry, I forgot about that behaviour. Well, in that case, it's not an option to use that method. Anyway, your approach should work fine. I don't see, why it would fail unless your BB isn't reset or it's not big enough. Have you tried what happens if you set it to a very small one? Does that change anything?

MichaelJPCT

i tried, smaller value has no effect either.

EgonOlsen

Then something resets the box. Can you create a test case for this issue?