size values

Hello, another question from me… :slight_smile:
Assuming I can draw a certain object (like a car) after reading a file, how do I find its x,y,z length? I need to scale it down so that it’s max volume is 8 units.
Thanks in advance. :slight_smile:

Well I could guess there are 2 ways.

  1. You can set the x,y,z lengths in the file
    or
  2. You can you a for loop to test all the points and find the ones that are farthest apart on the x, y, z axises.

Thank you for the reply.
What would happen if the object’s centre is not the origin, like it has been translated. Looking through all the vertices and finding the farthest ones is a complex task for complex objects… Is there another way?

What’s your goal?

If you’re only trying to show the full model at a certain scale, you can just take the minimum/maximum values, and get the width, height and length by subtracting min from max.
And you can also use that information to reposition the center.
It’s pretty hopeless trying to correct for a rotation though.

But if you’re trying to get a whole bunch of cars into one scene and they’re all at different scales, forcing them all to the same size will not be a good idea.

What I did a couple of years ago for a UT Mod, was this (UT allows setting the scale in-game, you could use glScale or scale the vertex coordinates):

  1. Determine a desired scale factor. X units in-game equals Y meters (or feet, whatever rocks your boat).
  2. Get a known size of the vehicle, measure the size in units at scale 1.0, then calulate the correct scale factor.
  3. Finetune the scale factor by placing a reference (human) model next to it - since the model may not be perfectly to scale.
  4. Keep the calculated scale factor in a spreadsheet. If you get a new version you need to recalculate (usually the shape has changed).

And I don’t think there’s a better way to deal with it. You can perhaps get the artist to do it for you.

Hello again…
T101, my goal is pretty much your poits 1 & 2. For example, if the input is a certain object of, say volume 300, I want to scale it down so that its volume is less then or equal to 8, and also find its centre.
Thank you for your reply :slight_smile:

To find the center just average the farthest points apart on the x,y, and z axises, I’m pretty sure this will work with rotation, though I’m not sure how to figure out length, width, and hight after it’s been rotated.

I shall try this tomorrow… it’s my last chance :stuck_out_tongue: