I want to make a set of scripts that will control active 3d view with N900’s (Nokia’s) accelerometers.
The discussion was also started here: http://talk.maemo.org/showthread.php?t=61964
There seems to be no problem getting accelerometers data on N900 (for examle using sources of AccDisplay app) and I can imagine some ways of streaming it to desktop.
But I can’t find a way to control 3d view in Blender with python. Does it exist?
There are only tools for moving and rotating objects but I want to begin with view as it’s most uncomfortable with mouse/numpad for me.
You can change the viewport. It’s located in RegionView3D
You’re looking for view_distance, view_location, view_perspective and view_rotate_method. For a short period of time this could be done much simpler, because view_matrix was both readable and settable, but this was changed to read-only. I don’t know the reasons for that, but you might want to ask about it on the mailinglist.
A simple example:
import bpy
for area in bpy.context.screen.areas:
if area.type == "VIEW_3D":
region = area.active_space.region_3d
region.view_location = [10, 0, 0]
So I was somewhat right when I was thinking “I’d better wait until 2.5 stabilization as they are changing the API”. Now I’m back to this concept and trying to work with VIEW_3D again. Just found out that area.active_space is no longer valid, now it’s area.spaces.active.
I was looking into this a while back, but instead of a N900 I was planning on using a ZTE Blade with Android 2.2 and an application which recorded the X, Y, Z values from the accelerometers to a .CVS file.
I didn’t really get anywhere with it as things got in the way.