I have a cube and I want to spawn another cube right on top of it. (it should work for other shapes like a pyramid, too). The tricky part is, that the first cube (or pyramid) moves randomly around.
So I guess what I need is the orientation of the first cube's top face I want to spawn my second cube at. But how can I get that information?
I can get the vertex normal with
# get the 1st mesh
mesh = obj.meshes[0]
# get the first vertex of the first material
vert = mesh.getVertex( 0, 0)
# get the vertex normal vector
normal = vert.getNormal()
but I need the face normal for properly place my second cube on top of the first.
In the end what I want is to randomly stack objects on top of each other without gabs between them. And the newly spawned object always should should match the faces normal it is spawned on.
Thanks for any hint, cheers