Last active
May 20, 2017 15:57
-
-
Save jazzyjackson/364771114aeb394b0b95d98135b67cb1 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 | |
from mathutils import * | |
from math import pi # wasn't necessary on my mac, but my coworker threw an error without it ¯\_(ツ)_/¯ | |
bpy.ops.object.text_add() | |
textObject = bpy.context.active_object # the object just addded to the scene becomes the active object of the context | |
textObject.data.body = "hello\nworld!" | |
bpy.ops.object.origin_set(type="ORIGIN_GEOMETRY") # set the origin (center of rotation) of the shape to it's geometric center | |
textObject.rotation_euler[0] = pi / 2 #rotation euler is an array-like, [x,y,z], so this is 90 deg x axis rotation in radians! | |
textObject.keyframe_insert('rotation_euler',frame = 0) #as opposed to rotation quaternion | |
textObject.rotation_euler[2] = 20 * pi # 2pi is 360 degrees, 20pi is 10 rotations. | |
textObject.keyframe_insert('rotation_euler',frame = 500) # default keyframe interpolation is a sine wave, rotation speeds up and slows down over 500 frames | |
bpy.ops.object.duplicate_move() #creates an unlinked copy, complete with animation keyframes | |
bpy.context.active_object.scale[2] = -1 #invert the y axis, effectively flipping the normals to backside of text, otherwise light rays only bounce off one side, and the backside is invisible. | |
bpy.data.scenes['Scene'].frame_end = 500 #set the length of the animation | |
bpy.ops.export_scene.fbx(filepath="./holobang.fbx", | |
object_types={'OTHER'}, # for MESH we would use MESH, but Text is a Curve is an Other | |
bake_anim_use_nla_strips=False, | |
bake_anim_use_all_actions=False) # following recommendations from SketchFab https://help.sketchfab.com/hc/en-us/articles/206223646 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment