Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

Display distance of camera to an object
show user profile  robert

Is there a way to display the distance between a camera and the object it is seeing in 3ds max while it is being animated?

Let say you have a camera that is looking an a cube. And that distance is 12 inches.
Now if I move the object closer to the camera by 6 inches, is there a way to display the range live during animation? The animation would show a number on the view itself going from 12 inches to 6 inches slowly as the object gets closer to the camera. Like a live tape measure?


read 743 times
1/9/2015 6:11:18 AM (last edit: 1/9/2015 6:11:18 AM)
show user profile  mike_renouf
I think this could be done with maxscript, though I don't have the skills.

Cameras have a target distance, so you could capture this value and feed it into a text object. The text would need to be linked the the camera so that it remains in the same position in the render window.

After that I'm a bit lost...

read 726 times
1/9/2015 8:40:52 AM (last edit: 1/9/2015 8:40:52 AM)
show user profile  Nik Clark
To find the distance between two objects, select two objects and type the following into the listener

distance $[1] $[2]

Use the distance function to update the value of a text object's properties.

If I had time, I'd write the script, but this should be enough to go on for anybody with a smattering of maxscript.

It would be something like

textobject.text = (distance camera object)

I can't remember if the text object property can be animated. You might have to have it run as a pre-render script.

read 723 times
1/9/2015 10:04:54 AM (last edit: 1/9/2015 10:18:17 AM)
show user profile  reeves1984
I had a quick look Nik you're right, you can't animate the text, can't see it in graph view...

Is there no way to get any other stats in the viewport?

Pre-render script sounds like a good idea

Simon Reeves - VFX Artist & Blog
twitter <-- I work here

read 707 times
1/9/2015 10:39:10 AM (last edit: 1/9/2015 10:39:10 AM)
show user profile  Boing
Can you not slap in on in post?
read 704 times
1/9/2015 11:08:51 AM (last edit: 1/9/2015 11:08:51 AM)
show user profile  ccampbell
One simple way would be to use a maxscript change handler to monitor the distance between the 2 objects and output the result as necessary. Here I output the result to a text shape.

The text shape is linked and always facing the camera should it move about.

1) create objects
2) run maxscript
3) animate
4) render

Unable to display content. Adobe Flash is required.


Maxscript Change Handler Code

when transform $box changes do
dist = (distance $camera $box) as string
$text.text = dist


Good Luck!

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 679 times
1/10/2015 2:26:09 AM (last edit: 1/10/2015 2:30:07 AM)
show user profile  Boing
peoples knowledge of Max never ceases to depress me.....
read 662 times
1/10/2015 1:52:43 PM (last edit: 1/10/2015 1:52:43 PM)
#Maxforums IRC
Open chat window