Lucas_3D

Untitled

Feb 15th, 2022 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. /*
  2. load the xml into memory
  3. delete out any garbage if possible
  4. array the keyframe numbers
  5. array the cam position
  6. array the cam target
  7. */
  8. --get the data from xml
  9. xml = (dotnetClass "System.IO.File").ReadAllLines @"Z:\Projects\lucas\xmlCameraImport\test.xml"
  10.  
  11. --find the frame number. 1,2,3
  12. motionCameraFrames = #()
  13. for i in xml do
  14. (
  15. if ((matchPattern i pattern:"*Keyframe order=*") == true) do
  16. (
  17. tmpArr = (filterString i " ")
  18. for n in tmpArr do
  19. (
  20. if matchPattern n pattern:"*order=*" do
  21. (
  22. tmpFrameArr = (filterString n "\"")
  23. append motionCameraFrames (execute(tmpFrameArr[2]))
  24. )
  25. )
  26. )
  27. )
  28. "Here are the frames:"
  29. motionCameraFrames
  30.  
  31. -- find the camera position. [0,0,0]...
  32. motionCameraPostion = #()
  33. (
  34. camPosXArr = #()
  35. camPosYArr = #()
  36. camPosZArr = #()
  37. for i in xml do
  38. (
  39. if ((matchPattern i pattern:"*Position x=*") == true) do
  40. (
  41. tmpArr = (filterString i " ")
  42. for n in tmpArr do
  43. (
  44. if matchPattern n pattern:"*x=*" then
  45. (
  46. tmpXArr = (filterString n "\"")
  47. append camPosXArr tmpXArr[2]
  48. ) else
  49. (
  50. if matchPattern n pattern:"*y=*" then
  51. (
  52. tmpYArr = (filterString n "\"")
  53. append camPosYArr tmpYArr[2]
  54. ) else
  55. (
  56. if matchPattern n pattern:"*z=*" do
  57. (
  58. tmpZArr = (filterString n "\"")
  59. append camPosZArr tmpZArr[2]
  60. )
  61. )
  62. )
  63. )
  64. )
  65. )
  66. for i = 1 to camPosXArr.count do
  67. (
  68. append motionCameraPostion [(execute(camPosXArr[i])),(-1*(execute(camPosZArr[i]))),(execute(camPosYArr[i]))] --uh oh [x,y,z]? [x,-z,y]?
  69. )
  70. )
  71. "Here are the positions:"
  72. motionCameraPostion
  73.  
  74. -- find the camera target position
  75. motionCameraTargetPosition = #()
  76. (
  77. camTargPosXArr = #()
  78. camTargPosYArr = #()
  79. camTargPosZArr = #()
  80. for i in xml do
  81. (
  82. if ((matchPattern i pattern:"*LookAt x=*") == true) do
  83. (
  84. tmpArr = (filterString i " ")
  85. for n in tmpArr do
  86. (
  87. if matchPattern n pattern:"*x=*" then
  88. (
  89. tmpXArr = (filterString n "\"")
  90. append camTargPosXArr tmpXArr[2]
  91. ) else
  92. (
  93. if matchPattern n pattern:"*y=*" then
  94. (
  95. tmpYArr = (filterString n "\"")
  96. append camTargPosYArr tmpYArr[2]
  97. ) else
  98. (
  99. if matchPattern n pattern:"*z=*" do
  100. (
  101. tmpZArr = (filterString n "\"")
  102. append camTargPosZArr tmpZArr[2]
  103. )
  104. )
  105. )
  106. )
  107. )
  108. )
  109. for i = 1 to camTargPosXArr.count do
  110. (
  111. append motionCameraTargetPosition [(execute(camTargPosXArr[i])),(-1 * (execute(camTargPosZArr[i]))),(execute(camTargPosYArr[i]))] --uh oh [x,y,z]? [x,-z,y]?
  112. )
  113. )
  114. "Here are the target positions"
  115. motionCameraTargetPosion
  116.  
  117. --make and animate a camera
  118. /*
  119. the shot is 210 and is 5250 frames
  120. 210sec * 25f = 5250f
  121. */
  122. animationRange = (interval 0 5250)
  123. delete cameras
  124. sliderTime = 0f
  125. animatedCamera = Physical targeted:on name:"AnimatedCamera.Target" pos:[0,0,10] wirecolor:yellow
  126. animatedCamera.targeted = on
  127. animatedCamera.target.wirecolor = yellow
  128. animatedCamera.target.pos = [0,0,0]
  129.  
  130. for i = 1 to motionCameraFrames.count do with animate on
  131. (
  132. animatedCamera.position = motionCameraPostion[i]
  133. animatedCamera.target.position = (motionCameraPostion[i] + motionCameraTargetPosition[i])
  134. sliderTime += 525 --(add 10 seconds)
  135. )
Add Comment
Please, Sign In to add comment