Answers for "Rotating an object around the centre of its mesh, using Quarternion AxisAngle"
http://answers.unity.com/questions/1416889/rotating-an-object-around-the-centre-of-its-mesh-u.html
The latest answers for the question "Rotating an object around the centre of its mesh, using Quarternion AxisAngle"Answer by BlakeSchreurs
http://answers.unity.com/answers/1416907/view.html
So, I see a few ways that I might try to approach this problem. The best way to do it is going to depend a lot on your application and the geometry you're creating.
1) Cheat: Child your generated object to an Empty GameObject (Make sure the generated GO is at 0,0,0 relative to the parent), and move the parent around. Sometimes this simplifies things, sometimes it doesn't, but it's worth a quick try.
2) Calculate the "Center of mass" of the generated object. Here's the gist: After it's generated, get the mesh from the MeshFilter. Sum up all of the vectors in the mesh, divide by the number of vectors, to get an average position. (Note: If one side has a lot more triangles than another, the center will trend toward the side with more triangles). You can then try an offset by this position, or go through and subtract this position from all the vectors to re-center it a bit.
3) Calculate the "render center" of the generated object. Here's the gist: After it's generated, get the mesh from the MeshFilter. Find the min and max x,y,z values for all vectors in the mesh. Take the max, subtract the min, then divide by two (Note, if the model has tall bits like a space station with antennas, this center will tend more toward those tall bits). You can then try an offset by this position, or go through and subtract this position from all the vectors to re-center it a bit.
Good luck!Fri, 06 Oct 2017 12:46:27 GMTBlakeSchreurs