Browse Source

adding colors script

shuvit 3 years ago
parent
commit
a9ac8b4826
1 changed files with 121 additions and 0 deletions
  1. 121
    0
      colors.py

+ 121
- 0
colors.py View File

@@ -0,0 +1,121 @@
1
+import bge
2
+from bge import texture
3
+
4
+dict = bge.logic.globalDict 
5
+scene = bge.logic.getCurrentScene()
6
+shirt = scene.objects["Char4:Zshirtt1"]
7
+deck = scene.objects["deck"]
8
+throw_deck = scene.objectsInactive["throw_deck"]
9
+focus_deckA = scene.objectsInactive["focus_deckA"]
10
+focus_deckB = scene.objectsInactive["focus_deckB"]
11
+shoeR = scene.objects['Char4:Shoes02.R']
12
+shoeL = scene.objects['Char4:Shoes02.L']
13
+trucks = scene.objects['trucks']
14
+wheel1 = scene.objects['rollen.000']
15
+wheel2 = scene.objects['rollen.001']
16
+wheel3 = scene.objects['rollen.002']
17
+wheel4 = scene.objects['rollen.003']
18
+
19
+##
20
+white = [ .9, .9, .9, 1.0]
21
+yellow = [ 0.6, 0.33, 0, 1.0]
22
+grey = [ .5, .5, .5, 1.0]
23
+red = [ .2, 0, 0, 1]
24
+orange = [.47, .1, 0, 1]
25
+deckbrown = [.2, .075, .001, 1]
26
+lightblue = [.375, .6, 1, 1]
27
+## set colors
28
+shirtC = white
29
+deckC = red
30
+shoesC = grey
31
+def main():
32
+
33
+    cont = bge.logic.getCurrentController()
34
+    own = cont.owner
35
+
36
+    #shirt.color = shirtC
37
+    #print(dict['shirt_color'])
38
+    scol = [dict['shirt_color_r'], dict['shirt_color_g'], dict['shirt_color_b'], 1]
39
+    deckC = [dict['deck_color_r'], dict['deck_color_g'], dict['deck_color_b'], 1]
40
+    print(scol)
41
+    shirt.color = scol
42
+    deck.color = deckC
43
+    throw_deck.color = deckC
44
+    focus_deckA.color = deckC
45
+    focus_deckB.color = deckC
46
+    shoesC = [dict['shoe_color_r'], dict['shoe_color_g'], dict['shoe_color_b'], 1]
47
+    shoeR.color = shoesC
48
+    shoeL.color = shoesC
49
+    
50
+    trucks.color = [dict['trucks_r'], dict['trucks_g'], dict['trucks_b'], 1]
51
+    wheel1.color = [dict['wheel1_r'], dict['wheel1_g'], dict['wheel1_b'], 1]
52
+    wheel2.color = [dict['wheel2_r'], dict['wheel2_g'], dict['wheel2_b'], 1]
53
+    wheel3.color = [dict['wheel3_r'], dict['wheel3_g'], dict['wheel3_b'], 1]
54
+    wheel4.color = [dict['wheel4_r'], dict['wheel4_g'], dict['wheel4_b'], 1]
55
+    
56
+    #print("set color", deck.color)
57
+
58
+
59
+    logo = dict['shirt_logo']
60
+    logo1 = shirt.meshes[0].materials[0].textures[6]
61
+    logo2 = shirt.meshes[0].materials[0].textures[7] 
62
+    logo3 = shirt.meshes[0].materials[0].textures[5]   
63
+    try:
64
+        if logo == 1:
65
+            logo1.diffuseIntensity = 1
66
+            logo2.diffuseIntensity = 0
67
+            logo1.diffuseFactor = 1
68
+            logo2.diffuseFactor = 0
69
+            logo3.diffuseIntensity = 0
70
+            logo3.diffuseFactor = 0
71
+        if logo == 2:
72
+            logo1.diffuseIntensity = 0
73
+            logo1.diffuseFactor = 0
74
+            logo2.diffuseIntensity = 1 
75
+            logo2.diffuseFactor = 1   
76
+            logo3.diffuseIntensity = 0
77
+            logo3.diffuseFactor = 0        
78
+        if logo == 3:
79
+            logo1.diffuseIntensity = 0
80
+            logo1.diffuseFactor = 0
81
+            logo2.diffuseIntensity = 0 
82
+            logo2.diffuseFactor = 0                   
83
+            logo3.diffuseIntensity = 1
84
+            logo3.diffuseFactor = 1        
85
+        if logo == 0:
86
+            logo1.diffuseIntensity = 0
87
+            logo2.diffuseIntensity = 0            
88
+            logo1.diffuseFactor = 0
89
+            logo2.diffuseFactor = 0
90
+            logo3.diffuseIntensity = 0
91
+            logo3.diffuseFactor = 0        
92
+    except:
93
+        pass    
94
+
95
+main()
96
+
97
+
98
+def update_tuck_tex():
99
+    #deck graphic testing
100
+    import glob
101
+    scene = bge.logic.getCurrentScene()
102
+    deck = scene.objects["deck"]
103
+    mainDir = bge.logic.expandPath("//")
104
+    fileName = mainDir + "textures\\decks\\*.png"    
105
+    deckList = glob.glob(fileName)
106
+    dict['deckList'] = deckList  
107
+    ID = texture.materialID(deck, 'MAdeck')
108
+    deck_texture = texture.Texture(deck, ID)
109
+    new_source = texture.ImageFFmpeg(deckList[dict["deck_index"]])
110
+    bge.logic.texture = deck_texture
111
+    bge.logic.texture.source = new_source
112
+    bge.logic.texture.refresh(False)
113
+    deck_name = deckList[dict['deck_index']]
114
+    deck_name = deck_name.replace(mainDir, '')
115
+    deck_name = deck_name.replace('textures\decks', '' )
116
+    deck_name = deck_name.replace('.png', '')   
117
+    deck_name = deck_name.replace("\\", "")  
118
+    print('deck texture updted to ', deck_name)
119
+    dict['deck_name'] = deck_name
120
+
121
+

Loading…
Cancel
Save