-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerativeScript.py
More file actions
115 lines (89 loc) · 4.24 KB
/
Copy pathgenerativeScript.py
File metadata and controls
115 lines (89 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import bpy
import random
from pprint import pprint
class Gemesis:
def __init__(self, gemId, upperBox, lowerBox, background, crystal):
#randomly asign different properties to gem
self.gemId = gemId
self.upperBox = upperBox
self.lowerBox = lowerBox
self.background = background
self.crystal = crystal
#kirstalColor = null;
def hashMe(self):
#do hash
print("hashing")
class Traits:
def __init__(self):
#ADD ALL OBJECTS FROM ONE COLLECTION TO EACH LIST
self.upperBoxes = bpy.data.collections['UpperBoxes'].all_objects #objects in objects are not good as they get displayed seperately
self.lowerBoxes = bpy.data.collections['LowerBoxes'].all_objects
self.crystals = bpy.data.collections['Crystals'].all_objects
self.backgrounds = bpy.data.collections['Backgrounds'].all_objects
#ADD ALL MATERIAL TO EACH LIST
self.upperBoxesMaterials = bpy.data.materials
class GemesisGenerator():
def createRandomGem(gemId, traits):
#RANDOMLY CHOOSE ONE OF THE TRAITS (OBJECTS)
upperBox = random.choice(traits.upperBoxes)
lowerBox = random.choice(traits.lowerBoxes)
background = random.choice(traits.backgrounds)
crystal = random.choice(traits.crystals)
#CREATE GEM WITH CHOSEN TRAITS
gemesis = Gemesis(gemId, upperBox, lowerBox, background, crystal)
#MAKE ONLY CHOSEN ITEMS VISIBLE AND RENDERABLE
bpy.data.objects[gemesis.upperBox.name].hide_render = False
bpy.data.objects[gemesis.upperBox.name].hide_viewport = False
bpy.data.objects[gemesis.upperBox.name].hide_set(False)
bpy.data.objects[gemesis.lowerBox.name].hide_render = False
bpy.data.objects[gemesis.lowerBox.name].hide_viewport = False
bpy.data.objects[gemesis.lowerBox.name].hide_set(False)
bpy.data.objects[gemesis.background.name].hide_render = False
bpy.data.objects[gemesis.background.name].hide_viewport = False
bpy.data.objects[gemesis.background.name].hide_set(False)
bpy.data.objects[gemesis.crystal.name].hide_render = False
bpy.data.objects[gemesis.crystal.name].hide_viewport = False
bpy.data.objects[gemesis.crystal.name].hide_set(False)
print("Gem with gemId " + str(gemId) + " created")
def hideAll():
bpy.ops.object.select_all(action='DESELECT')
#Unhide all inactive objects
for obj in bpy.data.objects:
#obj.hide_viewport = False #Enable visibility in all viewports
obj.hide_render = True #Enable the object in renders
obj.hide_set(True) #Enable the object in the viewport
obj.hide_select = True #Enable selection in the viewport
def showLights():
#for light in bpy.data.collections['Lights'].all_objects:
#obj.hide_viewport = False #Enable visibility in all viewports
#light.hide_render = False #Enable the object in renders
#light.hide_set(False) #Enable the object in the viewport
#light.hide_select = False #Enable selection in the viewport
print("ShowLights")
def unHideAll():
bpy.ops.object.select_all(action='DESELECT')
#Unhide all inactive objects
for obj in bpy.data.objects:
obj.hide_render = False #Enable the object in renders
obj.hide_set(False) #Enable the object in the viewport
obj.hide_select = False #Enable selection in the viewport
print("Unhidden")
def safeGemInFile():
#safe the gem in file
donothing = 0
##DO THE MAIN STUFF
i = 1; #gemID
maxAmount = 2 #amount of gems you want to create
while i <= maxAmount:
hideAll()
traits = Traits()
createRandomGem(i, traits)
#for obj in bpy.data.objects:
#pprint(obj)
#print("______________________________________________")
#for light in bpy.data.collections['Lights'].all_objects:
#pprint(light)
i = i + 1
#INFO
#PRINTS ALL Properties OF OBJECT
#pprint(vars(my_object))