Browse Source

Upload everything

If you can't figure out blender....
Just gonna send it
Farmerjoe12 3 years ago
parent
commit
527d8d8b91
5 changed files with 314 additions and 211 deletions
  1. 2
    2
      README.md
  2. 12
    0
      active_camera_loc.py
  3. 209
    209
      ai_manager.py
  4. 19
    0
      curves.osl
  5. 72
    0
      lensflare01.osl

+ 2
- 2
README.md View File

@@ -1,2 +1,2 @@
1
-# shuvit
2
-Open source skateboarding game made with UPBGE / Blender.
1
+# shuvit
2
+Open source skateboarding game made with UPBGE / Blender.

+ 12
- 0
active_camera_loc.py View File

@@ -0,0 +1,12 @@
1
+import bge
2
+
3
+
4
+def set(cont):
5
+    own = cont.owner
6
+
7
+    #own.getWorldPosition
8
+    scene = bge.logic.getCurrentScene()
9
+    cam = scene.active_camera
10
+    own.worldPosition = cam.worldPosition
11
+
12
+# dont call main(bge.logic.getCurrentController()), the py controller will

+ 209
- 209
ai_manager.py View File

@@ -1,210 +1,210 @@
1
-def printplaying(skater,deck):
2
-    splaying_layers = "S: "
3
-    playing_layers = "D: "
4
-    tplaying_layers = "T: "
5
-    for x in range(9999):
6
-        if skater.isPlayingAction(x):
7
-        #if trucks.isPlayingAction(x):
8
-        #if skater.isPlayingAction(x):                        
9
-            splaying_layers += str(x)
10
-            splaying_layers += " "        
11
-        if deck.isPlayingAction(x):
12
-        #if trucks.isPlayingAction(x):
13
-        #if skater.isPlayingAction(x):                        
14
-            playing_layers += str(x)
15
-            playing_layers += " "
16
-          
17
-    print(splaying_layers, playing_layers)
18
-
19
-def main():
20
-
21
-    frame_rate = 60    #Set this to the framerate of your game.
22
-    optimization = 1    #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
23
-    #recording_cutoff = 6974#7300 #3600   #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
24
-    
25
-    recorder_state = 1   #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
26
-    allow_playback_break = True   #Allow the player to resume playing from the position in the recording.
27
-
28
-    from bge import logic
29
-    import aiRecord
30
-    import aiSortData
31
-    import npcChangeAnim
32
-    from mathutils import Vector
33
-    import math
34
-    
35
-    debugg = True
36
-
37
-    cont = logic.getCurrentController()
38
-    own = cont.owner
39
-    scene = logic.getCurrentScene()
40
-    dict = logic.globalDict
41
-    own['valueIndex'] = own['valueIndex'] + 2
42
-    #dict['recorder_on'] = recorder_on
43
-    npc_index = own['npc_index']
44
-    skater = dict['spawned_npcs'][npc_index]
45
-    recorder_on = dict.get('recorder_on')
46
-    own['recorder_on'] = recorder_on
47
-    #print("recorder on: ", recorder_on) 
48
-    own["playback"] = True
49
-    recording_cutoff = own['replay_length']
50
-    idle_timer = own['idle_timer']
51
-    npc_playback = own['npc_playback']
52
-    
53
-    
54
-    
55
-    if 'data_loaded' not in own:
56
-        #own['data_loaded'] = 1
57
-        aiRecord.loadData(cont, own)
58
-        if debugg: print('ai_loadData')
59
-        
60
-    if npc_playback == True:
61
-        cube = own
62
-        aiRecord.loadData(cont, own)   
63
-        #own['move'] = False          
64
-        #....................
65
-
66
-        valueIndex = own['valueIndex']
67
-        n = (valueIndex / recording_cutoff) * 1000
68
-        n = int(round(n))
69
-        #print(own['valueIndex'])
70
-        if own['objIndex'] < (recording_cutoff-3):
71
-            own['objIndex'] = own['objIndex'] + 2
72
-        else:
73
-            own['objIndex'] = 4   
74
-            print('replay end')    
75
-            npcChangeAnim.main(cont)
76
-            #own['npc_replay_name'] = '30secA.dat'
77
-            own['inited'] = False
78
-            own['rotate_in'] = True
79
-            own['move_to'] = True
80
-            own['rotate_out'] = True 
81
-            aiRecord.loadData(cont, own)
82
-    else:
83
-        if idle_timer < 5:
84
-            idle_timer += 1
85
-            #print('idling', idle_timer)
86
-        else:
87
-            idle_timer = 0
88
-            own['npc_rotate'] = True                 
89
-            
90
-    if own['move'] == True:
91
-        speed = .15
92
-        target = own['rpStartLoc']
93
-        my_vector = Vector([target[0], target[1], target[2]])
94
-        length = (own.worldPosition - my_vector).length
95
-        obj = own['target_object_name']
96
-        vect = own.getVectTo(obj)   
97
-        if length < .1:
98
-            own['move'] = False
99
-            obj = own['target_object_name']
100
-    own['idle_timer'] = idle_timer   
101
-    
102
-    try:
103
-        obj = own['target_object_name']
104
-        #print(obj.worldPosition)
105
-    except:
106
-        pass    
107
-    
108
-    
109
-    #11111111
110
-    if own['rotate_in'] == False and own['move_to'] == False and own['rotate_out'] == False:
111
-        own['npc_playback'] = True
112
-        #obj = own['target_object_name']
113
-        #obj.endObject()
114
-        #print('ending target')    
115
-    if own['rotate_in'] == True:
116
-        tActu = cont.actuators['npcTracking']
117
-        tActu.object = own['target_object_name']
118
-        try:
119
-            own['rotate_in_timer'] = own['rotate_in_timer'] + 1
120
-        except:
121
-            own['rotate_in_timer'] = 0
122
-        if own['rotate_in_timer'] < 120:    
123
-            cont.activate(tActu)
124
-            skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)  
125
-        else:
126
-            cont.deactivate(tActu) 
127
-            own['rotate_in'] = False
128
-            own['rotate_in_timer'] = 0
129
-            skater.stopAction(2)
130
-
131
-    elif own['move_to'] == True:
132
-        target = own['rpStartLoc']
133
-        #print(target, 'target', own.worldPosition, '++++++')
134
-        my_vector = Vector([target[0], target[1], target[2]])
135
-        length = (own.worldPosition - my_vector).length
136
-        sActu = cont.actuators['npcSteering']
137
-        sActu.target = own['target_object_name']
138
-        #length = round(length, 7)
139
-        if length > .1:
140
-            #print(length, 'length < .1')
141
-            #pass
142
-            cont.activate(sActu)
143
-            skater.playAction('reg_nwalk', 0,35, layer=2, play_mode=1, speed=.5)
144
-        else:
145
-            cont.deactivate(sActu)
146
-            own['move_to'] = False
147
-            print(length, 'length met')
148
-            skater.stopAction(2)
149
-
150
-    elif own['rotate_out'] == True:    
151
-        #own['rpStartZ'] = 180
152
-        #print(own['rpStartZ'], 'start')
153
-        xyz = own.localOrientation.to_euler()
154
-        #print(xyz[2], 'non euler')
155
-        rotz = math.degrees(xyz[2])
156
-        xyz[2] = xyz[2] + 1.57
157
-        rotz_b = rotz + 180
158
-        if rotz_b > 360:
159
-            rotz_b -= 360
160
-        srotz_b = own['rpStartZ'] + 180
161
-        if srotz_b > 360:
162
-            srotz_b -= 360
163
-        #print (rotz_b, srotz_b, '---rotations')        
164
-        #print (rotz, own['rpStartZ'], '---rotations')
165
-        num = rotz - (own['rpStartZ'])
166
-        amt = .03
167
-        amt2 = 1
168
-        
169
-        
170
-        local = own.worldOrientation.inverted() * ( own['target_object_name'].worldPosition - own.worldPosition) 
171
-
172
-        if local.x >0:
173
-            #target is in front
174
-            #print('in front')
175
-            pass
176
-        else:
177
-            #target is behind
178
-            #print('behind')
179
-            pass
180
-        if local.y > 0:
181
-                 #object on right
182
-            #print('on right')
183
-            rot = 'right'
184
-        else:
185
-                 #object is on left 
186
-            #print('on left')
187
-            rot = 'left'       
188
-        
189
-        
190
-        
191
-        skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)
192
-        if abs(num) < amt2:
193
-            own['npc_playback'] = True
194
-            own['npc_rotate'] = False
195
-            print('----starting replay', num)
196
-            own['rotate_out'] = False
197
-            obj = own['target_object_name']
198
-            obj.endObject()
199
-            print('ending target') 
200
-            skater.stopAction(2)            
201
-        #elif rotz > own['rpStartZ']:
202
-        elif rot == 'right':    
203
-            own.applyRotation([0,0,amt], True)
204
-            own.worldPosition = own['rpStartLoc']
205
-        #elif rotz < own['rpStartZ']:
206
-        elif rot == 'left':    
207
-            own.applyRotation([0,0,-amt], True) 
208
-            own.worldPosition = own['rpStartLoc']                
209
-    #print(own['rotate_in'], own['move_to'], own['rotate_out'])                          
1
+def printplaying(skater,deck):
2
+    splaying_layers = "S: "
3
+    playing_layers = "D: "
4
+    tplaying_layers = "T: "
5
+    for x in range(9999):
6
+        if skater.isPlayingAction(x):
7
+        #if trucks.isPlayingAction(x):
8
+        #if skater.isPlayingAction(x):                        
9
+            splaying_layers += str(x)
10
+            splaying_layers += " "        
11
+        if deck.isPlayingAction(x):
12
+        #if trucks.isPlayingAction(x):
13
+        #if skater.isPlayingAction(x):                        
14
+            playing_layers += str(x)
15
+            playing_layers += " "
16
+          
17
+    print(splaying_layers, playing_layers)
18
+
19
+def main():
20
+
21
+    frame_rate = 60    #Set this to the framerate of your game.
22
+    optimization = 1    #An integer, must be at least 1! Higher value will make a smaller saved file size. I do not reccomend setting it to anything other than 1 though.
23
+    #recording_cutoff = 6974#7300 #3600   #Frames at which the oldest recorded frame will be deleted. 0 is no cutoff.
24
+    
25
+    recorder_state = 1   #This is the main state of the recorder object. State will be reverted to this value when the user breaks out of the playback.
26
+    allow_playback_break = True   #Allow the player to resume playing from the position in the recording.
27
+
28
+    from bge import logic
29
+    import aiRecord
30
+    import aiSortData
31
+    import npcChangeAnim
32
+    from mathutils import Vector
33
+    import math
34
+    
35
+    debugg = True
36
+
37
+    cont = logic.getCurrentController()
38
+    own = cont.owner
39
+    scene = logic.getCurrentScene()
40
+    dict = logic.globalDict
41
+    own['valueIndex'] = own['valueIndex'] + 2
42
+    #dict['recorder_on'] = recorder_on
43
+    npc_index = own['npc_index']
44
+    skater = dict['spawned_npcs'][npc_index]
45
+    recorder_on = dict.get('recorder_on')
46
+    own['recorder_on'] = recorder_on
47
+    #print("recorder on: ", recorder_on) 
48
+    own["playback"] = True
49
+    recording_cutoff = own['replay_length']
50
+    idle_timer = own['idle_timer']
51
+    npc_playback = own['npc_playback']
52
+    
53
+    
54
+    
55
+    if 'data_loaded' not in own:
56
+        #own['data_loaded'] = 1
57
+        aiRecord.loadData(cont, own)
58
+        if debugg: print('ai_loadData')
59
+        
60
+    if npc_playback == True:
61
+        cube = own
62
+        aiRecord.loadData(cont, own)   
63
+        #own['move'] = False          
64
+        #....................
65
+
66
+        valueIndex = own['valueIndex']
67
+        n = (valueIndex / recording_cutoff) * 1000
68
+        n = int(round(n))
69
+        #print(own['valueIndex'])
70
+        if own['objIndex'] < (recording_cutoff-3):
71
+            own['objIndex'] = own['objIndex'] + 2
72
+        else:
73
+            own['objIndex'] = 4   
74
+            print('replay end')    
75
+            npcChangeAnim.main(cont)
76
+            #own['npc_replay_name'] = '30secA.dat'
77
+            own['inited'] = False
78
+            own['rotate_in'] = True
79
+            own['move_to'] = True
80
+            own['rotate_out'] = True 
81
+            aiRecord.loadData(cont, own)
82
+    else:
83
+        if idle_timer < 5:
84
+            idle_timer += 1
85
+            #print('idling', idle_timer)
86
+        else:
87
+            idle_timer = 0
88
+            own['npc_rotate'] = True                 
89
+            
90
+    if own['move'] == True:
91
+        speed = .15
92
+        target = own['rpStartLoc']
93
+        my_vector = Vector([target[0], target[1], target[2]])
94
+        length = (own.worldPosition - my_vector).length
95
+        obj = own['target_object_name']
96
+        vect = own.getVectTo(obj)   
97
+        if length < .1:
98
+            own['move'] = False
99
+            obj = own['target_object_name']
100
+    own['idle_timer'] = idle_timer   
101
+    
102
+    try:
103
+        obj = own['target_object_name']
104
+        #print(obj.worldPosition)
105
+    except:
106
+        pass    
107
+    
108
+    
109
+    #11111111
110
+    if own['rotate_in'] == False and own['move_to'] == False and own['rotate_out'] == False:
111
+        own['npc_playback'] = True
112
+        #obj = own['target_object_name']
113
+        #obj.endObject()
114
+        #print('ending target')    
115
+    if own['rotate_in'] == True:
116
+        tActu = cont.actuators['npcTracking']
117
+        tActu.object = own['target_object_name']
118
+        try:
119
+            own['rotate_in_timer'] = own['rotate_in_timer'] + 1
120
+        except:
121
+            own['rotate_in_timer'] = 0
122
+        if own['rotate_in_timer'] < 120:    
123
+            cont.activate(tActu)
124
+            skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)  
125
+        else:
126
+            cont.deactivate(tActu) 
127
+            own['rotate_in'] = False
128
+            own['rotate_in_timer'] = 0
129
+            skater.stopAction(2)
130
+
131
+    elif own['move_to'] == True:
132
+        target = own['rpStartLoc']
133
+        #print(target, 'target', own.worldPosition, '++++++')
134
+        my_vector = Vector([target[0], target[1], target[2]])
135
+        length = (own.worldPosition - my_vector).length
136
+        sActu = cont.actuators['npcSteering']
137
+        sActu.target = own['target_object_name']
138
+        #length = round(length, 7)
139
+        if length > .1:
140
+            #print(length, 'length < .1')
141
+            #pass
142
+            cont.activate(sActu)
143
+            skater.playAction('reg_nwalk', 0,35, layer=2, play_mode=1, speed=.5)
144
+        else:
145
+            cont.deactivate(sActu)
146
+            own['move_to'] = False
147
+            print(length, 'length met')
148
+            skater.stopAction(2)
149
+
150
+    elif own['rotate_out'] == True:    
151
+        #own['rpStartZ'] = 180
152
+        #print(own['rpStartZ'], 'start')
153
+        xyz = own.localOrientation.to_euler()
154
+        #print(xyz[2], 'non euler')
155
+        rotz = math.degrees(xyz[2])
156
+        xyz[2] = xyz[2] + 1.57
157
+        rotz_b = rotz + 180
158
+        if rotz_b > 360:
159
+            rotz_b -= 360
160
+        srotz_b = own['rpStartZ'] + 180
161
+        if srotz_b > 360:
162
+            srotz_b -= 360
163
+        #print (rotz_b, srotz_b, '---rotations')        
164
+        #print (rotz, own['rpStartZ'], '---rotations')
165
+        num = rotz - (own['rpStartZ'])
166
+        amt = .03
167
+        amt2 = 1
168
+        
169
+        
170
+        local = own.worldOrientation.inverted() * ( own['target_object_name'].worldPosition - own.worldPosition) 
171
+
172
+        if local.x >0:
173
+            #target is in front
174
+            #print('in front')
175
+            pass
176
+        else:
177
+            #target is behind
178
+            #print('behind')
179
+            pass
180
+        if local.y > 0:
181
+                 #object on right
182
+            #print('on right')
183
+            rot = 'right'
184
+        else:
185
+                 #object is on left 
186
+            #print('on left')
187
+            rot = 'left'       
188
+        
189
+        
190
+        
191
+        skater.playAction('reg_idle1', 0,120, layer=2, play_mode=1, speed=.5)
192
+        if abs(num) < amt2:
193
+            own['npc_playback'] = True
194
+            own['npc_rotate'] = False
195
+            print('----starting replay', num)
196
+            own['rotate_out'] = False
197
+            obj = own['target_object_name']
198
+            obj.endObject()
199
+            print('ending target') 
200
+            skater.stopAction(2)            
201
+        #elif rotz > own['rpStartZ']:
202
+        elif rot == 'right':    
203
+            own.applyRotation([0,0,amt], True)
204
+            own.worldPosition = own['rpStartLoc']
205
+        #elif rotz < own['rpStartZ']:
206
+        elif rot == 'left':    
207
+            own.applyRotation([0,0,-amt], True) 
208
+            own.worldPosition = own['rpStartLoc']                
209
+    #print(own['rotate_in'], own['move_to'], own['rotate_out'])                          
210 210
 main()

+ 19
- 0
curves.osl View File

@@ -0,0 +1,19 @@
1
+
2
+
3
+uniform sampler2D bgl_RenderedTexture;
4
+
5
+uniform float BC_BRIGHTNESS = 2;
6
+uniform float BC_CONTRAST = 1;
7
+
8
+//const float BC_CONTRAST = 1.3;    //1 is no contrast.
9
+//const float BC_BRIGHTNESS = 1.15;    //1 is no brightness 1.15 is good
10
+
11
+void main()
12
+{
13
+    vec4 color = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
14
+    
15
+    color = ((color-1)*max(BC_CONTRAST,0));
16
+    color = color+BC_BRIGHTNESS;
17
+     
18
+    gl_FragColor = color; 
19
+}

+ 72
- 0
lensflare01.osl View File

@@ -0,0 +1,72 @@
1
+
2
+uniform sampler2D bgl_RenderedTexture;
3
+uniform float bgl_RenderedTextureWidth;
4
+uniform float bgl_RenderedTextureHeight;
5
+uniform float sunX;
6
+uniform float sunY;
7
+uniform float timer;
8
+uniform float sundirect;
9
+uniform float sunScale; 
10
+
11
+float noise( float n )
12
+{
13
+     return fract(sin(n+timer/2.0));
14
+}
15
+
16
+//float noise2(vec2 co){
17
+    //return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
18
+//}
19
+
20
+vec3 lensflare(vec2 uv,vec2 pos,float sunscale)
21
+{
22
+	vec2 main = uv-pos;
23
+	vec2 uvd = uv*(length(uv));
24
+	
25
+	float ang = atan(main.y, main.x);
26
+	float dist=length(main); dist = pow(dist,.1);
27
+	float n = noise1(vec2((ang-timer/9.0)*16.0,dist*32.0));
28
+	
29
+	float f0 = 1.0/(length(uv-pos)/sunscale+1.0);
30
+	
31
+	f0 = f0+f0*(sin((ang+timer/18.0 + noise1(abs(ang)+n/2.0)*2.0)*12.0)*.1+dist*.1+.8);
32
+
33
+	float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;
34
+	float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;
35
+	float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;
36
+	
37
+	vec2 uvx = mix(uv,uvd,-0.5);
38
+	
39
+	float f4 = max(0.01-pow(length(uvx+0.4*pos),2.4),.0)*6.0;
40
+	float f42 = max(0.01-pow(length(uvx+0.45*pos),2.4),.0)*5.0;
41
+	float f43 = max(0.01-pow(length(uvx+0.5*pos),2.4),.0)*3.0;
42
+	
43
+	uvx = mix(uv,uvd,-.4);
44
+	
45
+	float f5 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
46
+	float f52 = max(0.01-pow(length(uvx+0.4*pos),5.5),.0)*2.0;
47
+	float f53 = max(0.01-pow(length(uvx+0.6*pos),5.5),.0)*2.0;
48
+	
49
+	uvx = mix(uv,uvd,-0.5);
50
+	
51
+	float f6 = max(0.01-pow(length(uvx-0.3*pos),1.6),.0)*6.0;
52
+	float f62 = max(0.01-pow(length(uvx-0.325*pos),1.6),.0)*3.0;
53
+	float f63 = max(0.01-pow(length(uvx-0.35*pos),1.6),.0)*5.0;
54
+	
55
+	vec3 c = vec3(.0);
56
+	
57
+	c.r+=f2+f4+f5+f6; c.g+=f22+f42+f52+f62; c.b+=f23+f43+f53+f63;
58
+	c+=vec3(f0);
59
+	
60
+	return c;
61
+}
62
+
63
+void main()
64
+{
65
+    vec4 renderedTex = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
66
+    float xconv = bgl_RenderedTextureWidth / bgl_RenderedTextureHeight;
67
+    vec2 sunPos = vec2((sunX - 0.5) * xconv, sunY - 0.5);
68
+    vec2 uv = vec2((gl_TexCoord[0].s - 0.5) * xconv, gl_TexCoord[0].t - 0.5);
69
+    vec3 lens = lensflare(uv, sunPos, sunScale);
70
+    renderedTex.rgb += lens * sundirect;
71
+    gl_FragColor = renderedTex;
72
+}

Loading…
Cancel
Save