[Bf-extensions-cvs] [ca85dbc7] master: sun position: update working version: T69936

meta-androcto noreply at git.blender.org
Fri Sep 20 08:23:47 CEST 2019


Commit: ca85dbc76c57decc803fff09dcb60bb6fc21e03a
Author: meta-androcto
Date:   Fri Sep 20 16:23:17 2019 +1000
Branches: master
https://developer.blender.org/rBACca85dbc76c57decc803fff09dcb60bb6fc21e03a

sun position: update working version: T69936

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

M	sun_position/__init__.py
M	sun_position/hdr.py
M	sun_position/map.py
M	sun_position/north.py
D	sun_position/operators.py
M	sun_position/properties.py
M	sun_position/sun_calc.py
M	sun_position/ui_sun.py

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

diff --git a/sun_position/__init__.py b/sun_position/__init__.py
index c8e03f77..d276463e 100644
--- a/sun_position/__init__.py
+++ b/sun_position/__init__.py
@@ -28,67 +28,65 @@
 # NASA's image use policy can be found at:
 # http://www.nasa.gov/audience/formedia/features/MP_Photo_Guidelines.html
 # --------------------------------------------------------------------------
+# The geo parser script is by Maximilian Högner, released
+# under the GNU GPL license:
+# http://hoegners.de/Maxi/geo/
+# --------------------------------------------------------------------------
 
 # <pep8 compliant>
 
 bl_info = {
-    "name": "Sun Position 2.8",
-    "author": "Michael Martin, Kevan Cress",
-    "version": (3, 0, 1),
+    "name": "Sun Position",
+    "author": "Michael Martin",
+    "version": (3, 1, 0),
     "blender": (2, 80, 0),
     "location": "World > Sun Position",
     "description": "Show sun position with objects and/or sky texture",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" \
-        "Scripts/3D_interaction/Sun_Position",
-        "tracker_url": "https://projects.blender.org/tracker/" \
-        "index.php?func=detail&aid=29714",
-    "category": "3D View"}  #  "Lighting"} ?
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+    "Scripts/3D_interaction/Sun_Position",
+    "tracker_url": "https://projects.blender.org/tracker/"
+    "index.php?func=detail&aid=29714",
+    "category": "Lighting"}
 
-import bpy
-from . properties import *
-from . ui_sun import *
-from . map import SunPos_Help
-from . hdr import SunPos_HdrHelp
+if "bpy" in locals():
+    import importlib
+    importlib.reload(properties)
+    importlib.reload(ui_sun)
+    importlib.reload(map)
+    importlib.reload(hdr)
 
-############################################################################
+else:
+    from . import properties, ui_sun, map, hdr
+
+import bpy
 
-classes = (
-    SunPos_OT_Controller,
-    SunPos_OT_Preferences,
-    SunPos_OT_PreferencesDone,
-    SunPos_OT_DayRange,
-    SunPos_OT_SetObjectGroup,
-    SunPos_OT_ClearObjectGroup,
-    SunPos_OT_TimePlace,
-    SunPos_OT_Map,
-    SunPos_OT_Hdr,
-    SPOS_PT_Panel,
-    SunPos_OT_MapChoice,
-    SunPos_Help,
-    SunPos_HdrHelp,
-)
 
 def register():
-    bpy.utils.register_class(SunPosSettings)
-    bpy.types.Scene.SunPos_property = (
-        bpy.props.PointerProperty(type=SunPosSettings,
+    bpy.utils.register_class(properties.SunPosProperties)
+    bpy.types.Scene.sun_pos_properties = (
+        bpy.props.PointerProperty(type=properties.SunPosProperties,
                         name="Sun Position",
                         description="Sun Position Settings"))
-    bpy.utils.register_class(SunPosPreferences)
-    bpy.types.Scene.SunPos_pref_property = (
-        bpy.props.PointerProperty(type=SunPosPreferences,
-                        name="Sun Position Preferences",
-                        description="SP Preferences"))
+    bpy.utils.register_class(properties.SunPosAddonPreferences)
+    bpy.utils.register_class(ui_sun.SUNPOS_OT_AddPreset)
+    bpy.utils.register_class(ui_sun.SUNPOS_OT_DefaultPresets)
+    bpy.utils.register_class(ui_sun.SUNPOS_MT_Presets)
+    bpy.utils.register_class(ui_sun.SUNPOS_PT_Panel)
+    bpy.utils.register_class(hdr.SUNPOS_OT_ShowHdr)
+    # bpy.utils.register_class(map.SunPos_Help)
 
-    for c in classes:
-        bpy.utils.register_class(c)
+    bpy.app.handlers.frame_change_post.append(sun_calc.sun_handler)
 
 
 def unregister():
-    for c in reversed(classes):
-        bpy.utils.unregister_class(c)
+    # bpy.utils.unregister_class(map.SunPos_Help)
+    bpy.utils.unregister_class(hdr.SUNPOS_OT_ShowHdr)
+    bpy.utils.unregister_class(ui_sun.SUNPOS_PT_Panel)
+    bpy.utils.unregister_class(ui_sun.SUNPOS_MT_Presets)
+    bpy.utils.unregister_class(ui_sun.SUNPOS_OT_DefaultPresets)
+    bpy.utils.unregister_class(ui_sun.SUNPOS_OT_AddPreset)
+    bpy.utils.unregister_class(properties.SunPosAddonPreferences)
+    del bpy.types.Scene.sun_pos_properties
+    bpy.utils.unregister_class(properties.SunPosProperties)
 
-    del bpy.types.Scene.SunPos_pref_property
-    bpy.utils.unregister_class(SunPosPreferences)
-    del bpy.types.Scene.SunPos_property
-    bpy.utils.unregister_class(SunPosSettings)
+    bpy.app.handlers.frame_change_post.remove(sun_calc.sun_handler)
diff --git a/sun_position/hdr.py b/sun_position/hdr.py
index e7f908f6..774b42df 100644
--- a/sun_position/hdr.py
+++ b/sun_position/hdr.py
@@ -1,936 +1,294 @@
+### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
 # -*- coding: utf-8 -*-
 
 import bpy
+import gpu
 import bgl
-import blf
-import sys
-import os
-import math
-
-from . sun_calc import degToRad, radToDeg, format_hms
-from . properties import Display, Sun
-
-# ---------------------------------------------------------------------------
-
-
-class HdrObject:
-
-    class Origin:
-        x = 0
-        y = 0
-
-    def __init__(self, t, w, h):
-        self.type = t
-        self.width = w
-        self.height = h
-        self.heightFactor = .50
-        self.opacity = 1.0
-        self.focused = False
-        self.view3d_area = None
-        self.origin = self.Origin()
-
-    def set_dimensions(self, width):
-        self.width = width
-        self.height = int(width * self.heightFactor)
-
-    def check_focus(self, context, event):
-        self.focused = self.is_focused(context, event)
-        return self.focused
-
-    def is_focused(self, context, event):
-        if context.area != self.view3d_area:
-            return False
-
-        x = event.mouse_region_x
-        y = event.mouse_region_y
-
-        for reg in self.view3d_area.regions:
-            if reg.type == 'WINDOW':
-                if x < 0 or x > reg.width:
-                    return False
-                else:
-                    break
-
-        if x < self.origin.x or x > (self.origin.x + self.width) or \
-                y < self.origin.y or y > (self.origin.y + self.height) or \
-                y < 0 or y > reg.height:
-            return False
-        return True
-
-    def near_border(self, context, event):
-        if context.area != self.view3d_area:
-            return False
-
-        x = event.mouse_region_x
-        y = event.mouse_region_y
-
-        for reg in self.view3d_area.regions:
-            if reg.type == 'WINDOW':
-                if x < 20 or x > (reg.width - 20) or \
-                        y < 20 or y > (reg.height - 20):
-                    return True
-                else:
-                    break
-        return False
-
-
-# ---------------------------------------------------------------------------
+from gpu_extras.batch import batch_for_shader
+from mathutils import Vector
+from gpu_extras.presets import draw_texture_2d
+from math import sqrt, pi, atan2, asin
 
 
-class HdrClass:
+vertex_shader = '''
+uniform mat4 ModelViewProjectionMatrix;
 
-    class mouse:
-        pass
+/* Keep in sync with intern/opencolorio/gpu_shader_display_transform_vertex.glsl */
+in vec2 texCoord;
+in vec2 pos;
+out vec2 texCoord_interp;
 
-    class grab:
+void main()
+{
+  gl_Position = ModelViewProjectionMatrix * vec4(pos.xy, 0.0f, 1.0f);
+  gl_Position.z = 1.0;
+  texCoord_interp = texCoord;
+}'''
 
-        class spot:
-            pass
+fragment_shader = '''
+in vec2 texCoord_interp;
+out vec4 fragColor;
 
-        class offset:
-            pass
+uniform sampler2D image;
+uniform float exposure;
 
-    class zoom:
-        pass
+void main()
+{
+  fragColor = texture(image, texCoord_interp) * exposure;
+}'''
 
-    class image:
-        pass
+# shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
 
-    class last:
-        pass
 
-    def __init__(self):
-        self.handler1 = None
-        self.handler2 = None
-        self.view3d_area = None
-        self.draw_region = None
-        self.glImage = None
-        self.init_zoom_preference = True
-        self.reset()
-        self.last.filename = None
-        self.last.image = None
-        self.last.pixels = None
-        self.last.projection = None
+def draw_callback_px(self, context):
+    nt = bpy.context.scene.world.node_tree.nodes
+    env_tex_node = nt.get(bpy.context.scene.sun_pos_properties.hdr_texture)
+    image = env_tex_node.image
 
-    def init(self):
-        self.object = [HdrObject('MAP', 0, 0), HdrObject('TEXT', 100, 160)]
-        self.object[0].set_dimensions(200)
-        self.object[1].origin.x = 10
-        self.object[1].origin.y = 80
-
-    def zoom_preferences(self, invert_zoom_wheel, invert_mouse_zoom):
-        self.init_zoom_preference = False
-        if invert_zoom_wheel:
-            self.zoom.wheel_up = 'OUT'
-            self.zoom.wheel_down = 'IN'
-        else:
-            self.zoom.wheel_up = 'IN'
-            self.zoom.wheel_down = 'OUT'
-        if invert_mouse_zoom:
-            self.zoom.mouse_up = 'IN'
-            self.zoom.mouse_down = 'OUT'
-        else:
-            self.zoom.mouse_up = 'OUT'
-            self.zoom.mouse_down = 'IN'
-
-    def reset(self):
-        self.init()
-        self.action = None
-        self.isActive = False
-        self.start = False
-        self.stop = False
-        self.lockCrosshair = True
-        self.elevation = 0.0
-        self.azimuth = 0.0
-        self.ctrlPress = False
-        self.altPress = False
-        self.mouse.x = 0
-        self.mouse.y = 0
-        self.grab.spot.x = 0
-        self.grab.spot.y = 0


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list