[Bf-extensions-cvs] [b695b981] master: Fix: issues with the camera and light source

Clemens Barth noreply at git.blender.org
Fri Mar 15 21:24:27 CET 2019


Commit: b695b9816e268d84e4b5b968dfa333d81c59bc9c
Author: Clemens Barth
Date:   Fri Mar 15 21:23:33 2019 +0100
Branches: master
https://developer.blender.org/rBACb695b9816e268d84e4b5b968dfa333d81c59bc9c

Fix: issues with the camera and light source

For instance, the old 'RAY_SHADOW' thing of the light source was removed and
the 90° camera rotation is now deactivated. I need to see how one can rotate
the camera around its own axis ... . Furthermore, in the code the light source
is now named as 'light' and not as 'lamp'.

===================================================================

M	io_mesh_xyz/import_xyz.py

===================================================================

diff --git a/io_mesh_xyz/import_xyz.py b/io_mesh_xyz/import_xyz.py
index 2434e1f3..a9274d29 100644
--- a/io_mesh_xyz/import_xyz.py
+++ b/io_mesh_xyz/import_xyz.py
@@ -359,7 +359,7 @@ def import_xyz(Ball_type,
                put_to_center,
                put_to_center_all,
                use_camera,
-               use_lamp,
+               use_light,
                filepath_xyz):
 
     # List of materials
@@ -539,43 +539,44 @@ def import_xyz(Ball_type,
         # 4 is the size of the matrix.
         camera.rotation_euler  = Matrix.Rotation(angle, 4, axis_vec).to_euler()
 
-        # Rotate the camera around its axis by 90° such that we have a nice
-        # camera position and view onto the object.
-        bpy.ops.object.select_all(action='DESELECT')
-        camera.select_set(True)
-        bpy.ops.transform.rotate(value=(90.0*2*pi/360.0),
-                                 axis=object_camera_vec,
-                                 constraint_axis=(False, False, False),
-                                 orient_type='GLOBAL',
-                                 mirror=False, proportional='DISABLED',
-                                 proportional_edit_falloff='SMOOTH',
-                                 proportional_size=1, snap=False,
-                                 snap_target='CLOSEST', snap_point=(0, 0, 0),
-                                 snap_align=False, snap_normal=(0, 0, 0),
-                                 release_confirm=False)
+        # This will be done at some point ...
+        #
+        ## Rotate the camera around its axis by 90° such that we have a nice
+        ## camera position and view onto the object.
+        #bpy.ops.object.select_all(action='DESELECT')
+        #camera.select_set(True)
+        #bpy.ops.transform.rotate(value=(90.0*2*pi/360.0),
+        #                         axis=object_camera_vec,
+        #                         constraint_axis=(False, False, False),
+        #                         orient_type='GLOBAL',
+        #                         mirror=False, proportional='DISABLED',
+        #                         proportional_edit_falloff='SMOOTH',
+        #                         proportional_size=1, snap=False,
+        #                         snap_target='CLOSEST', snap_point=(0, 0, 0),
+        #                         snap_align=False, snap_normal=(0, 0, 0),
+        #                         release_confirm=False)
 
     # Here a lamp is put into the scene, if chosen.
-    if use_lamp == True:
+    if use_light == True:
 
         # This is the distance from the object measured in terms of %
         # of the camera distance. It is set onto 50% (1/2) distance.
-        lamp_dl = sqrt(object_size) * 15 * 0.5
+        light_dl = sqrt(object_size) * 15 * 0.5
         # This is a factor to which extend the lamp shall go to the right
         # (from the camera  point of view).
-        lamp_dy_right = lamp_dl * (3.0/4.0)
+        light_dy_right = light_dl * (3.0/4.0)
 
         # Create x, y and z for the lamp.
-        object_lamp_vec = Vector((lamp_dl,lamp_dy_right,lamp_dl))
-        lamp_xyz_vec = object_center_vec + object_lamp_vec
+        object_light_vec = Vector((light_dl,light_dy_right,light_dl))
+        light_xyz_vec = object_center_vec + object_light_vec
 
         # Create the lamp
-        lamp_data = bpy.data.lamps.new(name="A_lamp", type="POINT")
-        lamp_data.distance = 500.0
-        lamp_data.energy = 3.0
-        lamp_data.shadow_method = 'RAY_SHADOW'
-        lamp = bpy.data.objects.new("A_lamp", lamp_data)
-        lamp.location = lamp_xyz_vec
-        bpy.context.collection.objects.link(lamp)
+        light_data = bpy.data.lights.new(name="A_lamp", type="SUN")
+        light_data.distance = 500.0
+        light_data.energy = 3.0
+        light = bpy.data.objects.new("A_lamp", light_data)
+        light.location = light_xyz_vec
+        bpy.context.collection.objects.link(light)
 
         bpy.context.scene.world.light_settings.use_ambient_occlusion = True
         bpy.context.scene.world.light_settings.ao_factor = 0.2



More information about the Bf-extensions-cvs mailing list