Some little changes including ini and blend files.

This commit is contained in:
CJSatnarine
2023-05-09 12:08:51 -04:00
parent c99188b89b
commit d07ca6bb7d
3 changed files with 14 additions and 9 deletions

BIN
BlenderWorldGenerator.blend Normal file

Binary file not shown.

View File

@@ -1,7 +1,6 @@
#Imports. #Imports.
import bpy; import bpy;
import bmesh; import bmesh;
import random;
# Variables: # Variables:
# Size of each cube. # Size of each cube.
@@ -62,10 +61,13 @@ def spawnGround():
materialNodes = material.node_tree.nodes; materialNodes = material.node_tree.nodes;
materialLinks = material.node_tree.links; materialLinks = material.node_tree.links;
# Add the material.
activeObject.data.materials.append(material);
# Selecting each face and then assigning the material to that face. # Selecting each face and then assigning the material to that face.
for i in range(6): for i in range(6):
# Checks if the object is currently in edit mode, and if not, sets it into edit mode. # Checks if the object is currently in edit mode, and if not, sets it into edit mode.
if (bpy.context.active_object.mode == "OBJECT"): if (bpy.context.active_object.mode != "EDIT"):
bpy.ops.object.editmode_toggle(); bpy.ops.object.editmode_toggle();
bm = bmesh.from_edit_mesh(activeObject.data); bm = bmesh.from_edit_mesh(activeObject.data);
@@ -80,16 +82,17 @@ def spawnGround():
bmesh.update_edit_mesh(activeObject.data); bmesh.update_edit_mesh(activeObject.data);
print('Face ', i, ' grabbed'); print('Face ', i, ' grabbed');
# Appened the material to the face.
# bpy.ops.object.material_slot_assign({'object': activeObject});
# bpy.ops.transform.translate(value=(0.169302, 0, 0), orient_axis_ortho='X', orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), mirror=False, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False, snap=False, snap_elements={'INCREMENT'}, use_snap_project=False, snap_target='CLOSEST', use_snap_self=True, use_snap_edit=True, use_snap_nonedit=True, use_snap_selectable=False);
# Deselect the faces. # Deselect the faces.
bm.faces[i].select = False; bm.faces[i].select = False;
print('Face ', i, ' released'); print('Face ', i, ' released');
# Add the material.
activeObject.data.materials.append(material);
# Change the texture of the cube. # Change the texture of the cube.
textureImage = material.node_tree.nodes.new('ShaderNodeTexImage'); textureImage = material.node_tree.nodes.new('ShaderNodeTexImage');
textureImage.image = bpy.data.images.load("C:\\Users\\satna\\OneDrive\\Desktop\\Programming\\Python\\Blender\\Blender-World-Generator\\DirtBlock.png"); textureImage.image = bpy.data.images.load("C://Users//satna//OneDrive//Desktop/Programming//Python//Blender//Blender-World-Generator//DirtBlock.png");
material.node_tree.links.new(BSDF.inputs['Base Color'], textureImage.outputs['Color']); material.node_tree.links.new(BSDF.inputs['Base Color'], textureImage.outputs['Color']);
# Assign the texture to the object. # Assign the texture to the object.
@@ -98,7 +101,7 @@ def spawnGround():
else: else:
activeObjectViewLayer.data.materials.append(material); activeObjectViewLayer.data.materials.append(material);
# Calling the functions: # Calling the functions:
cleanScene(); cleanScene();
spawnGround(); spawnGround();
print('Code has run.');

2
config.ini Normal file
View File

@@ -0,0 +1,2 @@
[Paths]
Texture = "C://Users//satna//OneDrive//Desktop/Programming//Python//Blender//Blender-World-Generator//DirtBlock.png"