View position in python API

Hi guys!
I’m writting addon in which I need to use location of “fake camera” (I mean the point in space from where we observe scene). I found functions like:


So far I know that view location describe pivot point, distance is also clear (it changes when i scroll). However I do not have any idea how to obtain from these data current observator location. Does anybody know?


There’s also .view_matrix and .perspective_matrix

Check this script:

Thanks! However it did not solve my problem because it works only in perspective mode.
I’ve tried to find solution on my own over the weekend and here is what i got. I think it may be usefull for others. Thanks again :wink:

view_pivot = bpy.context.region_data.view_location
view_rotation = bpy.context.region_data.view_rotation.to_euler()
vector_x = math.sin(view_rotation.z)
vector_y = -math.cos(view_rotation.z)
vector_z = math.cos(view_rotation.x)

view_vector = mathutils.Vector((vector_x,vector_y,vector_z))    
view_location = view_pivot + view_vector*bpy.context.region_data.view_distance