Hello,
I would like to make a camera that behaves in a particular way. The entity
that the camera tracks to, call it A.
When A moves along the local z axis of the camera (in and out of view), the
camera moves also along that local z axis too.
Any other movement of A, the camera rotates to face (tracks to).
Unfortunately when I combine both of these transforms in my code, it seems to
work a little then suddenly start getting nan in the below value 'diff'
(GetO2T() is turning it into nan, nan, nan). Any ideas what I am doing wrong?
# get the transform that describes the camera
camtrans = self.camera.GetTransform()
# calculate the difference along the cameras local z axis
# to the tracked object
campos = camtrans.GetOrigin()
objpos = trackedobject.GetPosition()
diff = camtrans.GetO2T() * (objpos - campos)
# now calculate the new position of the camera to be within
# a range of 5
newpos = csVector3(campos) + csVector3(0,0,diff.z - 5)
# @@@
# these transforms only work independently, not together
# @@@
camtrans.SetOrigin(csVector3(campos) + csVector3(0,0,diff.z -
5))
camtrans.LookAt(playpos - campos, csVector3(0,1,0))
self.camera.SetTransform(camtrans)
Thank you for your time.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]