- Home /
How to Get Exact 2D GUI Bounding Box of a 3D Object
Hey there. I am trying to get a GUI axis aligned bounding box of a 3D object (car in my case).
I have tried to use renderer bounds & collider bounds, but their bounding box is larger than expected due to rotation of the object.
Here is an example of renderer bounds solution.
I know there is an exact solution of this which is iterating through all the vertices and getting min max points then drawing the bounding box.
It results something like this which is the bounding box that i want. But vertex iteration solution is very performance consuming. There will be a lot of 3D objects that I should get a bounding box for each frame.
So, I was wondering if there is any other solution to this problem, thanks in advance.
Answer by serg2016 · May 02, 2020 at 07:47 PM
You can use simplified 3d shape to calculate min max. There is some code available to generate simplified mesh. And you can use it to calculate 2d bounding box. https://github.com/Unity-Technologies/UnityMeshSimplifier/
Also you can use LOD mesh generated in 3d modeling software.
Answer by shubhamsarwade · Oct 28, 2020 at 08:57 PM
@Gelrant Hi, were you able to solve the problem? Could you share the solution for this part including how you drew the bounding boxes.,Hi, did you solve the problem? Could you share your solution for this part including how you drew the boxes on screenplane.
Your answer
Follow this Question
Related Questions
Bounds vs. Rectangle 1 Answer
Create variable based on local axis 1 Answer
Collision Not Working 0 Answers
Vector3 Clamp 3 Answers