Spawn leaves properly
This commit is contained in:
@@ -54,6 +54,12 @@ def buildTree():
|
|||||||
treeZPos = z
|
treeZPos = z
|
||||||
treeTrunkHeight = random.randint(3, 5)
|
treeTrunkHeight = random.randint(3, 5)
|
||||||
|
|
||||||
|
# Variables for the leaves
|
||||||
|
leavesSize = (size * treeTrunkHeight) / 2
|
||||||
|
leavesXPosition = treeXPos
|
||||||
|
leavesYPosition = treeYPos
|
||||||
|
leavesZPosition = treeTrunkHeight + leavesSize
|
||||||
|
|
||||||
# Add a single block as the location of the tree stump.
|
# Add a single block as the location of the tree stump.
|
||||||
# Loop through the treeheight to add a new cube as a chunk of the trunk. Add colour to the trunk.
|
# Loop through the treeheight to add a new cube as a chunk of the trunk. Add colour to the trunk.
|
||||||
counter = 1
|
counter = 1
|
||||||
@@ -70,9 +76,16 @@ def buildTree():
|
|||||||
# increase the counter
|
# increase the counter
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
|
# Create the leaves of the tree.
|
||||||
|
createLowPolyLeaves(leavesSize, leavesXPosition, leavesYPosition, leavesZPosition)
|
||||||
|
|
||||||
# Function to make the low poly leaves for the tree.
|
# Function to make the low poly leaves for the tree.
|
||||||
def createLowPolyLeaves(size, xPosition, yPosition, zPosition):
|
def createLowPolyLeaves(size, xPosition, yPosition, zPosition):
|
||||||
bpy.ops.mesh.primitive_cube_add(size = size, location = (xPosition, yPosition, zPosition))
|
lowPolyLeaves = bpy.ops.mesh.primitive_cube_add(size = size, location = (xPosition, yPosition, zPosition), scale = (size, size, size))
|
||||||
|
activeObject = bpy.context.active_object
|
||||||
|
colourOfLeaves = createMaterial(0.007951, 0.349087, 0.0003, 1)
|
||||||
|
assignMaterial(lowPolyLeaves, colourOfLeaves)
|
||||||
|
return activeObject
|
||||||
|
|
||||||
# Function to add a material to the selected object.
|
# Function to add a material to the selected object.
|
||||||
def assignMaterial(object, material):
|
def assignMaterial(object, material):
|
||||||
|
Reference in New Issue
Block a user