5 def export_to_file(self, context, out_fn):
6 obj = context.active_object
8 resource = self.export_camera(obj)
10 resource.write_to_file(out_fn)
12 def export_camera(self, obj):
13 if obj.type!='CAMERA':
14 raise Exception("Object is not a camera")
16 from .datafile import Resource, Statement
17 resource = Resource(obj.name+".camera", "camera")
19 position = obj.matrix_world*mathutils.Vector((0, 0, 0))
20 resource.statements.append(Statement("position", position[0], position[1], position[2]))
21 look_dir = obj.matrix_world*mathutils.Vector((0, 0, -1, 0))
22 resource.statements.append(Statement("look_direction", look_dir[0], look_dir[1], look_dir[2]))
23 resource.statements.append(Statement("up_direction", 0.0, 0.0, 1.0))
24 resource.statements.append(Statement("field_of_view", obj.data.angle_y*180/math.pi))
25 resource.statements.append(Statement("depth_clip", obj.data.clip_start, obj.data.clip_end))