Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
blender
blender-addons-contrib
Commits
ca85dbc7
Commit
ca85dbc7
authored
Sep 20, 2019
by
meta-androcto
Browse files
sun position: update working version: T69936
parent
9e4579b1
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
sun_position/__init__.py
View file @
ca85dbc7
...
...
@@ -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
(
SunPosSetting
s
)
bpy
.
types
.
Scene
.
S
un
P
os_propert
y
=
(
bpy
.
props
.
PointerProperty
(
type
=
SunPosSetting
s
,
bpy
.
utils
.
register_class
(
properties
.
SunPosPropertie
s
)
bpy
.
types
.
Scene
.
s
un
_p
os_propert
ies
=
(
bpy
.
props
.
PointerProperty
(
type
=
properties
.
SunPosPropertie
s
,
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
)
sun_position/hdr.py
View file @
ca85dbc7
This diff is collapsed.
Click to expand it.
sun_position/map.py
View file @
ca85dbc7
### 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
...
...
@@ -8,8 +26,8 @@ import os
import
datetime
import
math
from
.
sun_calc
import
degToRad
,
format_hm
s
from
.
properties
import
Display
,
S
un
from
math
import
radian
s
from
.
sun_calc
import
format_hms
,
s
un
# ---------------------------------------------------------------------------
...
...
@@ -24,16 +42,16 @@ class MapObject:
self
.
type
=
t
self
.
width
=
w
self
.
height
=
h
self
.
height
F
actor
=
.
50
self
.
height
_f
actor
=
.
50
self
.
opacity
=
1.0
self
.
focused
=
False
self
.
view3d_area
=
None
self
.
color
S
tyle
=
'N'
self
.
color
_s
tyle
=
'N'
self
.
origin
=
self
.
Origin
()
def
set_dimensions
(
self
,
width
):
self
.
width
=
width
self
.
height
=
int
(
width
*
self
.
height
F
actor
)
self
.
height
=
int
(
width
*
self
.
height
_f
actor
)
def
check_focus
(
self
,
context
,
event
):
self
.
focused
=
self
.
is_focused
(
context
,
event
)
...
...
@@ -132,16 +150,16 @@ class MapClass:
def
reset
(
self
,
location
):
self
.
init
(
location
)
self
.
action
=
None
self
.
is
A
ctive
=
False
self
.
is
_a
ctive
=
False
self
.
start
=
False
self
.
stop
=
False
self
.
lock
C
rosshair
=
True
self
.
show
I
nfo
=
False
self
.
lock
_c
rosshair
=
True
self
.
show
_i
nfo
=
False
self
.
latitude
=
0.0
self
.
longitude
=
0.0
self
.
ctrl
P
ress
=
False
self
.
alt
P
ress
=
False
self
.
line
W
idth
=
1.0
self
.
ctrl
_p
ress
=
False
self
.
alt
_p
ress
=
False
self
.
line
_w
idth
=
1.0
self
.
textureless
=
False
self
.
mouse
.
x
=
0
self
.
mouse
.
y
=
0
...
...
@@ -205,7 +223,7 @@ class MapClass:
self
.
handler1
=
bpy
.
types
.
SpaceView3D
.
draw_handler_add
(
Map_load_callback
,
(
self
,
context
),
'WINDOW'
,
'POST_PIXEL'
)
self
.
is
A
ctive
=
True
self
.
is
_a
ctive
=
True
return
True
else
:
return
False
...
...
@@ -238,14 +256,13 @@ class MapClass:
self
.
image
.
free_it
=
False
self
.
glImage
=
None
self
.
image
.
bindcode
=
0
self
.
isActive
=
False
#if Sun.SP: # why removed?
Sun
.
SP
.
ShowMap
=
False
# indent?
self
.
is_active
=
False
sun
.
sp
.
show_map
=
False
def
load_blender_image
(
self
,
file_name
):
if
file_name
==
"None"
:
self
.
textureless
=
True
self
.
object
[
0
].
height
F
actor
=
.
5
self
.
object
[
0
].
height
_f
actor
=
.
5
return
True
else
:
self
.
textureless
=
False
...
...
@@ -259,7 +276,7 @@ class MapClass:
if
self
.
glImage
is
not
None
:
self
.
image
.
loaded
=
True
self
.
glImage
.
user_clear
()
self
.
object
[
0
].
height
F
actor
=
\
self
.
object
[
0
].
height
_f
actor
=
\
self
.
glImage
.
size
[
1
]
/
self
.
glImage
.
size
[
0
]
return
True
else
:
...
...
@@ -286,7 +303,7 @@ class MapClass:
fy
-=
20
return
fy
if
text
.
color
S
tyle
==
'N'
:
if
text
.
color
_s
tyle
==
'N'
:
tColor
=
(
0.8
,
0.8
,
0.8
,
1.0
)
vColor
=
(
1.0
,
1.0
,
1.0
,
1.0
)
else
:
...
...
@@ -296,31 +313,31 @@ class MapClass:
blf
.
size
(
0
,
14
,
72
)
fx
=
text
.
origin
.
x
fy
=
text
.
origin
.
y
+
140
fy
=
text_line
(
fx
+
10
,
fy
,
True
,
tColor
,
str
(
S
un
.
SP
.
M
onth
)
+
" / "
+
str
(
S
un
.
SP
.
D
ay
)
+
" / "
+
str
(
S
un
.
SP
.
Y
ear
))
fy
=
text_line
(
fx
+
10
,
fy
,
True
,
tColor
,
str
(
s
un
.
sp
.
m
onth
)
+
" / "
+
str
(
s
un
.
sp
.
d
ay
)
+
" / "
+
str
(
s
un
.
sp
.
y
ear
))
fy
=
text_line
(
fx
,
fy
,
False
,
tColor
,
" Day: "
)
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
str
(
S
un
.
SP
.
D
ay_of_year
))
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
str
(
s
un
.
sp
.
d
ay_of_year
))
fy
=
text_line
(
fx
,
fy
,
False
,
tColor
,
"Time: "
)
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
format_hms
(
S
un
.
SP
.
T
ime
))
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
format_hms
(
s
un
.
sp
.
t
ime
))
if
S
un
.
ShowRiseSet
:
if
s
un
.
ShowRiseSet
:
fy
-=
10
fy
=
text_line
(
fx
,
fy
,
True
,
tColor
,
"Solar Noon:"
)
fy
=
text_line
(
fx
+
14
,
fy
,
True
,
vColor
,
format_hms
(
S
un
.
SolarNoon
.
time
))
format_hms
(
s
un
.
SolarNoon
.
time
))
fy
-=
10
fy
=
text_line
(
fx
,
fy
,
False
,
tColor
,
"Rise: "
)
if
S
un
.
RiseSetOK
:
if
s
un
.
RiseSetOK
:
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
format_hms
(
S
un
.
Sunrise
.
time
))
format_hms
(
s
un
.
Sunrise
.
time
))
else
:
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
"--------"
)
fy
=
text_line
(
fx
,
fy
,
False
,
tColor
,
" Set: "
)
if
S
un
.
RiseSetOK
:
if
s
un
.
RiseSetOK
:
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
format_hms
(
S
un
.
S
unset
.
time
))
format_hms
(
s
un
.
s
unset
.
time
))
else
:
fy
=
text_line
(
fx
+
40
,
fy
,
True
,
vColor
,
"--------"
)
...
...
@@ -337,7 +354,7 @@ class MapClass:
def
event_controller
(
self
,
context
,
event
):
if
not
S
un
.
SP
.
S
how
M
ap
or
event
.
type
==
'TIMER'
:
if
not
s
un
.
sp
.
s
how
_m
ap
or
event
.
type
==
'TIMER'
:
return
{
'PASS_THROUGH'
}
mapInFocus
=
self
.
object
[
0
].
check_focus
(
context
,
event
)
...
...
@@ -488,7 +505,7 @@ def key_MiddleMouse(context, event):
def
key_A
(
event
):
if
event
.
value
==
'PRESS'
:
if
Map
.
object
[
0
].
focused
:
S
un
.
SP
.
O
bject
G
roup
=
'ANALEMMA'
s
un
.
sp
.
o
bject
_g
roup
=
'ANALEMMA'
else
:
return
{
'PASS_THROUGH'
}
return
{
'RUNNING_MODAL'
}
...
...
@@ -497,10 +514,10 @@ def key_A(event):
def
key_C
(
event
):
if
event
.
value
==
'PRESS'
:
if
Map
.
object
[
0
].
focused
or
Map
.
object
[
1
].
focused
:
if
Map
.
object
[
1
].
color
S
tyle
==
'N'
:
Map
.
object
[
1
].
color
S
tyle
=
'R'
if
Map
.
object
[
1
].
color
_s
tyle
==
'N'
:
Map
.
object
[
1
].
color
_s
tyle
=
'R'
else
:
Map
.
object
[
1
].
color
S
tyle
=
'N'
Map
.
object
[
1
].
color
_s
tyle
=
'N'
else
:
return
{
'PASS_THROUGH'
}
return
{
'RUNNING_MODAL'
}
...
...
@@ -509,7 +526,7 @@ def key_C(event):
def
key_E
(
event
):
if
event
.
value
==
'PRESS'
:
if
Map
.
object
[
0
].
focused
:
S
un
.
SP
.
O
bject
G
roup
=
'ECLIPTIC'
s
un
.
sp
.
o
bject
_g
roup
=
'ECLIPTIC'
else
:
return
{
'PASS_THROUGH'
}
return
{
'RUNNING_MODAL'
}
...
...
@@ -556,8 +573,8 @@ def key_S(event):
if
event
.
value
==
'PRESS'
:
if
Map
.
object
[
0
].
focused
:
Map
.
showInfo
=
True
if
not
Map
.
showInfo
else
False
S
un
.
PP
.
ShowRiseSet
=
True
S
un
.
ShowRiseSet
=
True
s
un
.
PP
.
ShowRiseSet
=
True
s
un
.
ShowRiseSet
=
True
else
:
return
{
'PASS_THROUGH'
}
return
{
'RUNNING_MODAL'
}
...
...
@@ -749,10 +766,10 @@ def mouse_zoom():
def
check_time_boundary
():
if
S
un
.
SP
.
T
ime
>
24.0
:
S
un
.
SP
.
T
ime
+=
-
24.0
elif
S
un
.
SP
.
T
ime
<
0.0
:
S
un
.
SP
.
T
ime
+=
24.0
if
s
un
.
sp
.
t
ime
>
24.0
:
s
un
.
sp
.
t
ime
+=
-
24.0
elif
s
un
.
sp
.
t
ime
<
0.0
:
s
un
.
sp
.
t
ime
+=
24.0
Display
.
refresh
()
...
...
@@ -762,7 +779,7 @@ def time_change_wheel(action):
else
:
val
=
-
1.0
if
not
Map
.
altPress
else
-
0.0166
mf
=
1.5
if
Map
.
ctrlPress
else
1.0
S
un
.
SP
.
T
ime
+=
mf
*
val
s
un
.
sp
.
t
ime
+=
mf
*
val
check_time_boundary
()
...
...
@@ -774,7 +791,7 @@ def time_change():
sx
=
0.0001
if
Map
.
mouse
.
x
>
Map
.
grab
.
spot
.
x
else
-
0.0001
else
:
sx
=
(
Map
.
mouse
.
x
-
Map
.
grab
.
spot
.
x
)
/
mf
S
un
.
SP
.
T
ime
+=
sx
s
un
.
sp
.
t
ime
+=
sx
Map
.
grab
.
spot
.
x
=
Map
.
mouse
.
x
check_time_boundary
()
...
...
@@ -799,18 +816,18 @@ def day_change():
def
day_change_bounds
(
wf
):
if
S
un
.
SP
.
D
ay_of_year
+
wf
>
366
:
S
un
.
SP
.
D
ay_of_year
=
1
S
un
.
SP
.
Y
ear
+=
1
elif
S
un
.
SP
.
D
ay_of_year
+
wf
<
1
:
S
un
.
SP
.
D
ay_of_year
=
366
S
un
.
SP
.
Y
ear
-=
1
if
s
un
.
sp
.
d
ay_of_year
+
wf
>
366
:
s
un
.
sp
.
d
ay_of_year
=
1
s
un
.
sp
.
y
ear
+=
1
elif
s
un
.
sp
.
d
ay_of_year
+
wf
<
1
:
s
un
.
sp
.
d
ay_of_year
=
366
s
un
.
sp
.
y
ear
-=
1
else
:
S
un
.
SP
.
D
ay_of_year
+=
wf
dt
=
(
datetime
.
date
(
S
un
.
SP
.
Y
ear
,
1
,
1
)
+
datetime
.
timedelta
(
S
un
.
SP
.
D
ay_of_year
-
1
))
S
un
.
SP
.
D
ay
=
dt
.
day
S
un
.
SP
.
M
onth
=
dt
.
month
s
un
.
sp
.
d
ay_of_year
+=
wf
dt
=
(
datetime
.
date
(
s
un
.
sp
.
y
ear
,
1
,
1
)
+
datetime
.
timedelta
(
s
un
.
sp
.
d
ay_of_year
-
1
))
s
un
.
sp
.
d
ay
=
dt
.
day
s
un
.
sp
.
m
onth
=
dt
.
month
Display
.
refresh
()
# ---------------------------------------------------------------------------
...
...
@@ -861,22 +878,22 @@ def opacity_change_bounds(obj):
def
X_change_wheel
(
action
):
wf
=
wheel_factor
(
action
)
if
S
un
.
SP
.
L
ongitude
+
wf
>
180.0
:
S
un
.
SP
.
L
ongitude
=
-
180.0
elif
S
un
.
SP
.
L
ongitude
+
wf
<
-
180.0
:
S
un
.
SP
.
L
ongitude
=
180.0
if
s
un
.
sp
.
l
ongitude
+
wf
>
180.0
:
s
un
.
sp
.
l
ongitude
=
-
180.0
elif
s
un
.
sp
.
l
ongitude
+
wf
<
-
180.0
:
s
un
.
sp
.
l
ongitude
=
180.0
else
:
S
un
.
SP
.
L
ongitude
+=
wf
s
un
.
sp
.
l
ongitude
+=
wf
def
Y_change_wheel
(
action
):
wf
=
wheel_factor
(
action
)
if
S
un
.
SP
.
L
atitude
+
wf
>
90.0
:
S
un
.
SP
.
L
atitude
=
-
90.0
elif
S
un
.
SP
.
L
atitude
+
wf
<
-
90.0
:
S
un
.
SP
.
L
atitude
=
90.0
if
s
un
.
sp
.
l
atitude
+
wf
>
90.0
:
s
un
.
sp
.
l
atitude
=
-
90.0
elif
s
un
.
sp
.
l
atitude
+
wf
<
-
90.0
:
s
un
.
sp
.
l
atitude
=
90.0
else
:
S
un
.
SP
.
L
atitude
+=
wf
s
un
.
sp
.
l
atitude
+=
wf
def
wheel_factor
(
action
):
...
...
@@ -892,11 +909,11 @@ def wheel_factor(action):
def
Map_load_callback
(
self
,
context
):
if
S
un
.
SP
.
S
how
M
ap
and
not
Map
.
image
.
loaded
:
if
s
un
.
sp
.
s
how
_m
ap
and
not
Map
.
image
.
loaded
:
Map
.
glImage
=
None
if
not
Map
.
load_blender_image
(
S
un
.
MapName
):
if
not
Map
.
load_blender_image
(
s
un
.
MapName
):
print
(
"Could not load image file: "
,
Map
.
image
.
name
)
S
un
.
SP
.
ShowMap
=
False
s
un
.
SP
.
ShowMap
=
False
if
Map
.
start
:
def
set_region_data
():
...
...
@@ -933,13 +950,13 @@ def Map_load_callback(self, context):
print
(
"Could not get texture in gl_load()"
)
Map
.
glImage
=
None
Map
.
image
.
bindcode
=
0
S
un
.
SP
.
S
how
M
ap
=
False
s
un
.
sp
.
s
how
_m
ap
=
False
elif
Map
.
textureless
:
set_region_data
()
return
else
:
S
un
.
SP
.
S
how
M
ap
=
False
s
un
.
sp
.
s
how
_m
ap
=
False
return
if
Map
.
stop
:
...
...
@@ -992,10 +1009,10 @@ def Draw_map_callback(self, context):
# cylindrical projection with lat/long 0/0 exactly
# in the middle of the image.
zLong
=
the
M
ap
.
width
/
2
longFac
=
z
L
ong
/
180
zLat
=
the
M
ap
.
height
/
2
latFac
=
z
L
at
/
90
zLong
=
the
_m
ap
.
width
/
2
longFac
=
z
_l
ong
/
180
zLat
=
the
_m
ap
.
height
/
2
latFac
=
z
_l
at
/
90
crossChange
=
True
if
not
Map
.
action
==
'PAN'
:
...
...
@@ -1092,8 +1109,8 @@ def Draw_map_callback(self, context):
x
=
theMap
.
width
/
2.0
if
crossChange
and
not
Map
.
lockCrosshair
:
if
Map
.
action
!=
'Y'
:
S
un
.
SP
.
L
ongitude
=
newLongitude
longitude
=
(
S
un
.
SP
.
L
ongitude
*
x
/
180.0
)
+
x
s
un
.
sp
.
l
ongitude
=
newLongitude
longitude
=
(
s
un
.
sp
.
l
ongitude
*
x
/
180.0
)
+
x
bgl
.
glEnable
(
bgl
.
GL_BLEND
)
bgl
.
glEnable
(
bgl
.
GL_LINES
)
...
...
@@ -1109,8 +1126,8 @@ def Draw_map_callback(self, context):
y
=
theMap
.
height
/
2.0
if
crossChange
and
not
Map
.
lockCrosshair
:
if
Map
.
action
!=
'X'
:
S
un
.
SP
.
L
atitude
=
newLatitude
latitude
=
(
S
un
.
SP
.
L
atitude
*
y
/
90.0
)
+
y
s
un
.
sp
.
l
atitude
=
newLatitude
latitude
=
(
s
un
.
sp
.
l
atitude
*
y
/
90.0
)
+
y
alpha
=
1.0
if
Map
.
action
==
'X'
else
0.5
color
=
(
0.894
,
0.741
,
.
510
,
alpha
)
...
...
@@ -1134,7 +1151,7 @@ def Draw_map_callback(self, context):
bgl
.
glVertex2f
(
Lx
,
Ly
)
bgl
.
glEnd
()
if
not
S
un
.
ShowRiseSet
or
not
Map
.
lineWidth
:
if
not
s
un
.
ShowRiseSet
or
not
Map
.
lineWidth
:
bgl
.
glDisable
(
bgl
.
GL_LINES
)
bgl
.
glFlush
()
return
...
...
@@ -1159,14 +1176,14 @@ def Draw_map_callback(self, context):
py
=
Ly
+
latitude
radius
=
30
+
Map
.
lineWidth
*
10
if
S
un
.
RiseSetOK
and
Map
.
lineWidth
:
if
s
un
.
RiseSetOK
and
Map
.
lineWidth
:
color
=
(
0.2
,
0.6
,
1.0
,
0.9
)
angle
=
-
(
degToRad
(
S
un
.
S
unrise
.
azimuth
)
-
math
.
pi
/
2
)
angle
=
-
(
radians
(
s
un
.
s
unrise
.
azimuth
)
-
math
.
pi
/
2
)
bgl
.
glLineWidth
(
Map
.
lineWidth
)
draw_angled_line
(
color
,
angle
,
px
,
py
)
color
=
(
0.86
,
0.18
,
0.18
,
0.9
)
angle
=
-
(
degToRad
(
S
un
.
S
unset
.
azimuth
)
-
math
.
pi
/
2
)
angle
=
-
(
radians
(
s
un
.
s
unset
.
azimuth
)
-
math
.
pi
/
2
)
draw_angled_line
(
color
,
angle
,
px
,
py
)
# ------------------------
...
...
@@ -1174,18 +1191,18 @@ def Draw_map_callback(self, context):
# ------------------------
if
Map
.
textureless
:
phi
=
degToRad
(
S
un
.
AzNorth
)
*
-
1
phi
=
radians
(
s
un
.
AzNorth
)
*
-
1
else
:
phi
=
degToRad
(
S
un
.
Azimuth
)
*
-
1
x
=
math
.
sin
(
phi
)
*
math
.
sin
(
-
S
un
.
Theta
)
*
(
radius
+
10
)
y
=
math
.
sin
(
S
un
.
Theta
)
*
math
.
cos
(
phi
)
*
(
radius
+
10
)
phi
=
radians
(
s
un
.
Azimuth
)
*
-
1
x
=
math
.
sin
(
phi
)
*
math
.
sin
(
-
s
un
.
Theta
)
*
(
radius
+
10
)
y
=
math
.
sin
(
s
un
.
Theta
)
*
math
.
cos
(
phi
)
*
(
radius
+
10
)
night
=
(
0.24
,
0.29
,
0.94
,
0.9
)
day
=
(
0.85
,
0.77
,
0.60
,
0.9
)
if
S
un
.
SolarNoon
.
elevation
<
0.0
:
if
s
un
.
SolarNoon
.
elevation
<
0.0
:
color
=
night
elif
S
un
.
Elevation
>=
S
un
.
Sunrise
.
elevation
:
if
S
un
.
Time
>=
S
un
.
Sunset
.
time
and
\
S
un
.
Elevation
<=
S
un
.
Sunset
.
elevation
:
elif
s
un
.
Elevation
>=
s
un
.
Sunrise
.
elevation
:
if
s
un
.
Time
>=
s
un
.
Sunset
.
time
and
\
s
un
.
Elevation
<=
s
un
.
Sunset
.
elevation
:
color
=
night
else
:
color
=
day
...
...
sun_position/north.py
View file @
ca85dbc7
### 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 #####
import
bpy
import
bgl
import
math
import
gpu
from
gpu_extras.batch
import
batch_for_shader
from
mathutils
import
Vector
from
.shader
import
Dashed_Shader_3D
from
.
properties
import
Sun
dashedLineShader
=
gpu
.
types
.
GPUShader
(
Dashed_Shader_3D
.
vertex_shader
,
Dashed_Shader_3D
.
fragment_shader
)
class
NorthClass
:
def
__init__
(
self
):
self
.
handler
=
None
self
.
isActive
=
False
def
refresh_screen
(
self
):
#bpy.context.scene.cursor.location.x += 0.0
bpy
.
context
.
area
.
tag_redraw
()
def
activate
(
self
,
context
):
if
context
.
area
.
type
==
'PROPERTIES'
:
self
.
handler
=
bpy
.
types
.
SpaceView3D
.
draw_handler_add
(
DrawNorth_callback
,
#(self, context), 'WINDOW', 'POST_PIXEL') # why changed?
(
self
,
context
),
'WINDOW'
,
'POST_VIEW'
)
self
.
isActive
=
True
self
.
refresh_screen
()
return
True
return
False
def
deactivate
(
self
):
if
self
.
handler
is
not
None
:
bpy
.
types
.
SpaceView3D
.
draw_handler_remove
(
self
.
handler
,
'WINDOW'
)
self
.
handler
=
None
self
.
isActive
=
False
self
.
refresh_screen
()
#if Sun.SP: # why removed?
Sun
.
SP
.
ShowNorth
=
False
# indent?
Sun
.
ShowNorth
=
False