New update, this time working on some polishing, adding details, etc.
I made a little “object surface data visualization” system with those points being spawned on the mesh randomly, like if it was pointing to flaws or noticeable things on the object.
It was kinda tricky to do since I didn’t want to have simple points being generated and using the mesh’s normals to offset the text part. Doing that would have created points in weird places like under the mesh or inside cavities (like behind the trunk on this one for example) and using the normal at that point would have offseted the text in weird ways (like inside the shape).
So the solution I came up with was using a stretched hemisphere shape encompassing the mesh and spawning point on that. From there, I projected this position onto the mesh thanks to the shape.project() function. I could then draw two points for the two tips and a line between them.
Here you can the part of the graph that computes the positions for every part:
You can clearly see how I sample the Hemisphere shape (showed as debug in the viewport) and use the retrieved Position and Normal data to then either calculate the textpoint positions (with an extra physics added) or calculate the projection on the mesh and position the meshpoint. The axis is simply drawn by averaging the two positions and subtracting them to get the vector axis
From there, I was pretty satisfied but… not entirely
The thing is, I thought it was too bad that texts were still visible when behind the object. It was distracting and not very cool.
So to avoid that, I made a simple script node and went on doing some raycasting (again !). The idea is to cast a ray from camera position to particle position, and check if it intersects with the shape on the way.
Here to part of the graph and the script:
“Shape” input is my Ganesha statue mesh. “RayStart” is my Camera Position. “RayDirection” is a simple normalized subtraction of my particle position and my cam position. My “RayLength” is quite high, to test. And “ParticlePosition” is, again, my particle’s position.
DoCollide condition is triggered when the Ray hits the mesh AND when the ray distance is lower than the particle distance from the camera (why ? because I want to hide the text when it’s behind the mesh, not when it’s in front of it!).
That was difficult, technical and fun !