NemesisMate

Untitled

Jul 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import bge
  2.  
  3. cont = bge.logic.getCurrentController()
  4. bge.logic.setLogicTicRate(60.0)
  5.  
  6. act = cont.actuators['objTimer']
  7.  
  8. if act.value == '':
  9. time = 0.0
  10.  
  11. if act.value != '':
  12. time = float(act.value)
  13.  
  14. if time < 60.0:
  15. time += 0.01
  16.  
  17. if time == 60.0:
  18. time = 0
  19.  
  20. act.value = str(time)
  21.  
  22. VertexShader = """
  23. varying vec4 texCoords;
  24. void main() // all vertex shaders define a main() function
  25. {
  26. texCoords = gl_MultiTexCoord0; // in this case equal to gl_Vertex
  27. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  28. // this line transforms the predefined attribute gl_Vertex
  29. // of type vec4 with the predefined uniform
  30. // gl_ModelViewProjectionMatrix of type mat4 and stores
  31. // the result in the predefined output variable gl_Position
  32. // of type vec4. (gl_ModelViewProjectionMatrix combines
  33. // the viewing transformation, modeling transformation and
  34. // projection transformation in one matrix.)
  35. }
  36. """
  37.  
  38. FragmentShader = """
  39. varying vec4 texCoords;
  40. uniform float time;
  41. void main()
  42. {
  43. //gl_FragColor = texture2D(textureUnit, texCoords * 2.);
  44. gl_FragColor = vec4(1.0, 0.0 + time, 0.0, 1.0);
  45. // red, green, blue, alpha
  46. }
  47. """
  48.  
  49. mesh = cont.owner.meshes[0]
  50. for mat in mesh.materials:
  51. shader = mat.getShader()
  52. if shader != None:
  53. if not shader.isValid():
  54. shader.setSource(VertexShader, FragmentShader, 1)
  55. #shader.setSampler('textureUnit', 0)
  56. shader.setUniform1f('time',time)
  57. print(time)
Advertisement
Add Comment
Please, Sign In to add comment