Created
August 19, 2015 14:19
-
-
Save zeffii/7a756ad358075809fbdf to your computer and use it in GitHub Desktop.
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
import bpy | |
import csv | |
def mission1(obj, loc_txt, quat_txt): | |
with open(loc_txt, 'r') as loc_fh: | |
with open(quat_txt, 'r') as quat_fh: | |
r_loc = csv.reader(loc_fh, delimiter=',') | |
r_quat = csv.reader(quat_fh, delimiter=',') | |
obj.rotation_mode = 'QUATERNION' | |
i = 0 | |
for row_loc in r_loc: | |
row_quat = r_quat.__next__() | |
row_loc = [ float(x.strip()) for x in row_loc[:3]] | |
row_quat = [ float(x.strip()) for x in row_quat[:4]] | |
fr = 10+2*i | |
obj.location = row_loc | |
obj.rotation_quaternion = row_quat | |
obj.keyframe_insert(data_path="location", frame=fr) | |
obj.keyframe_insert(data_path="rotation_quaternion", frame=fr) | |
i = i+1 | |
path_xyz = '/home/zeffii/Desktop/ARYA_PYTHON/xyzposition.csv' | |
path_quatz = '/home/zeffii/Desktop/ARYA_PYTHON/quaternions.csv' | |
mission1(bpy.context.active_object, path_xyz, path_quatz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment