Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by lachesis · Oct 28, 2013 at 04:30 PM · rendererbounds

Axis Aligned Bounding Boxes, Extents, and Rotation

I'm creating a set of cubes at runtime whose sizes vary with some inspector-exposed variables. I'm attempting to write code that grabs the size of a cube's face after generation, which would allow for any changes to the inspector-exposed variables.

In searching for the right methods to grab this information, I've settled on renderer.bounds, which has introduced Axis Aligned Bounding Boxes to my world. I've had success in grabbing the size of an 8x8 plane in the x and z axes like this:

 Vector3 faceSize = thisFace.renderer.bounds.size;

which returns

 Vector3(8.0, 0, 8.0)

as expected. However, when I grab the same renderer's bounds.max, I get:

 Vector3(4.0, 4.0, 4.0)

I expected that the magnitude of the vector3 would be half that of the bounds.size, since the extents are measured from the renderer's center, per the documentation:

http://docs.unity3d.com/Documentation/ScriptReference/Bounds.html

Given that thisFace is a 2-dimensional plane, however, I did not expect the y value to contain anything other than 0.0.

I expect that this has something to do with the nature of Axis Aligned Bounding Boxes. I've had difficulty finding documentation on them. Can someone help me to understand why the extents extrude into the y-plane? Or what the Unity script reference means when it says that AABBs are "a box aligned with coordinate axes?"

EDIT: I'm imagining a box that encapsulates the rendered object at all possible rotations and, therefore, can be said to both always encapsulate an object and to ignore that object's rotations. This doesn't explain why bounds.size would return nothing in the y axis, however.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EvilWarren · Oct 28, 2013 at 08:55 PM 0
Share

Where is the centre of your cube? If it is (0,0,0) this makes perfect sense as you have an 8x8x8 cube. Remember bounds.max is a coordinate not a size. Therefore by the values you get, I assume this is the top face you're looking at, so (4,4,4) would be the position of the max corner. Check the $$anonymous$$ value for this face, if my suspicions are correct, this should be (-4,4,-4). If your cube is not centred at (0,0,0) or you are not looking at the top face, you should pretty much scrap everything I said and pretend I didn't type this...ahem

avatar image lachesis · Oct 28, 2013 at 11:27 PM 0
Share

$$anonymous$$akes sense! I was assu$$anonymous$$g that bounds.$$anonymous$$ and bounds.max returned a Vector3 that was relative to the center of the object, but if they're just global coordinates that $$anonymous$$imize and maximize a Vector3 while remaining on the rendered face of the cube, then it seems perfectly reasonable.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bounds.Encapsulate Not Working As Intended 1 Answer

Wrong positions from bounds 1 Answer

TextMesh.renderer.bounds.extents not 100% accurate? 2 Answers

Renderer.bounds.extenct.x; cant find bounds 0 Answers

How do I check if an object is completely visible? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges