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 gamesbyangelina · Jul 20, 2013 at 03:51 PM · 3dmodelorigin

Finding the center point of a model

I'm automatically downloading 3D models from the web for use in a game project. This means I didn't make the models, and have never seen them before. My Unity project places them automatically within the 3D world. I've noticed that these models often do not have their local origin as the dead center of the model. In fact they can be wildly off.

This answer: http://answers.unity3d.com/questions/359023/is-a-mesh-vertice-position-relative-to-the-center.html seems to suggest that scale and rotation play a part in it. But setting scale to 1,1,1 and rotation to 0, the origin is clearly not the middle of the model I'm looking at right now. I assume this is because the modeller build the model off-origin in their modelling program?

This is a huge problem for me. Is there a way to 'reorient' the origin to be the center of the model's mesh, automatically in code?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Kiloblargh · Jul 20, 2013 at 03:58 PM

Yes. You need to process mesh.vertices, which is an array of local Vector3 positions. You could average all of them, or just find the max and min x, y, and z values and average those. Then you go through again and subtract the offset of the calculated center point from every vertex.

Don't try to change mesh.vertices[n] directly, do it like in the example, where you copy the array, modify the copy, and then write it back when you're done.

Comment
Add comment · Show 1 · Share
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 gamesbyangelina · Jul 20, 2013 at 04:05 PM 0
Share

Brilliant! Thank you so much. I know nothing about 3D modelling yet so I'd never have got to this.

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

15 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

Related Questions

Animation cant be found even if attached to object? 1 Answer

Human model clothes 1 Answer

Convert Trail Render To Solid Object 0 Answers

3d Model from Maya does not animate limbs - only animates entire model rotation 2 Answers

Textures appears blurry on the objects I make! 0 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