View Full Version : How can i query that value ...!!
Hazoof 12-05-2007, 08:14 PM how can i query the value of (distance from camera) which its output on this frame
without distance measurment tool...
http://img221.imageshack.us/img221/266/mydistancefromcamerazz2.jpg
|
|
Get the location of the current camera, get the location of the selected object and then do the calculation.
Like so:
proc float getDist()
{
string $currentPanel = `getPanel -wf`;
string $currentCamera = `modelPanel -q -cam $currentPanel`;
string $object[] = `ls -sl`;
float $distance;
if (!size($object))
error "Select Something";
float $camXforms[] = `xform -q -ws -t $currentCamera`;
float $objectXforms[] = `xform -q -ws -t $object[0]`;
float $dx = ($camXforms[0] - $objectXforms[0]);
float $dy = ($camXforms[1] - $objectXforms[1]);
float $dz = ($camXforms[2] - $objectXforms[2]);
$distance = sqrt(($dx*$dx) + ($dy*$dy) + ($dz*$dz));
return $distance;
}
getDist;
after looking at it a bit more, this will return a different value than what's listed in the HUD. However this will return the same value if you use the measure tools. I'm not sure how they calculate the HUD value.
CGTalk Moderation
12-05-2007, 08:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.