|
how would I set a renderers bounds (center and extents) in script? the inspector provides access to it, but I know its read-only when I try to do the same in a script. Thanks.
(comments are locked)
|
|
Renderer.bounds just tells you the bounds of the renderer. This depends on the object it is rendering. You can't set the bounds, why would you? The bounds are a result of the objects position / scale / rotation. there are some issues with the model/rig that require manual adjustments (and unfortunately fixing the rig is not an option)
Jul 30 '12 at 10:42 AM
unity.editor
Well, if you want to set the bounds manually, you have to set Mesh.bounds, not Renderer.bounds. The renderer is just a component which renders the mesh. The Mesh represents the actual data.
Jul 30 '12 at 01:35 PM
Bunny83
tried that to no avail, thanks for the suggestion!
Jul 31 '12 at 02:22 AM
unity.editor
I just tried it myself and it works like expected... When i insert a cube and change the mesh bounds, the isVisisble flage is changing like expected. What kind of problems do you have? Usually the bounds are calculated correctly for any kind of mesh, so where or how do you experience problems?
Jul 31 '12 at 02:44 AM
Bunny83
Again, Renderer.bounds is determined at runtime. It's not stored anywhere. It represents the axis-aligned-bounding-box (AABB) that encloses the rotated mesh.bounds. mesh.bound can be changed manually, but Renderer.bound is always an AABB, so when the object is rotated, it will be larger. How does your object look like? If the mesh is already rotated in local space, the mesh.bounds will already be too large. The bounds can't be rotated to match your object shape. Mesh.bounds is a local AABB and Renderer.bounds a worldspace AABB.
Jul 31 '12 at 01:21 PM
Bunny83
(comments are locked)
|
|
If you are creating a mesh a runtime, then you might be looking for Mesh.RecalculateBounds. Otherwise, as @Bunny83 said, there is not need to set the bounds yourself. thanks for the replies, but there are issues with the model and rig I received leading to my need to do some manual adjustments. I was hoping to automate this, but I guess that isn't possible (and neither if fixing the rig).
Jul 30 '12 at 10:41 AM
unity.editor
I tried that but since the model/rig are at fault, it just recalculates the same bad bounds and fixing the rig is not currently an option.
Jul 30 '12 at 10:46 AM
unity.editor
(comments are locked)
|

