I'm working on something with an animated camera; the camera can animate to any one of seven different locations, and I want to be able to animate directly to any of the other six positions. You cannot know ahead of time which of the seven locations the director will want to go.... I am writing an external application to run the scene directors to the location that gets called by the director.
The "animate to" paradigm would be where you could just set the last keyframe of the animation, and it would start the object where it currently exists in space. That doesn't work, and that's fine - there's a number of reason to not do it that way (not the least of which is you can't set the TCB).
My solution was to put a script event as the first frame of a scene director, the animation controller would follow 1 or two frames later. The script sets the first keyframe on the animation controller for camera object (actually using the setKeyframeValueTCB method).
I thought I had it working late last night (although I may have been delusional by that time), but today it seems like, even though the scene director time is outside of the animController (before) when the script is triggered, that the camera jumps to the first keyframe of that anim controller first, so that the script is ineffectual.
I could put the script at the end, and reset ALL the anim controllers first key frames to where the camera ends up. Since the whole system is "paused" by the end of the animation, even if it takes more than a frame to complete, it shouldn't cause any issues, but I think there must be a better way.
I was using a global method to try to simplify the individual SceneDirector events:
Sub setFirstKeyFrame(byref AnimControllerName as String, byref Scene as XpScene)
'
' Sets the first keyframe of the animation to the current
' camera position.
'
dim anim as XpAnimController
dim camera as XpBaseObject
dim px, py, pz, rx, ry, rz as Double
if Scene.getObjectByName("Camera", camera) then
if Scene.getAnimControllerByName(AnimControllerName, anim) then
camera.getPosXYZ(px, py, pz)
camera.getRotXYZ(rx, ry, rz)
anim.setKeyFrameValueTCB(camera, 0, "Position.X", px, 1.0, 0.0, 0.0)
anim.setKeyFrameValueTCB(camera, 0, "Position.Y", py, 1.0, 0.0, 0.0)
anim.setKeyFrameValueTCB(camera, 0, "Position.Z", pz, 1.0, 0.0, 0.0)
anim.setKeyFrameValueTCB(camera, 0, "Rotation.X", rx, 1.0, 0.0, 0.0)
anim.setKeyFrameValueTCB(camera, 0, "Rotation.Y", ry, 1.0, 0.0, 0.0)
end if
end if
End Sub
Then the event script would just be:
setFirstKeyFrame("NameOfController", scene)