Last active
April 24, 2024 14:18
-
-
Save howiemnet/8784cf04568c849271730965eaf35159 to your computer and use it in GitHub Desktop.
First attempt at getting AE camera data into Houdini (hacky woo)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ultra quick'n'hacky AE camera animation importer for Houdini. | |
# Create a new shelf, create a new tool, paste this into the script box. | |
# | |
# In AE, select the Orientation and/or Position keyframes, and Ctrl/Cmd-C them to the clipboard | |
# Open a new text file (Notepad or Textedit) and paste the clipboard contents in. There's your keyframes. | |
# Save the text file somewhere and amend the filename line below to suit | |
# In Houdini, create a camera (it's up to you to set the same zoom / aperture as the AE one). | |
# ... and run this script (well, press the shelf button you stuck this on) | |
import hou | |
# amend the next two lines as required | |
h = hou.node("/obj/cam1") | |
filename = "cameraKeyFrameData.txt" | |
state = "crap" | |
ignoreLine = False | |
with open (filename,"rU") as ff: | |
for theLine in ff: | |
elements = theLine.strip().split("\t") | |
ignoreLine = False | |
if len(elements) == 0: | |
state = "crap" | |
ignoreLine = True | |
else: | |
if elements.count("X degrees") > 0: | |
state = "orientation" | |
ignoreLine = True | |
if elements.count("X pixels") > 0: | |
state = "translate" | |
ignoreLine = True | |
if ignoreLine == False: | |
if len(elements) == 4: | |
theFrame = elements[0] | |
theXValue = elements[1] | |
theYValue = elements[2] | |
theZValue = elements[3] | |
if state == "translate": | |
print ("At frame "+theFrame+" translate to: "+theXValue) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(float(theXValue)*0.01) | |
testCh = hou.parm("obj/cam1/tx") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theYValue)*0.01) | |
testCh = hou.parm("obj/cam1/ty") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theZValue)*0.01) | |
testCh = hou.parm("obj/cam1/tz") | |
testCh.setKeyframe(setKey) | |
if state == "orientation": | |
print ("At frame "+theFrame+" orient to: "+theXValue) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(float(theXValue)) | |
testCh = hou.parm("obj/cam1/rx") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theYValue)) | |
testCh = hou.parm("obj/cam1/ry") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theZValue)) | |
testCh = hou.parm("obj/cam1/rz") | |
testCh.setKeyframe(setKey) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey!! my camera was in the wrong direction and i don't understand how to correct it