Guest User

Untitled

a guest
Jul 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. uv_offset = [0, 0]
  2. def init(c):
  3. # Copy UVs to second channel using an identity matrix.
  4. c.owner.meshes[0].transformUV(-1, mathutils.Matrix(), 1, 0)
  5.  
  6. def update(c):
  7. # Transform stored original values and write to first channel.
  8. uv_offset[0] += SPEED_X
  9. uv_offset[1] += SPEED_Y
  10. uv_mat = mathutils.Matrix.Translation((uv_offset[0], uv_offset[1], 0))
  11. c.owner.meshes[0].transformUV(-1, uv_mat, 0, 1)
  12.  
  13. from bge import logic # get the controller that executes the script
  14. cont = logic.getCurrentController() # get the object that uses the controller
  15. own = cont.owner
  16.  
  17. speed_x = 0.002 # speed by which the coordinates are moved
  18. speed_y = 0.0 # speed by which the coordinates are moved
  19. mesh = own.meshes[0] # access the mesh of the object in question
  20. v_array = mesh.getVertexArrayLength(0) # how many verts are there?
  21. for v in range(0,v_array): # go through the uv's of every vert
  22. vert = mesh.getVertex(0,v)
  23. uv = vert.getUV()
  24. uv[0] += speed_x # change the uv coordinates. uv[0] = x, uv[1] = y
  25. uv[1] += speed_y
  26. vert.setUV(uv) # get the game engine to notice the change!!
Add Comment
Please, Sign In to add comment