Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 $$anonymous$$ · Nov 23, 2014 at 05:10 PM · rotationverticesvertexpivotdegrees

Real pivot rotation of all vertices in a mesh?

I need to rotate a mesh by actually moving all the vertices, NOT by changing the transform.rotation of the gameobject. In other words, the mesh should rotate by the vertices, but the tranform.rotation of the mesh remains unchanged at 0,0,0.

So, say I have a vertex located at x,y,z of 50,0,50... how would I rotate that vertex by 60 degrees clockwise around the y axis? Assuming the pivot point of the mesh is centered at 0,0,0?

Comment
Add comment · Show 3
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 robertbu · Nov 23, 2014 at 05:11 PM 0
Share

You can use the Rotate$$anonymous$$esh() editor script in the following question as a basis for your code:

http://answers.unity3d.com/questions/561786/how-to-export-obj-from-editor-with-rescaled-mesh.html

avatar image $$anonymous$$ robertbu · Nov 23, 2014 at 05:25 PM 0
Share

Actually, it looks like there is a unity function just for this http://docs.unity3d.com/ScriptReference/$$anonymous$$atrix4x4.TRS.html

avatar image robertbu · Nov 23, 2014 at 05:53 PM 1
Share

I've converted my answer to a comment because for the actual rotation, @Cherno's answer is right and the code I pointed you towards does not do what you asked. You don't need a $$anonymous$$atrix4x4 to solve your problem. You only have to to multiply the vertices by a Quaternion representing your rotation.

But there are a few other things to consider that are handled in the code above. For example, you will need to either rotate the normals or recalculate the normals, and recalculate the bounds. And if your object has a collider, you need to address the changed geometry.

2 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by Cherno · Nov 23, 2014 at 05:41 PM

I do it like this:

  Vector3 center = new Vector3(x, y, z);//any V3 you want as the pivot point.
  Quaternion newRotation = new Quaternion();
  newRotation.eulerAngles = new Vector3(0,0,0);//the degrees the vertices are to be rotated, for example (0,90,0) 
     
  for(int i = 0; i < vertices.Count; i++) {//vertices being the array of vertices of your mesh
       vertices[i] = newRotation * (vertices[i] - center) + center;
  }
Comment
Add comment · Show 2 · 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 Devilwhale · Apr 26, 2017 at 08:29 PM 0
Share

Thanks, This works great!

avatar image yesmanfree · Jun 21, 2018 at 03:48 AM 0
Share

this works for me as well

avatar image
0

Answer by BergOnTheJob · Jul 10, 2020 at 05:04 PM

if anyone is looking, this tool can move, rotate, and scale a mesh's vertices without changing the object's transform.

https://assetstore.unity.com/packages/slug/166155

it also has a bunch of other modeling tools if you want to further edit your mesh.

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

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

6 People are following this question.

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

Related Questions

Pivot modifying script 0 Answers

What are some practical ways performance-wise to get a set of vertices in an area? 1 Answer

Help with gun accuracy in degrees. 3 Answers

Constrain object rotation set by mouse? 1 Answer

How to change the pivot point of a mesh in script? 1 Answer


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