开发者

Programmatically animate a blender model — where to start?

I have to create a simplistic 3D demo.

Having a model in Blender, I will write a python program that will:

  • build a scene, set camera, draw an infinite plane, fill it with texture
  • load a model (exported from Blender) and position the object
  • handle key presses to produce the object moves

I need a link to descriptive tutorial(s) covering these 3 points:

  • creating a 3d scene from Python program
  • loading model from the file (of course I'm fine with any format, just letting you 开发者_C百科know that the source is created in Blender)
  • catching key presses

No need in help on physics, or designing, only the principal programmatic part.

Thanks!


Not much to say: OpenGL / Glut

Also, take a look at the OpenGL red book. You can read it online. Samples are written in C, but can be easily ported to python, since function calls are the same.

Programmatically animate a blender model — where to start?

As for loading the blender model, take a look at this: Loading wavefront obj files with python

In a nutshell look for:

  • Push/Pop matrix
  • glTranslate / glRotate / glScale
  • gluLookAt
  • define a function that and pass it to glutKeyboardFunc


To link components from another Blender file into your scene, you can use the Python API. You can find all the documentation at: http://www.blender.org/documentation/blender_python_api_2_59_0/contents.html

In particular, you probably will need: bpy.data.libraries.load ( http://www.blender.org/documentation/blender_python_api_2_59_0/bpy.types.BlendDataLibraries.html#bpy.types.BlendDataLibraries ) to inspect the contents of a file, and bpy.ops.wm.link_append ( http://www.blender.org/documentation/blender_python_api_2_59_0/bpy.ops.wm.html ) to import the objects you need from the specified file.

I only know how to catch keypresses while running the Game Engine. Is that what you are looking for?

Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜