Minor changes.
This commit is contained in:
17
Trial.py
17
Trial.py
@@ -3,11 +3,10 @@ import bpy;
|
|||||||
import random;
|
import random;
|
||||||
|
|
||||||
# Variables:
|
# Variables:
|
||||||
|
# Size of each cube.
|
||||||
size = 1; # Size of each cube.
|
size = 1;
|
||||||
|
# Setting the x, y, and z positions.
|
||||||
x = y = z = size / 2; # Setting the x, y, and z positions.
|
x = y = z = size / 2;
|
||||||
|
|
||||||
|
|
||||||
#Function to clean the scene. This removes all of the objects, collections, materials, particles, textures, images, curves, meshes, actions, nodes, and worlds from the scene.
|
#Function to clean the scene. This removes all of the objects, collections, materials, particles, textures, images, curves, meshes, actions, nodes, and worlds from the scene.
|
||||||
def cleanScene():
|
def cleanScene():
|
||||||
@@ -25,8 +24,9 @@ def cleanScene():
|
|||||||
bpy.ops.object.select_all(action = "SELECT");
|
bpy.ops.object.select_all(action = "SELECT");
|
||||||
bpy.ops.object.delete();
|
bpy.ops.object.delete();
|
||||||
|
|
||||||
# Iterate over each grid 'cell' we want a cube at.
|
# Function to spawn the "ground" by creating several cubes using a nested for loop.
|
||||||
def spawnGround():
|
def spawnGround():
|
||||||
|
# Iterate over each grid "cell" we want a cube at.
|
||||||
for x in range(20):
|
for x in range(20):
|
||||||
for y in range(20):
|
for y in range(20):
|
||||||
for z in range(1):
|
for z in range(1):
|
||||||
@@ -34,7 +34,7 @@ def spawnGround():
|
|||||||
location = (x, y, z);
|
location = (x, y, z);
|
||||||
|
|
||||||
# Add the cubes.
|
# Add the cubes.
|
||||||
bpy.ops.mesh.primitive_cube_add(size = size, location=location, scale=(1, 1, 1));
|
bpy.ops.mesh.primitive_cube_add(size = size, location = location, scale = (1, 1, 1));
|
||||||
# Set the newly created cube as the active object.
|
# Set the newly created cube as the active object.
|
||||||
activeObject = bpy.context.active_object;
|
activeObject = bpy.context.active_object;
|
||||||
# Add a new material slot.
|
# Add a new material slot.
|
||||||
@@ -50,7 +50,7 @@ def spawnGround():
|
|||||||
# Change the base colour.
|
# Change the base colour.
|
||||||
materialNodes['Principled BSDF'].inputs['Base Color'].default_value = (1.0, 0.47, 1.0, 1.0);
|
materialNodes['Principled BSDF'].inputs['Base Color'].default_value = (1.0, 0.47, 1.0, 1.0);
|
||||||
|
|
||||||
# Calls the functions:
|
# Calling the functions:
|
||||||
cleanScene();
|
cleanScene();
|
||||||
spawnGround();
|
spawnGround();
|
||||||
|
|
||||||
@@ -60,4 +60,5 @@ spawnGround();
|
|||||||
# - y is for creating cubes in the y axis.
|
# - y is for creating cubes in the y axis.
|
||||||
# - z is for creating cubes in the z axis.
|
# - z is for creating cubes in the z axis.
|
||||||
# - I need to add the materials to the cubes and somehow save it in the Blender program.
|
# - I need to add the materials to the cubes and somehow save it in the Blender program.
|
||||||
|
# - I need to replace the nested for loop with a recursive function to spawn the ground.
|
||||||
# - I need to add a function to create a tree in a random position. This function will create cubes and put them in a way to look like a tree. It will also assign the correct materials to their proper cubes.
|
# - I need to add a function to create a tree in a random position. This function will create cubes and put them in a way to look like a tree. It will also assign the correct materials to their proper cubes.
|
Reference in New Issue
Block a user