Is there a way to get the suface orientation from a raycast hit?
I basically want to create an object at a raycast hit location (which i’m already doing) but then I want the object to be the same rotation as the surface. So the object is flat against a surface (such as a bullet hole).
I believe what I’m looking for is called surface normal vector. I did notice one of the properties which is returned is called hitNormal. Although rotating or rotating from eular using the hitNormal vector didn’t seem to work
Any ideas or am I looking at the wrong thing? In an old engine I used to use you would tell it the object and the vector of the point you would like to know the surface normal.
I tried to use set rotation from eular but that didn’t work and I’m not sure why, it actually messed it up so the node just didn’t show when I tried it. As the output is a vector and not a quatronion I presume from eular would need to be the way I use the hitNormal?
this.node.setRotationFromEuler(result.hitNormal);
or
this.node.setRotationFromEuler(new Vec3(result.hitNormal.x,result.hitNormal.y,result.hitNormal.z));
I do how ever get consistent vectors from the hitNormal depending on the orientation of the suface that is hit such as:
hitNormal is not the same as Eulerian angle, I think you need to find the initial vector and then derive the rotation angle you want based on the angle between the two vectors.
Ok, at least that’s good to know. When you say original vector do you mean the original position of where the ray was casted from or the hitPoint? Also any suggestions on how to go about it would be great. I.E a function under Quat, Vec3 or Math is where I should be looking. Thanks for your help.