Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
f6255e3f
Commit
f6255e3f
authored
13 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
updated scatter script for 2.5x
parent
c556bd0b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
object_grease_scatter.py
+17
-22
17 additions, 22 deletions
object_grease_scatter.py
with
17 additions
and
22 deletions
object_grease_scatter.py
+
17
−
22
View file @
f6255e3f
...
...
@@ -21,7 +21,7 @@
# Script copyright (C) Campbell Barton
bl_info
=
{
"
name
"
:
"
Export Camera Animation
"
,
"
name
"
:
"
Grease Scatter Objects
"
,
"
author
"
:
"
Campbell Barton
"
,
"
version
"
:
(
0
,
1
),
"
blender
"
:
(
2
,
5
,
8
),
...
...
@@ -36,7 +36,7 @@ bl_info = {
"
support
"
:
'
OFFICIAL
'
,
"
category
"
:
"
Object
"
}
from
mathutils
import
Vector
,
Rotation
Matrix
,
Quaternion
from
mathutils
import
Vector
,
Matrix
,
Quaternion
from
math
import
radians
from
random
import
uniform
,
shuffle
import
bpy
...
...
@@ -54,12 +54,12 @@ def _main(self, DENSITY=1.0, SCALE=0.6, RAND_LOC=0.8, RAND_ALIGN=0.75):
WALL_LIMIT
=
radians
(
45.0
)
mats
=
[
Rotation
Matrix
(
radians
(
-
45
),
3
,
'
X
'
),
Rotation
Matrix
(
radians
(
45
),
3
,
'
X
'
),
Rotation
Matrix
(
radians
(
-
45
),
3
,
'
Y
'
),
Rotation
Matrix
(
radians
(
45
),
3
,
'
Y
'
),
Rotation
Matrix
(
radians
(
-
45
),
3
,
'
Z
'
),
Rotation
Matrix
(
radians
(
45
),
3
,
'
Z
'
)]
Matrix
.
Rotation
(
radians
(
-
45
),
3
,
'
X
'
),
Matrix
.
Rotation
(
radians
(
45
),
3
,
'
X
'
),
Matrix
.
Rotation
(
radians
(
-
45
),
3
,
'
Y
'
),
Matrix
.
Rotation
(
radians
(
45
),
3
,
'
Y
'
),
Matrix
.
Rotation
(
radians
(
-
45
),
3
,
'
Z
'
),
Matrix
.
Rotation
(
radians
(
45
),
3
,
'
Z
'
)]
Z_UP
=
Vector
((
0
,
0
,
1.0
))
...
...
@@ -142,12 +142,8 @@ def _main(self, DENSITY=1.0, SCALE=0.6, RAND_LOC=0.8, RAND_ALIGN=0.75):
return
[
fix_point
(
point
.
co
)
for
point
in
stroke
.
points
]
def
get_splines
(
gp
):
l
=
None
for
l
in
gp
.
layers
:
if
l
.
active
:
# XXX - should be layers.active
break
if
l
:
frame
=
l
.
active_frame
if
gp
.
layers
.
active
:
frame
=
gp
.
layers
.
active
.
active_frame
return
[
get_points
(
stroke
)
for
stroke
in
frame
.
strokes
]
else
:
return
[]
...
...
@@ -185,11 +181,11 @@ def _main(self, DENSITY=1.0, SCALE=0.6, RAND_LOC=0.8, RAND_ALIGN=0.75):
pofs
=
p
+
n
*
0.01
n_seek
=
n
*
SEEK
m_alt_1
=
Rotation
Matrix
(
radians
(
22.5
),
3
,
n
)
m_alt_2
=
Rotation
Matrix
(
radians
(
-
22.5
),
3
,
n
)
m_alt_1
=
Matrix
.
Rotation
(
radians
(
22.5
),
3
,
n
)
m_alt_2
=
Matrix
.
Rotation
(
radians
(
-
22.5
),
3
,
n
)
for
_m
in
mats
:
for
m
in
(
_m
,
m_alt_1
*
_m
,
m_alt_2
*
_m
):
hit
,
nor
,
ind
=
ray
(
pofs
,
pofs
+
(
m
*
n_seek
))
hit
,
nor
,
ind
=
ray
(
pofs
,
pofs
+
(
n_seek
*
m
))
if
ind
!=
-
1
:
dist
=
(
pofs
-
hit
).
length
if
dist
<
best_dist
:
...
...
@@ -329,7 +325,7 @@ def _main(self, DENSITY=1.0, SCALE=0.6, RAND_LOC=0.8, RAND_ALIGN=0.75):
# make 2 angles and blend
angle
=
radians
(
uniform
(
-
180
,
180.0
))
angle_aligned
=
-
(
ori
.
angle
(
quat
*
Vector
((
0
,
1
,
0
)),
radians
(
180.0
)))
angle_aligned
=
-
(
ori
.
angle
(
Vector
((
0
,
1
,
0
))
*
quat
,
radians
(
180.0
)))
quat
=
Quaternion
(
no
,
(
angle
*
(
1.0
-
RAND_ALIGN
))
+
(
angle_aligned
*
RAND_ALIGN
)).
cross
(
quat
)
...
...
@@ -390,7 +386,7 @@ class Scatter(bpy.types.Operator):
return
{
'
FINISHED
'
}
def
invoke
(
self
,
context
,
event
):
wm
=
context
.
manager
wm
=
context
.
window_
manager
wm
.
invoke_popup
(
self
,
width
=
180
)
return
{
'
RUNNING_MODAL
'
}
...
...
@@ -407,7 +403,6 @@ class Scatter(bpy.types.Operator):
layout
.
operator_context
=
'
EXEC_DEFAULT
'
props
=
layout
.
operator
(
self
.
bl_idname
)
return
{
'
RUNNING_MODAL
'
}
# Add to the menu
...
...
@@ -415,11 +410,11 @@ menu_func = (lambda self, context: self.layout.operator(Scatter.bl_idname,
text
=
"
Scatter
"
,
icon
=
'
AUTO
'
))
def
register
():
bpy
.
type
s
.
register
(
Scatter
)
bpy
.
util
s
.
register
_class
(
Scatter
)
bpy
.
types
.
VIEW3D_PT_tools_objectmode
.
append
(
menu_func
)
def
unregister
():
bpy
.
type
s
.
unregister
(
Scatter
)
bpy
.
util
s
.
unregister
_class
(
Scatter
)
bpy
.
types
.
VIEW3D_PT_tools_objectmode
.
remove
(
menu_func
)
#if __name__ == "__main__":
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment