Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- load the xml into memory
- delete out any garbage if possible
- array the keyframe numbers
- array the cam position
- array the cam target
- */
- --get the data from xml
- xml = (dotnetClass "System.IO.File").ReadAllLines @"Z:\Projects\lucas\xmlCameraImport\test.xml"
- --find the frame number. 1,2,3
- motionCameraFrames = #()
- for i in xml do
- (
- if ((matchPattern i pattern:"*Keyframe order=*") == true) do
- (
- tmpArr = (filterString i " ")
- for n in tmpArr do
- (
- if matchPattern n pattern:"*order=*" do
- (
- tmpFrameArr = (filterString n "\"")
- append motionCameraFrames (execute(tmpFrameArr[2]))
- )
- )
- )
- )
- "Here are the frames:"
- motionCameraFrames
- -- find the camera position. [0,0,0]...
- motionCameraPostion = #()
- (
- camPosXArr = #()
- camPosYArr = #()
- camPosZArr = #()
- for i in xml do
- (
- if ((matchPattern i pattern:"*Position x=*") == true) do
- (
- tmpArr = (filterString i " ")
- for n in tmpArr do
- (
- if matchPattern n pattern:"*x=*" then
- (
- tmpXArr = (filterString n "\"")
- append camPosXArr tmpXArr[2]
- ) else
- (
- if matchPattern n pattern:"*y=*" then
- (
- tmpYArr = (filterString n "\"")
- append camPosYArr tmpYArr[2]
- ) else
- (
- if matchPattern n pattern:"*z=*" do
- (
- tmpZArr = (filterString n "\"")
- append camPosZArr tmpZArr[2]
- )
- )
- )
- )
- )
- )
- for i = 1 to camPosXArr.count do
- (
- append motionCameraPostion [(execute(camPosXArr[i])),(-1*(execute(camPosZArr[i]))),(execute(camPosYArr[i]))] --uh oh [x,y,z]? [x,-z,y]?
- )
- )
- "Here are the positions:"
- motionCameraPostion
- -- find the camera target position
- motionCameraTargetPosition = #()
- (
- camTargPosXArr = #()
- camTargPosYArr = #()
- camTargPosZArr = #()
- for i in xml do
- (
- if ((matchPattern i pattern:"*LookAt x=*") == true) do
- (
- tmpArr = (filterString i " ")
- for n in tmpArr do
- (
- if matchPattern n pattern:"*x=*" then
- (
- tmpXArr = (filterString n "\"")
- append camTargPosXArr tmpXArr[2]
- ) else
- (
- if matchPattern n pattern:"*y=*" then
- (
- tmpYArr = (filterString n "\"")
- append camTargPosYArr tmpYArr[2]
- ) else
- (
- if matchPattern n pattern:"*z=*" do
- (
- tmpZArr = (filterString n "\"")
- append camTargPosZArr tmpZArr[2]
- )
- )
- )
- )
- )
- )
- for i = 1 to camTargPosXArr.count do
- (
- append motionCameraTargetPosition [(execute(camTargPosXArr[i])),(-1 * (execute(camTargPosZArr[i]))),(execute(camTargPosYArr[i]))] --uh oh [x,y,z]? [x,-z,y]?
- )
- )
- "Here are the target positions"
- motionCameraTargetPosion
- --make and animate a camera
- /*
- the shot is 210 and is 5250 frames
- 210sec * 25f = 5250f
- */
- animationRange = (interval 0 5250)
- delete cameras
- sliderTime = 0f
- animatedCamera = Physical targeted:on name:"AnimatedCamera.Target" pos:[0,0,10] wirecolor:yellow
- animatedCamera.targeted = on
- animatedCamera.target.wirecolor = yellow
- animatedCamera.target.pos = [0,0,0]
- for i = 1 to motionCameraFrames.count do with animate on
- (
- animatedCamera.position = motionCameraPostion[i]
- animatedCamera.target.position = (motionCameraPostion[i] + motionCameraTargetPosition[i])
- sliderTime += 525 --(add 10 seconds)
- )
Add Comment
Please, Sign In to add comment