0
$\begingroup$

I'm creating a real learning human baby in Blender Cycles. To create the "brain" or "AI" I must of course use code. But, can I run code in Cycles mode? I don't want to be in BGE mode. P.S. I don't need interactivity.

For example I'll need the code to move armatures, get numbers from a accelo-meter in the baby and use the numbers in the code, etc.

$\endgroup$
2
$\begingroup$

Using python you can create an animation that can be played back and rendered using any render engine at a later time.

bone.rotation_euler.x = 15.0
bone.keyframe_insert('rotation_euler', frame=10)

As you want to read external data while creating your animation you might want to look at using the subprocess module to keep blender responsive.

Without wanting interactivity you could capture your data to a text file and have your script read it in to create the animation.

with open('mydata.csv') as csvfile:
    inFile = csv.reader(csvfile)
    for row in inFile:
        bone.rotation_euler.x = row[1]
        bone.rotation_euler.y = row[2]
        bone.rotation_euler.z = row[3]
        bone.keyframe_insert('rotation_euler', frame=row[0])
$\endgroup$
  • $\begingroup$ Are you suggesting for me to use BGE and then render in ex. Cycles? I don't want to use BGE, it has worse Physics than Cycles does and doesn't allow Constraints. $\endgroup$ – Friendly Person 44 Jun 21 '17 at 12:53
  • $\begingroup$ No, nothing there refers to the game engine. You can use python to keyframe an animation the same as you can do by hand. $\endgroup$ – sambler Jun 22 '17 at 4:05
  • $\begingroup$ "python to keyframe an animation the same as you can do by hand" But can the code change, grab numbers from sensors, use those, update etc as I originally asked in my question? $\endgroup$ – Friendly Person 44 Jun 22 '17 at 5:29
  • $\begingroup$ The second example reads data from a file, you can change that to accepting data from a network connection or from a serial port.... whatever python is capable of using to get data. $\endgroup$ – sambler Jun 22 '17 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.