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
3de74ea5
Commit
3de74ea5
authored
12 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
add functions for scene setup
parent
d77e9af6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
object_fracture_voroni/fracture_cell_calc.py
+0
-0
0 additions, 0 deletions
object_fracture_voroni/fracture_cell_calc.py
object_fracture_voroni/fracture_cell_setup.py
+108
-0
108 additions, 0 deletions
object_fracture_voroni/fracture_cell_setup.py
with
108 additions
and
0 deletions
object_fracture_voroni/
cell_
fracture.py
→
object_fracture_voroni/fracture
_cell_calc
.py
+
0
−
0
View file @
3de74ea5
File moved
This diff is collapsed.
Click to expand it.
object_fracture_voroni/fracture_cell_setup.py
0 → 100644
+
108
−
0
View file @
3de74ea5
# ##### 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 #####
# <pep8 compliant>
# Script copyright (C) Blender Foundation 2012
def
cell_fracture_objects
(
context
,
obj
,
method
=
{
'
OTHER
'
}):
#assert(method in {'OTHER', 'PARTICLES'})
from
.
import
fracture_cell_calc
points
=
[]
if
'
PARTICLES
'
in
method
:
points
.
extend
([
p
.
location
.
copy
()
for
psys
in
obj
.
particle_systems
for
p
in
psys
.
particles
])
if
'
OTHER
'
in
method
:
for
obj_other
in
context
.
selected_objects
:
if
obj_other
.
type
==
'
MESH
'
:
mesh
=
obj_other
.
data
matrix
=
obj_other
.
matrix_world
.
copy
()
points
.
extend
([
matrix
*
v
.
co
for
v
in
mesh
.
vertices
])
mesh
=
obj
.
data
matrix
=
obj
.
matrix_world
.
copy
()
verts
=
[
matrix
*
v
.
co
for
v
in
mesh
.
vertices
]
cells
=
fracture_cell_calc
.
points_as_bmesh_cells
(
verts
,
points
)
# some hacks here :S
import
bmesh
scene
=
context
.
scene
cell_name
=
obj
.
name
+
"
_cell
"
objects
=
[]
for
center_point
,
cell_points
in
cells
:
mesh
=
bpy
.
data
.
meshes
.
new
(
name
=
cell_name
)
obj_cell
=
bpy
.
data
.
objects
.
new
(
name
=
cell_name
,
object_data
=
mesh
)
scene
.
objects
.
link
(
obj_cell
)
# scene.objects.active = obj_cell
obj_cell
.
location
=
center_point
# create the convex hulls
bm
=
bmesh
.
new
()
for
i
,
co
in
enumerate
(
cell_points
):
bm_vert
=
bm
.
verts
.
new
(
co
)
bm_vert
.
tag
=
True
import
mathutils
bm
.
transform
(
mathutils
.
Matrix
.
Translation
((
+
100.0
,
+
100.0
,
+
100.0
)))
# BUG IN BLENDER
bmesh
.
ops
.
remove_doubles
(
bm
,
{
'
TAG
'
},
0.0001
)
bmesh
.
ops
.
convex_hull
(
bm
,
{
'
TAG
'
})
bm
.
transform
(
mathutils
.
Matrix
.
Translation
((
-
100.0
,
-
100.0
,
-
100.0
)))
# BUG IN BLENDER
bm
.
to_mesh
(
me
)
bm
.
free
()
objects
.
append
(
obj_cell
)
return
obj_cell
def
cell_fracture_boolean
(
context
,
obj
,
objects
):
scene
=
context
.
scene
for
obj_cell
in
objects
:
mod
=
obj_cell
.
modifiers
.
new
(
type
=
'
BOOLEAN
'
)
mod
.
object
=
boolobj
mod
.
operation
=
'
INTERSECT
'
mesh_new
=
obj_cell
.
to_mesh
(
scene
,
apply_modifiers
=
True
)
mesh_old
=
obj_cell
.
data
obj_cell
.
data
=
mesh_new
# remove if not valid
if
not
mesh_old
.
users
:
bpy
.
data
.
meshes
.
remove
(
mesh_old
)
if
not
mesh_new
.
verts
:
scene
.
objects
.
unlink
(
obj_cell
)
if
not
obj_cell
.
users
:
bpy
.
data
.
objects
.
remove
(
obj_cell
)
if
not
mesh_new
.
users
:
bpy
.
data
.
meshes
.
remove
(
mesh_old
)
obj_cell
.
select
=
True
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