Free as in Freedom: Codeberg.org. Create your repos and join us!
Join Donate
Browse Source

Export orthographic cameras using 'screenwindow'.

Jan Walter 3 months ago
parent
commit
71374b526b
2 changed files with 13 additions and 7 deletions
  1. BIN
      blend/rs_pbrt_010.blend
  2. 13
    7
      io_scene_pbrt/export_pbrt.py

BIN
blend/rs_pbrt_010.blend View File


+ 13
- 7
io_scene_pbrt/export_pbrt.py View File

@@ -130,7 +130,7 @@ class PbrtExporter:
130 130
         # export camera(s)
131 131
         if self.camObj != None:
132 132
             self.camData = self.camObj.data
133
-            if self.camData.type == "PERSP":
133
+            if self.camData.type == "PERSP" or self.camData.type == "ORTHO":
134 134
                 for obj in self.scene.objects:
135 135
                     data = obj.data
136 136
                     if obj.type == 'CAMERA':
@@ -504,13 +504,19 @@ class PbrtExporter:
504 504
                                 self.scale_length * target[2]))
505 505
             self.pbrtFile.write("       %s %s %s # up\n" %
506 506
                                (up[0], up[1], up[2]))
507
-            self.pbrtFile.write('Camera "perspective"\n')
508 507
             aspect = resolution[0] / float(resolution[1])
509
-            if aspect >= 1.0:
510
-                fov = 2 * math.degrees(math.atan(16.0 / (aspect * lens)))
511
-            else:
512
-                fov = 2 * math.degrees(math.atan((aspect * 16.0) / lens))
513
-            self.pbrtFile.write('  "float fov" [ %s ]\n' % fov)
508
+            if obj.data.type == "ORTHO":
509
+                self.pbrtFile.write('Camera "orthographic"\n')
510
+                swy = obj.data.ortho_scale / (2.0 * aspect)
511
+                swx = aspect * swy
512
+                self.pbrtFile.write('  "float screenwindow" [ -%s %s -%s %s ]\n' % (swx, swx, swy, swy))
513
+            if obj.data.type == "PERSP":
514
+                self.pbrtFile.write('Camera "perspective"\n')
515
+                if aspect >= 1.0:
516
+                    fov = 2 * math.degrees(math.atan(16.0 / (aspect * lens)))
517
+                else:
518
+                    fov = 2 * math.degrees(math.atan((aspect * 16.0) / lens))
519
+                self.pbrtFile.write('  "float fov" [ %s ]\n' % fov)
514 520
             if aperture_size > 0.0 and (dof_distance > 0.0 or dof_object != None):
515 521
                 focaldistance = dof_distance
516 522
                 if dof_object != None:

Loading…
Cancel
Save