I’m using BGE and I’m creating a racing game on this engine. And I want to make a system of vinyl (stickers) in the car, similar to the system of “need for speed world”, so I have already changed the position of the UV coordinates, now I need to change the rotation and scale.Can someone help me? it is possible?
I have this code, which messes with the position of the UV coordinates, but I need the scale and rotation too …
from bge import logic # get the controller that executes the script
cont = logic.getCurrentController() # get the object that uses the controller
own = cont.owner
speed_x = 0.005 # speed by which the coordinates are moved
speed_y = 0.00 # speed by which the coordinates are moved
mesh = own.meshes[0] # access the mesh of the object in question
v_array = mesh.getVertexArrayLength(0) # how many verts are there?
for v in range(0,v_array): # go through the uv’s of every vert
vert = mesh.getVertex(0,v)
uv = vert.getUV()
uv[0] += speed_x # change the uv coordinates. uv[0] = x, uv[1] = y
uv[1] += speed_y
vert.setUV(uv) # get the game engine to notice the change!!
(I do not know how to speak English right because I’m Brazilian)
Thanks!!! It helped a lot! But has a problem, is changing the UV coordinates of all object textures. Can you change only the UV coordinates of just one texture?
This does not change textures. It changes the UV-components of a mesh. Obvious when you share a mesh you share all modifications to it. When you do not want that, ensure to use a copy of the mesh.
You can also have 1 UV layer per texture but I don’t know how many layers are supported in bge code (in upbge 1.3 we’ll have the possibility to change UV in the texture shader, so it will be per texture, and iirc I did a patch to have 8 uv layers supported with transformUV https://github.com/UPBGE/blender/commit/387a731d74232e9ef278a95cf6497f1d9e5e309f)
Yeah, this was just to say that upbge supported 8 uv layers with transformUV. (You don’t need to compile if you use upbge that can be found here: https://upbge.org/ (if you want to test of course))
You see, I consider the others can be interested in the way the engine works.