Comments and 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 comments and answers for the question "Rotating an object around the centre of its mesh, using Quarternion AxisAngle"Comment by Glurth on Glurth's answer
http://answers.unity.com/comments/1416991/view.html
Re #3) I should mention the BOUNDS class. both Meshs, and MeshRenderes provide bounds members. (one in model-space, one in work-space, repecively). This class MAY contain the "center" point you are looking for: https://docs.unity3d.com/ScriptReference/Bounds.htmlFri, 06 Oct 2017 15:38:32 GMTGlurthComment by FoxAlive555 on FoxAlive555's answer
http://answers.unity.com/comments/1416975/view.html
Thank you for this reply,
I ended up completely altering how objects were placed after they were instantiated to prevent getting that original offset.
My exact problem was pretty specific so unfortunately that "cheat" method didn't work (it was the first thing I tried).
I strongly, strongly suspect that all your answers would be applicable to many people who had more general rotation problems in Unity, and you also taught me some new techniques. I will definitely be using those in future. Accepting this because I think it will be more useful to others looking up this question than the solution I used.Fri, 06 Oct 2017 15:12:15 GMTFoxAlive555Answer 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