Hello! I am using a list to get all objects in the scene that have “Grass” in their properties, to make a grass (not procedural, because I don’t know: (…). But when I apply “localOrientation” to each object on the list, they change their orientations in the same direction, and their orientations are different.The objects have an “arrow” on top because I was wondering if they changed for each other in different ways (and it worked …).
(Note: UPBGE Project)
So let me get this strait
You want all the objects with grass property to face in the same direction
Like at the beginning of the video in the Blender View-Port
[ EDIT ]
After looking at your file I still don’t understand what you want to happen
The script modifies the orientation of all objects in the list at random so that it does not become monotone. But when I used the time math.sin() to modify the local orientation of each object, they deform in the same direction, and that’s not what I want, I want them to change individually.
I don’t know how to make this, this is very hard for me…
EDIT:
I made this code, trying to change the position of the object mesh vertices, but nothing happens. If I put the position of the vertex on the console, it shows that its position changes, but visually, it doesn’t.
import bge
import math
import mathutils
cont = bge.logic.getCurrentController()
own = cont.owner
grass = [obj for obj in bge.logic.getCurrentScene().objects if "Grass" in obj.getPropertyNames()]
velocity = 5
def ori():
x_z = math.sin((own['Time']*velocity)/1.2)/5
y_z = math.cos((own['Time']*velocity)/2.3)/5
return(y_z*10, x_z*10)
for gr in grass:
vert_pos = [ori()[0],ori()[1],1.0]
mesh = gr.meshes[0]
for mat in range(len(mesh.materials)):
for vet in range(mesh.getVertexArrayLength(mat)):
vertex = mesh.getVertex(mat, vet)
vertex_get_xyz = vertex.getXYZ()
vertex_get_xyz[0] = vertex_get_xyz[0]+ori()[0]
vertex_get_xyz[1] = vertex_get_xyz[1]+ori()[0]
pos = mathutils.Vector((vertex_get_xyz[0],vertex_get_xyz[1],vertex_get_xyz[2]))
pos.normalize()
vertex.setXYZ(pos)
Er so this is what I get on my end when opening @Markuebinha’s blend file
I see grass with rotation set to different rotations.
However it’s the same rotations every time. @Markuebinha I think you are wanting ABSOLUTE_RANDOM* rotations per-init
import random
def test(cont):
own = cont.owner
grass = [obj for obj in own.scene.objects if "Grass" in obj]
for obj in grass:
obj.worldOrientation = [0,0,random.randint(1,360)]
write in English please, most people wont understand what you write otherwise.
i put what you have written into google translate and got this.
“” Yeah! But I need the “wind” on the leaves to move in different directions as well. “”
I finally got a satisfactory result, got what I wanted using mesh.transformUV() and mesh.transform(). This results not bad, for me Vertex_BGE_Test.blend (541.9 KB)