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
d5d773b7
Commit
d5d773b7
authored
15 years ago
by
Martin Buerbaum
Browse files
Options
Downloads
Patches
Plain Diff
* Added ngon_fill() function to quickly generate "good" quad geometry for even®ular ngons.
parent
87d65a47
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
add_mesh_archimedean_solids.py
+43
-29
43 additions, 29 deletions
add_mesh_archimedean_solids.py
with
43 additions
and
29 deletions
add_mesh_archimedean_solids.py
+
43
−
29
View file @
d5d773b7
...
@@ -229,6 +229,30 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
...
@@ -229,6 +229,30 @@ def createFaces(vertIdx1, vertIdx2, closed=False, flipped=False):
########################
########################
# Converts regular ngons to quads
# Note: Exists because most "fill" functions can not be
# controlled as easily.
def
ngon_fill
(
ngon
,
offset
=
0
):
if
offset
:
ngon
=
ngon
[
1
:]
+
[
ngon
[
0
]]
if
len
(
ngon
)
==
6
:
# Hexagon
return
[
[
ngon
[
0
],
ngon
[
1
],
ngon
[
2
],
ngon
[
3
]],
[
ngon
[
0
],
ngon
[
3
],
ngon
[
4
],
ngon
[
5
]]]
elif
len
(
ngon
)
==
8
:
# Octagon
return
[
[
ngon
[
0
],
ngon
[
1
],
ngon
[
2
],
ngon
[
3
]],
[
ngon
[
0
],
ngon
[
3
],
ngon
[
4
],
ngon
[
7
]],
[
ngon
[
7
],
ngon
[
4
],
ngon
[
5
],
ngon
[
6
]]]
else
:
return
None
# Not supported (yet)
# Returns the middle location of a _regular_ polygon.
# Returns the middle location of a _regular_ polygon.
# verts ... List of vertex coordinates (Vector) used by the ngon.
# verts ... List of vertex coordinates (Vector) used by the ngon.
# ngon ... List of ngones (vertex indices of each ngon point)
# ngon ... List of ngones (vertex indices of each ngon point)
...
@@ -344,22 +368,14 @@ def add_truncated_tetrahedron(hexagon_side=2.0 * sqrt(2.0) / 3.0,
...
@@ -344,22 +368,14 @@ def add_truncated_tetrahedron(hexagon_side=2.0 * sqrt(2.0) / 3.0,
else
:
else
:
# Create quads from hexagons
# Create quads from hexagons
(
quad1
,
quad2
)
=
(
hex_quads
=
ngon_fill
(
ngon012
)
[
ngon012
[
0
],
ngon012
[
1
],
ngon012
[
2
],
ngon012
[
3
]],
faces
.
extend
(
hex_quads
)
[
ngon012
[
0
],
ngon012
[
3
],
ngon012
[
4
],
ngon012
[
5
]])
hex_quads
=
ngon_fill
(
ngon031
)
faces
.
extend
([
quad1
,
quad2
])
faces
.
extend
(
hex_quads
)
(
quad1
,
quad2
)
=
(
hex_quads
=
ngon_fill
(
ngon023
)
[
ngon031
[
0
],
ngon031
[
1
],
ngon031
[
2
],
ngon031
[
3
]],
faces
.
extend
(
hex_quads
)
[
ngon031
[
0
],
ngon031
[
3
],
ngon031
[
4
],
ngon031
[
5
]])
hex_quads
=
ngon_fill
(
ngon132
)
faces
.
extend
([
quad1
,
quad2
])
faces
.
extend
(
hex_quads
)
(
quad1
,
quad2
)
=
(
[
ngon023
[
0
],
ngon023
[
1
],
ngon023
[
2
],
ngon023
[
3
]],
[
ngon023
[
0
],
ngon023
[
3
],
ngon023
[
4
],
ngon023
[
5
]])
faces
.
extend
([
quad1
,
quad2
])
(
quad1
,
quad2
)
=
(
[
ngon132
[
0
],
ngon132
[
1
],
ngon132
[
2
],
ngon132
[
3
]],
[
ngon132
[
0
],
ngon132
[
3
],
ngon132
[
4
],
ngon132
[
5
]])
faces
.
extend
([
quad1
,
quad2
])
# Invert face normals
# Invert face normals
tri1
=
[
tri1
[
0
]]
+
list
(
reversed
(
tri1
[
1
:]))
tri1
=
[
tri1
[
0
]]
+
list
(
reversed
(
tri1
[
1
:]))
...
@@ -563,27 +579,25 @@ def add_cuboctahedron(octagon_side=0.0, star_ngons=False):
...
@@ -563,27 +579,25 @@ def add_cuboctahedron(octagon_side=0.0, star_ngons=False):
faces
.
extend
([
tri_xp_yp_zp
,
tri_xp_yn_zp
,
tri_xn_yp_zp
,
tri_xn_yn_zp
])
faces
.
extend
([
tri_xp_yp_zp
,
tri_xp_yn_zp
,
tri_xn_yp_zp
,
tri_xn_yn_zp
])
faces
.
extend
([
tri_xp_yp_zn
,
tri_xp_yn_zn
,
tri_xn_yp_zn
,
tri_xn_yn_zn
])
faces
.
extend
([
tri_xp_yp_zn
,
tri_xp_yn_zn
,
tri_xn_yp_zn
,
tri_xn_yn_zn
])
# Offset vertices so QUADS are created with orthagonal edges.
# Superficial change - Could be omitted, especially for stars.
ngon_bot
=
ngon_bot
[
1
:]
+
[
ngon_bot
[
0
]]
ngon_0
=
ngon_0
[
1
:]
+
[
ngon_0
[
0
]]
ngon_1
=
ngon_1
[
1
:]
+
[
ngon_1
[
0
]]
ngon_2
=
ngon_2
[
1
:]
+
[
ngon_2
[
0
]]
ngon_3
=
ngon_3
[
1
:]
+
[
ngon_3
[
0
]]
ngons
=
[
ngon_top
,
ngon_bot
,
ngon_0
,
ngon_1
,
ngon_2
,
ngon_3
]
if
star_ngons
:
if
star_ngons
:
ngons
=
[
ngon_top
,
ngon_bot
,
ngon_0
,
ngon_1
,
ngon_2
,
ngon_3
]
# Create stars from octagons.
# Create stars from octagons.
verts
,
faces_star
=
get_polygon_center
(
verts
,
ngons
)
verts
,
faces_star
=
get_polygon_center
(
verts
,
ngons
)
faces
.
extend
(
faces_star
)
faces
.
extend
(
faces_star
)
else
:
else
:
# Create quads from octagons.
# Create quads from octagons.
# The octagon ont he top is the only polygon we don't need to offset.
oct_quads
=
ngon_fill
(
ngon_top
)
faces
.
extend
(
oct_quads
)
ngons
=
[
ngon_bot
,
ngon_0
,
ngon_1
,
ngon_2
,
ngon_3
]
for
ngon
in
ngons
:
for
ngon
in
ngons
:
faces
.
extend
([
# offset=1 Offset vertices so QUADS are created with orthagonal edges.
[
ngon
[
0
],
ngon
[
1
],
ngon
[
2
],
ngon
[
3
]],
# Superficial change - Could be omitted.
[
ngon
[
0
],
ngon
[
3
],
ngon
[
4
],
ngon
[
7
]],
oct_quads
=
ngon_fill
(
ngon
,
offset
=
1
)
[
ngon
[
7
],
ngon
[
4
],
ngon
[
5
],
ngon
[
6
]]]
)
faces
.
extend
(
oct_quads
)
return
verts
,
faces
,
name
return
verts
,
faces
,
name
...
...
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