PDA

View Full Version : size values

ThunderSoul
06-06-2005, 03:27 PM
Hello, another question from me... ^_^
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.

t3jem
06-06-2005, 06:23 PM
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.

ThunderSoul
06-07-2005, 08:16 AM
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?

T101
06-07-2005, 09:28 AM

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.

ThunderSoul
06-07-2005, 09:39 AM
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.