1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
22 from collections
import namedtuple
24 from bpy
.props
import (
31 ScatterSettings
= namedtuple("ScatterSettings",
32 ["seed", "density", "radius", "scale", "random_scale",
33 "rotation", "normal_offset"])
35 class ObjectScatterProperties(bpy
.types
.PropertyGroup
):
39 description
="Change it to get a different scatter pattern",
42 density
: FloatProperty(
47 description
="The amount of objects per unit on the line",
50 radius
: FloatProperty(
57 description
="Maximum distance of the objects to the line",
65 description
="Size of the generated objects",
68 random_scale_percentage
: FloatProperty(
69 name
="Random Scale Percentage",
75 description
="Increase to get a larger range of sizes",
78 rotation
: FloatProperty(
86 description
="Maximum rotation of the generated objects",
89 normal_offset
: FloatProperty(
94 description
="Distance from the surface",
97 def to_settings(self
):
98 return ScatterSettings(
100 density
=self
.density
,
103 random_scale
=self
.random_scale_percentage
/ 100,
104 rotation
=self
.rotation
,
105 normal_offset
=self
.normal_offset
,
109 class ObjectScatterPanel(bpy
.types
.Panel
):
110 bl_idname
= "OBJECT_PT_object_scatter"
111 bl_label
= "Object Scatter"
112 bl_space_type
= 'VIEW_3D'
113 bl_region_type
= 'UI'
116 def draw(self
, context
):
118 layout
.use_property_split
= True
119 scatter
= context
.scene
.scatter_properties
121 layout
.prop(scatter
, "density", slider
=True)
122 layout
.prop(scatter
, "radius", slider
=True)
124 col
= layout
.column(align
=True)
125 col
.prop(scatter
, "scale", slider
=True)
126 col
.prop(scatter
, "random_scale_percentage", text
="Randomness", slider
=True)
128 layout
.prop(scatter
, "rotation", slider
=True)
129 layout
.prop(scatter
, "normal_offset", text
="Offset", slider
=True)
130 layout
.prop(scatter
, "seed")
134 ObjectScatterProperties
,
140 bpy
.utils
.register_class(cls
)
141 bpy
.types
.Scene
.scatter_properties
= PointerProperty(type=ObjectScatterProperties
)
145 bpy
.utils
.unregister_class(cls
)
146 del bpy
.types
.Scene
.scatter_properties