Distance Between Two Objects (Automate Camera's Focal Point)

I would like a way to find the distance between two objects. What is the best way to go about doing this through maxscript?
Using the measuring tool, getting the distance value between the two objects and then deleting it?

Thoughts.

Thanks.

Comments

Comment viewing options

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

Help

Maybe you could help me on this. It doesn't work entirely correctly but I feel that it is going in the right direction. It is for animating the Camera's Focal point. It seems to bug out when obj is not directly in front of the camera.

rollout rlCameraFocus "Camera Focus"
(
	local FocusObj
	local RendCam
 
	fn ObjFilter obj = 
	(
		superclassof obj != Camera --Helpers
	)
 
	fn camFilter obj = 
	(
		superclassof obj == Camera --Cameras
	)
 
	groupbox gobxFocusObj "Focus Object" width:140 height:52 pos:[5,2]
	pickbutton pkbtnFocusObj "Pick Object" width:120 height:24 pos:[15,20] filter:ObjFilter
 
	groupbox gobxCamera "Camera" width:140 height:52 pos:[5,60]
	pickbutton pkbtnCamera "Pick Camera" width:120 height:24 pos:[15,80] filter:camFilter
 
	button btnMakeInFocus "Make In Focus" width:140 height:24 pos:[5,120]
 
	on pkbtnCamera picked obj do
	(
		RendCam = obj
		pkbtnCamera.text = RendCam.name
	)
 
	on pkbtnFocusObj picked obj do
	(
		FocusObj = obj
		pkbtnFocusObj.text = FocusObj.name
	)
 
-- Calculation
	on btnMakeInFocus pressed do
	(
		fromHere = RendCam
		toThere = FocusObj
		FocVal = (distance fromHere toThere)
		print FocVal
		RendCam.baseObject.targetDistance = FocVal
	)
 
)
createDialog rlCameraFocus 150 150

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

br0t's picture

"distance"

Theres an existing command:

fromHere = $Teapot001
toThere = $Teapot002
 
distance fromHere toThere

Cheers

Never get low & slow & out of ideas

Comment viewing options

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