Author Topic: is result of setboundingbox permanent?  (Read 458 times)

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
is result of setboundingbox permanent?
« on: June 05, 2017, 07:31:54 am »
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.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #1 on: June 06, 2017, 06:55:12 am »
i tried setboundingbox at runtime, after build(), but i didn't see any effect - the bound box was still small.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #2 on: June 06, 2017, 07:40:57 am »
It's permanent until you call build() again. What do you mean by "I didn't see any effect"?

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #3 on: June 06, 2017, 08:57:58 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #4 on: June 06, 2017, 12:14:02 pm »
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.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #5 on: June 07, 2017, 09:20:31 am »
i am sure setboundingbox is called after build().
after i create the object3d, i call getMesh().compress() -> build() -> strip(), can these affect the result?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #6 on: June 08, 2017, 07:51:56 am »
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.

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #7 on: June 08, 2017, 08:52:41 am »
how to obtain the BB? i don't see getBoundingBox() method.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #9 on: June 09, 2017, 11:15:46 am »
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.
« Last Edit: June 09, 2017, 11:19:38 am by MichaelJPCT »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #10 on: June 09, 2017, 02:18:39 pm »
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?

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #11 on: June 09, 2017, 04:54:28 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #12 on: June 10, 2017, 05:00:55 pm »
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?

Offline MichaelJPCT

  • long
  • ***
  • Posts: 140
    • View Profile
Re: is result of setboundingbox permanent?
« Reply #13 on: June 11, 2017, 06:56:29 am »
i tried, smaller value has no effect either.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: is result of setboundingbox permanent?
« Reply #14 on: June 12, 2017, 09:27:16 am »
Then something resets the box. Can you create a test case for this issue?