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
29a11b10
Commit
29a11b10
authored
13 years ago
by
Andrew Hale
Browse files
Options
Downloads
Patches
Plain Diff
Added the ability to use rectangular leaves with UV mapping
parent
173e9d32
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
add_curve_sapling/__init__.py
+11
-5
11 additions, 5 deletions
add_curve_sapling/__init__.py
add_curve_sapling/utils.py
+18
-7
18 additions, 7 deletions
add_curve_sapling/utils.py
with
29 additions
and
12 deletions
add_curve_sapling/__init__.py
+
11
−
5
View file @
29a11b10
...
...
@@ -19,9 +19,9 @@
bl_info
=
{
"
name
"
:
"
Sapling
"
,
"
author
"
:
"
Andrew Hale (TrumanBlending)
"
,
"
version
"
:
(
0
,
2
,
3
),
"
version
"
:
(
0
,
2
,
4
),
"
blender
"
:
(
2
,
5
,
8
),
"
api
"
:
38
28
9
,
"
api
"
:
38
47
9
,
"
location
"
:
"
View3D > Add > Curve
"
,
"
description
"
:
(
"
Adds a parametric tree. The method is presented by
"
"
Jason Weber & Joseph Penn in their paper
'
Creation and Rendering of
"
...
...
@@ -29,8 +29,8 @@ bl_info = {
"
warning
"
:
""
,
# used for warning icon and text in addons panel
"
wiki_url
"
:
"
http://wiki.blender.org/index.php/Extensions:2.5/Py/
"
\
"
Scripts/Curve/Sapling_Tree
"
,
"
tracker_url
"
:
"
http://projects.blender.org/tracker/
index.php?
"
\
"
func=detail&aid=27226&group_id=153
&atid=468
"
,
"
tracker_url
"
:
"
http://projects.blender.org/tracker/
"
\
"
?
func=detail&
atid=469&
aid=27226&group_id=153
"
,
"
category
"
:
"
Add Curve
"
}
if
"
bpy
"
in
locals
():
...
...
@@ -327,6 +327,10 @@ class AddTree(bpy.types.Operator):
'
(LeafScaleX)
'
),
min
=
0.0
,
default
=
1.0
)
leafShape
=
leafDist
=
EnumProperty
(
name
=
'
Leaf Shape
'
,
description
=
'
The shape of the leaves, rectangular are UV mapped
'
,
items
=
((
'
hex
'
,
'
Hexagonal
'
,
'
0
'
),
(
'
rect
'
,
'
Rectangular
'
,
'
1
'
)),
default
=
'
hex
'
)
bend
=
FloatProperty
(
name
=
'
Leaf Bend
'
,
description
=
'
The proportion of bending applied to the leaf (Bend)
'
,
min
=
0.0
,
...
...
@@ -523,6 +527,8 @@ class AddTree(bpy.types.Operator):
row
=
box
.
row
()
row
.
prop
(
self
,
'
showLeaves
'
)
row
=
box
.
row
()
row
.
prop
(
self
,
'
leafShape
'
)
row
=
box
.
row
()
row
.
prop
(
self
,
'
leaves
'
)
row
=
box
.
row
()
row
.
prop
(
self
,
'
leafDist
'
)
...
...
@@ -586,4 +592,4 @@ def unregister():
bpy
.
types
.
INFO_MT_curve_add
.
remove
(
menu_func
)
if
__name__
==
"
__main__
"
:
register
()
register
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
add_curve_sapling/utils.py
+
18
−
7
View file @
29a11b10
...
...
@@ -313,10 +313,15 @@ def growSpline(stem,numSplit,splitAng,splitAngV,splineList,attractUp,hType,splin
stem
.
updateEnd
()
#return splineList
def
genLeafMesh
(
leafScale
,
leafScaleX
,
loc
,
quat
,
index
,
downAngle
,
downAngleV
,
rotate
,
rotateV
,
oldRot
,
bend
,
leaves
):
verts
=
[
Vector
((
0
,
0
,
0
)),
Vector
((
0.5
,
0
,
1
/
3
)),
Vector
((
0.5
,
0
,
2
/
3
)),
Vector
((
0
,
0
,
1
)),
Vector
((
-
0.5
,
0
,
2
/
3
)),
Vector
((
-
0.5
,
0
,
1
/
3
))]
edges
=
[[
0
,
1
],[
1
,
2
],[
2
,
3
],[
3
,
4
],[
4
,
5
],[
5
,
0
],[
0
,
3
]]
faces
=
[[
0
,
1
,
2
,
3
],[
0
,
3
,
4
,
5
]]
def
genLeafMesh
(
leafScale
,
leafScaleX
,
loc
,
quat
,
index
,
downAngle
,
downAngleV
,
rotate
,
rotateV
,
oldRot
,
bend
,
leaves
,
leafShape
):
if
leafShape
==
'
hex
'
:
verts
=
[
Vector
((
0
,
0
,
0
)),
Vector
((
0.5
,
0
,
1
/
3
)),
Vector
((
0.5
,
0
,
2
/
3
)),
Vector
((
0
,
0
,
1
)),
Vector
((
-
0.5
,
0
,
2
/
3
)),
Vector
((
-
0.5
,
0
,
1
/
3
))]
edges
=
[[
0
,
1
],[
1
,
2
],[
2
,
3
],[
3
,
4
],[
4
,
5
],[
5
,
0
],[
0
,
3
]]
faces
=
[[
0
,
1
,
2
,
3
],[
0
,
3
,
4
,
5
]]
elif
leafShape
==
'
rect
'
:
verts
=
[
Vector
((
1
,
0
,
0
)),
Vector
((
1
,
0
,
1
)),
Vector
((
-
1
,
0
,
1
)),
Vector
((
-
1
,
0
,
0
))]
edges
=
[[
0
,
1
],[
1
,
2
],[
2
,
3
],[
3
,
0
]]
faces
=
[[
0
,
1
,
2
,
3
],]
#faces = [[0,1,5],[1,2,4,5],[2,3,4]]
vertsList
=
[]
...
...
@@ -429,6 +434,7 @@ def addTree(props):
pruneRatio
=
props
.
pruneRatio
#
leafScale
=
props
.
leafScale
#
leafScaleX
=
props
.
leafScaleX
#
leafShape
=
props
.
leafShape
bend
=
props
.
bend
#
leafDist
=
int
(
props
.
leafDist
)
#
bevelRes
=
props
.
bevelRes
#
...
...
@@ -732,12 +738,12 @@ def addTree(props):
if
leaves
<
0
:
oldRot
=
-
rotate
[
n
]
/
2
for
g
in
range
(
abs
(
leaves
)):
(
vertTemp
,
faceTemp
,
oldRot
)
=
genLeafMesh
(
leafScale
,
leafScaleX
,
cp
.
co
,
cp
.
quat
,
len
(
leafVerts
),
downAngle
[
n
],
downAngleV
[
n
],
rotate
[
n
],
rotateV
[
n
],
oldRot
,
bend
,
leaves
)
(
vertTemp
,
faceTemp
,
oldRot
)
=
genLeafMesh
(
leafScale
,
leafScaleX
,
cp
.
co
,
cp
.
quat
,
len
(
leafVerts
),
downAngle
[
n
],
downAngleV
[
n
],
rotate
[
n
],
rotateV
[
n
],
oldRot
,
bend
,
leaves
,
leafShape
)
leafVerts
.
extend
(
vertTemp
)
leafFaces
.
extend
(
faceTemp
)
# Otherwise just add the leaves like splines.
else
:
(
vertTemp
,
faceTemp
,
oldRot
)
=
genLeafMesh
(
leafScale
,
leafScaleX
,
cp
.
co
,
cp
.
quat
,
len
(
leafVerts
),
downAngle
[
n
],
downAngleV
[
n
],
rotate
[
n
],
rotateV
[
n
],
oldRot
,
bend
,
leaves
)
(
vertTemp
,
faceTemp
,
oldRot
)
=
genLeafMesh
(
leafScale
,
leafScaleX
,
cp
.
co
,
cp
.
quat
,
len
(
leafVerts
),
downAngle
[
n
],
downAngleV
[
n
],
rotate
[
n
],
rotateV
[
n
],
oldRot
,
bend
,
leaves
,
leafShape
)
leafVerts
.
extend
(
vertTemp
)
leafFaces
.
extend
(
faceTemp
)
# Create the leaf mesh and object, add geometry using from_pydata, edges are currently added by validating the mesh which isn't great
...
...
@@ -747,6 +753,11 @@ def addTree(props):
leafObj
.
parent
=
treeOb
leafMesh
.
from_pydata
(
leafVerts
,(),
leafFaces
)
leafMesh
.
validate
()
if
leafShape
==
'
rect
'
:
uv
=
leafMesh
.
uv_textures
.
new
(
"
leafUV
"
)
for
tf
in
uv
.
data
:
tf
.
uv1
,
tf
.
uv2
,
tf
.
uv3
,
tf
.
uv4
=
Vector
((
1
,
0
)),
Vector
((
1
,
1
)),
Vector
((
1
-
leafScaleX
,
1
)),
Vector
((
1
-
leafScaleX
,
0
))
# This can be used if we need particle leaves
# if (storeN == levels-1) and leaves:
...
...
@@ -904,4 +915,4 @@ def addTree(props):
for
p
in
armOb
.
pose
.
bones
:
p
.
rotation_mode
=
'
XYZ
'
treeOb
.
parent
=
armOb
#print(time.time()-startTime)
#print(time.time()-startTime)
\ No newline at end of file
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