2
\$\begingroup\$

How do I go about moving a bounding box in libGDX?

I want to make the bounding box capture my character and move with him.

So ideally I want to be able to copy my vector 3 from my model instance and set it on the bounding box.

There doesn't seem to be any method like setToTranslation() on the BoundingBox class. How am I supposed to do it?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

From the documentation it looks like you have a few options.

  1. Use the set method to set the min and max bounds. So, you can move the box by moving both the min and max. Something like box.set(box.min + moveAmt, box.max + moveAmt);

  2. Use the mul to multiply the bounds by a matrix. Create a translation matrix to translate the bounds by your movement amount. Something like box.mul(new Matrix4(moveAmt, QuaternionIdentity, Vector3Ones).

\$\endgroup\$
2
  • \$\begingroup\$ Great! Its solved my problem. Could you also please explain to me what you think the minimum and maximum values are used for? Are they what represent the two opposite corners of the box? \$\endgroup\$
    – BeefCake
    Commented Sep 3, 2013 at 19:31
  • \$\begingroup\$ Correct. The min and max are the two corners of the box. Where the min contains the minimum X, the minimum Y and the minimum Z. And the max contains likewise for the maximums. With just those two points the entire cuboid can be defined in 3D space. \$\endgroup\$
    – House
    Commented Sep 3, 2013 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .