Issue with generating random points on mesh

I wanna create a grass field, but shape for grass field is being imported as mesh from blender. So I was working on generating points on mesh to spread out thin instances of grass. It sort worked for primitive meshes generated on babylon js but when I try to generate points for mesh imported from blender I am unable to get proper rotation of shape. I have points on shape that match the shape but with wrong rotation.

Here is playground of it.

Hello @Bhushan_Wagh , how are you doing?

It seems to be a matter of rotating the points 180 degrees in the Y axis. I’m not sure why that is, maybe Blender uses a different coordinate system definition, or something like that.

For now I think you can just add a rotation operation to your world matrix:

surface sampler | Babylon.js Playground (babylonjs.com)

1 Like

Actually, I think due to Blender handness not matching Babylon’s the importer adds a transform to the root node (a 180 degrees rotation to the Y axis and -1 scaling in the Z axis). This transformation will be captured by the world matrix you get from mesh.computeWorldMatrix(true).

Since the grass model also has this transformations applied to its root because the model also cames from Blender, when you add thin instances to the grass mesh it will have the “Blender handness correction” applied twice (one from the root node and one from the mesh.computeWorldMatrix(true) value.

Oh okay, Ik about mismatch between blender and babylon js axis sort of and tried to compensate for that initially but I didn’t get correct results. I must be doing somthing wrong. Thanks for solving it.