On 7/14/05, Byron Nash <Byron(at)snap5.tv> wrote:
> I think I have it all solved now. The script wasn't getting the value from the camera every frame. Also it was having problems dealing with objects in heirarchies. I worked around that by creating temp nulls and pos constraining them to the object. It's probably an ugly workaround but I'm not as strong with XSI scripting as AFX. In the process I made it a bit more user friendly on the AFX side. Check out http://www.aenhancers.com/viewtopic.php?t=237 for my detailed description and the link to download it.
>
> Martin's snippet of code has made it into several scripts now, I never would have figured that math out. How does the kine.Global.transform compare to a vector?
[g]use gettranslation() to get it
I'm sure there is a way to get around making the temp nulls but I
couldn't get my head around it.
>
> -----Original Message-----
> From: owner-xsi(at)Softimage.COM on behalf of Graham D Clark
> Sent: Thu 7/14/2005 2:52 PM
> To: XSI(at)Softimage.COM
> Cc:
> Subject: Re: [Scripting] vectors and world position
>
>
>
> looks like a Martin Talbot solution I ripped from him :)
> not sure of your hierarchy, but since you are using
> MapWorldPositionToObjectSpace perhaps instead gettranslation from
> kinematics.global.transform of the 'tracker' will help
>
> On 7/14/05, Byron Nash <Byron(at)snap5.tv> wrote:
> > I have found a bad problem with my 2D screen space script. When the camera is animating, it throws off everything. I was testing it with animated objects but not animating cameras. This code I'm using is borrowed from some other scripts so I don't have the best understanding of it. I don't get why the position is wrong if the script converts the 'tracking' vector to camera(object) space? Below is the snippet of code.
> >
> > set CamGlbTrans = incam.Kinematics.Global.Transform
> > Set v3Pos = XSIMath.CreateVector3
> > for i = frame1 to frame2
> > call v3Pos.Set( oObject.posx.value(i), oObject.posy.value(i), oObject.posz.value(i) )
> >
> > ' Convert vector world position to camera space
> > set NewVect = XSIMath.MapWorldPositionToObjectSpace (CamGlbTrans, v3Pos)
> > ' Convert vector camera space position to screen position
> > ImgRatio = tan ( CamFov/2 * pi/180 )
> > ImgPosX =-1*(NewVect.x / ( ImgRatio * NewVect.z))
> > ImgPosY = 1*( NewVect.y / ( ImgRatio * NewVect.z / CamAsp ))
> > 'camera positions are normalised -1 to 1 in x and y
> > xtemp=(round(((ImgPosX+1)/2)*xrenderres,0))
> > ytemp=round(((ImgPosY+1)/2)*yrenderres,0)
> >
> >
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> > unsubscribe xsi
> >
>
>
> --
> -------------------------------------------
> http://www.grahamdclark.com
> Hair|Fur & Character Finaling Supervisor, Omation
> TD|TA|FX|EDU
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
>
>
>
>
--
-------------------------------------------
http://www.grahamdclark.com
Hair|Fur & Character Finaling Supervisor, Omation
TD|TA|FX|EDU
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi