Getting the pixel dimensions of an object

Hi everyone,

Now I know the title doesn't make a great deal of sense - I'm aware that when you work in 3D, the pixel size of an object is largely unrelated.

However, I am working on a project where I need to swap two 3D objects with each other, whilst maintaining their "screen size". For example, if I had an object 10 metres away from the camera) and an object 30 metres away from the camera and I swapped these two objects, I would want the objects to maintain their original screen size.

I have some constants in this scenario: The camera position, camera orientation, camera FOV and object positions.

I have broken this down in to three steps that I can think of:

1. Calculate the on-screen bounding box for each object. (This is where I need help)
2. Pick two objects at random.
3. Scale the pair of objects based on the bounding box properties of each other. I am going to calculate the percentage difference between the two objects' on-screen bounding box and use this to scale them appropriately in 3D space.

Is this possible in MaxScript?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

Attached is the script, created by Enrico Gulloti. I can't find it in the net, so download it and use it to write your won script. The script works only with Editable Mesh and Editable Poly objects.

AttachmentSize
ic_sizeinscreen_0_2.zip 3.14 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.