From 312a3ab22599871ccae7bfe814a9ceadef981dc7 Mon Sep 17 00:00:00 2001 From: CJSatnarine Date: Fri, 1 Sep 2023 12:36:38 -0400 Subject: [PATCH] Delete code relating to textures --- DirtBlock.png | Bin 3258 -> 0 bytes GenerateMitImage.py | 107 ------------------------------------------- ImageTextureTrial.py | 24 ---------- 3 files changed, 131 deletions(-) delete mode 100644 DirtBlock.png delete mode 100644 GenerateMitImage.py delete mode 100644 ImageTextureTrial.py diff --git a/DirtBlock.png b/DirtBlock.png deleted file mode 100644 index 222d5c5883d2c56313173101360d8542411f7400..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3258 zcmV;r3`O%&Nk&Gp3;+OEMM6+kP&go_3;+O-L;#%uDxd(M06q~0fm}&NA{cXKjnLn`px!l*MGlym+8x+yukTu{-^kF$ZvdK^8JE;ZvOM^ z0sc4o|F0iGAJx49{=I(G`_g~2|AGG3+=uqxP!IBd+&};OP=C1p@9uB?o75BdC;LzT z{<(j;U;qAC|Gj_X^q>F#+2z2I{Cn}&=V#Wucgg|ISK2Y+|CK-1KUIDj{!{rQ{5ST4 zmP`1*^Dk{5_4NNO4<|p3f3p64{HKrytk2@#>;Ja@J^gR%PycKDSMX2YaK(x-5F7ct z%24MvLWG^dZf+lCijlxDS33(VwOizk?roV;lm3$wfRUIqvCPv~wc0|-Z(BpK2 zl)m9yHAa|?mf-j$!y8edCR=a3k|Llnnan`}uDKev{0 ze^r=8Y<4;(MciXUj4P__+5Srg*QcyCjI^WP41t%dBn%K4$llo^gEZAkmo`+^x^|DD zs+wiHmxv&ZN@!J(3T&q>4+cl@ySXWbzH=J5t$l{g7a=P)*`6__Rwx;EBRdvI&zddc*39yk+6nl@wI@x;SNZ*t(cQDux6Ns2$D# zx8fe7;tnr>LhqY40Pv$LI8o|_=o&Y9s|}OFyTLb`@MSBL4^z~fa^+uuXB?BM+9Z1Z zeYsbmqI$Z`Ga_5##tLi76eI-x9Z!9*E?Q`YmS)mx5%&BUGD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Xka583DW8X0B*aCQIy09qq$G5`Po diff --git a/GenerateMitImage.py b/GenerateMitImage.py deleted file mode 100644 index 5464d7d..0000000 --- a/GenerateMitImage.py +++ /dev/null @@ -1,107 +0,0 @@ -#Imports. -import bpy; -import bmesh; - -# Variables: -# Size of each cube. -size = 1; -# Setting the x, y, and z positions. -x = y = z = size / 2; -# Setting the number of cubes in each coordinate. -xNum = 1; -yNum = 1; -zNum = 1; -# Setting the initial value for the number of cubes in each recursive call. -cubeCount = 0; -# Setting the maximum amount of cubes that is needed to be created. -numOfCubes = xNum * yNum * zNum; -# print(numOfCubes); - -#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(): - # Changes the mode to object mode if it is in Edit mode. - if (bpy.context.active_object and bpy.context.active_object.mode == "EDIT"): - bpy.ops.object.editmode_toggle(); - - # Checks for hidden stuff and unhides them. - for obj in bpy.data.objects: - obj.hide_set(False); - obj.hide_select = False; - obj.hide_viewport = False; - - # Selects all the objects and then deletes. - bpy.ops.object.select_all(action = "SELECT"); - bpy.ops.object.delete(); - -# Function to spawn the "ground" by creating several cubes using a nested for loop. -def spawnGround(): - # Iterate over each grid "cell" we want a cube at. - for x in range(xNum): - for y in range(yNum): - for z in range(zNum): - # Set the location. - location = (x, y, z); - - # Add the cubes. - bpy.ops.mesh.primitive_cube_add(size = size, location = location, scale = (size, size, size)); - - # Set the newly created cube as the active object. - activeObject = bpy.context.active_object; - - # Object View Layer variable. - activeObjectViewLayer = bpy.context.view_layer.objects.active; - - # Add a new material slot. - # bpy.ops.object.material_slot_add(); - - # Creating a new material and assigning it to the active cube. - material = bpy.data.materials.new("Material"); - material.use_nodes = True; - BSDF = material.node_tree.nodes["Principled BSDF"]; - materialNodes = material.node_tree.nodes; - materialLinks = material.node_tree.links; - - # Add the material. - activeObject.data.materials.append(material); - - # Selecting each face and then assigning the material to that face. - for i in range(6): - # Checks if the object is currently in edit mode, and if not, sets it into edit mode. - if (bpy.context.active_object.mode != "EDIT"): - bpy.ops.object.editmode_toggle(); - - bm = bmesh.from_edit_mesh(activeObject.data); - - # Make sure the bmesh is up-to-date with the mesh data. - bm.faces.ensure_lookup_table(); - - # Set selecting the faces to be true. - bm.faces[i].select = True; - - # Show the updates in the viewport. - bmesh.update_edit_mesh(activeObject.data); - 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. - bm.faces[i].select = False; - print('Face ', i, ' released'); - - # Change the texture of the cube. - 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"); - material.node_tree.links.new(BSDF.inputs['Base Color'], textureImage.outputs['Color']); - - # Assign the texture to the object. - if activeObjectViewLayer.data.materials: - activeObjectViewLayer.data.materials[0] = material; - else: - activeObjectViewLayer.data.materials.append(material); - -# Calling the functions: -cleanScene(); -spawnGround(); -print('Code has run.'); \ No newline at end of file diff --git a/ImageTextureTrial.py b/ImageTextureTrial.py deleted file mode 100644 index c16a2ff..0000000 --- a/ImageTextureTrial.py +++ /dev/null @@ -1,24 +0,0 @@ -# Link to the code from StackExchange: https://blender.stackexchange.com/questions/157531/blender-2-8-python-add-texture-image - -#Import python -import bpy -from bpy import context, data, ops - - -mat = bpy.data.materials.new(name="New_Mat") -mat.use_nodes = True -bsdf = mat.node_tree.nodes["Principled BSDF"] -texImage = mat.node_tree.nodes.new('ShaderNodeTexImage') -texImage.image = bpy.data.images.load("C:\\Users\\satna\\OneDrive\\Desktop\\Programming\\Python\\Blender\\Blender-World-Generator\\DirtBlock.png") -mat.node_tree.links.new(bsdf.inputs['Base Color'], texImage.outputs['Color']) - -ob = context.view_layer.objects.active - -# Assign it to object -if ob.data.materials: - ob.data.materials[0] = mat -else: - ob.data.materials.append(mat) - -# Notes: -# - Find a way to select a single face of a cube and then add the image to each face. Might have to do stuff with nodes. \ No newline at end of file