0
$\begingroup$

I have a mesh (Mesh-A) with a bounding box of some arbitrary size defined by X,Y,Z scale. In runtime I import another mesh (Mesh-B),which has an overall topology similar to the Mesh-A, but it can have a different default scale. I am looking for an efficient algorithm to rescale the Mesh-B to have the new scale equal to the Mesh-A,which basically means - their bounding boxes are of similar sizes. The naive approach would be to run for... loop, scaling the Mesh-B transform,till its BB has an approximate size equal to that of the Mesh-B's BB. I would like to learn other approaches.

$\endgroup$
1
  • $\begingroup$ Scaling by BB does not seem a very fruitful way to do anything. I mean a elephant does not have the same BB as a human. Ideally youd have some feature you can relate. $\endgroup$
    – joojaa
    Sep 11 at 13:34
3
$\begingroup$

Scaling is linear, so you can do this in one step rather than iteratively. If you have two vector values sizeA and sizeB for the sizes of the two meshes’ bounding boxes, the vector value you should scale mesh B by is sizeA / sizeB. If you want to scale it uniformly, you’ll need to pick a single scalar value; one way to do that would be to average the ratios of each component, i.e. (sizeA.x / sizeB.x + sizeA.y / sizeB.y + sizeA.z / sizeB.z) / 3.

$\endgroup$
1
  • $\begingroup$ Works like a charm! Thanks. $\endgroup$
    – Michael IV
    Sep 11 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.