Quantcast
Channel: Questions in topic: "models"
Viewing all articles
Browse latest Browse all 416

Bounds vs BoxCollider producing different sizes when provided same values?

$
0
0
I've been working in Unity to build a tool that can read data from a natively unsupported model format. One of the things this format does is have its bounding boxes connected to the bones. Unity does not support putting Bounds directly onto transforms, so I compromised by using BoxColliders instead. Now here's where things have gotten confusing for me. I have an array of Bounds that the values are read into (this format lists the maximum and minimum values of the bounding boxes): for(int i = 0; i < bounds.Length; i++) { bounds[i].SetMinMax(new Vector3(fmdl.GetSection0BlockDEntries()[i].minZ, fmdl.GetSection0BlockDEntries()[i].minY, fmdl.GetSection0BlockDEntries()[i].minX), new Vector3(fmdl.GetSection0BlockDEntries()[i].maxZ, fmdl.GetSection0BlockDEntries()[i].maxY, fmdl.GetSection0BlockDEntries()[i].maxX)); } //for From there, I assign them to the BoxColliders using the center and size values: BoxCollider collider = bones[i].gameObject.AddComponent(); collider.center = bounds[fmdl.GetSection0Block0Entries()[i].boundingBoxId].center; collider.size = bounds[fmdl.GetSection0Block0Entries()[i].boundingBoxId].size; Everything seems to work well for the most part. The layout of the boxes is correct, but the BoxColliders are too big: ![alt text][1] I thought that maybe the bones were getting layed out incorrectly; But they are not. Here are the bones compared to the BoxColliders: ![alt text][2] And even more interesting, if the same Bounds that I've been using the sizes from to create the BoxColliders are applied as the meshes' bounds, their size is correct (not all of the bounds get applied because the bounding boxes are meant to be applied to the bones): mesh.bounds = bounds[i]; ![alt text][3] So my question is, what's going on with the BoxColliders? Why are they so big when the same values applied to the meshes' bounds are the correct size? Is there anything I can do to fix this? Thanks in advance. [1]: https://i.imgur.com/2CFI1Og.png [2]: https://i.imgur.com/AD4QBkL.png [3]: https://i.imgur.com/YWYxMVL.png

Viewing all articles
Browse latest Browse all 416

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>