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
1
Question by MountDoomTeam · Nov 22, 2012 at 03:09 AM · rotationresetvertexworld

Vertex World Rotation?

increasing a vertex.x on a mesh is the same as changing it's transform.position.x if the object is not rotated, ...IF the object is rotated, it's the same as changing its transform.localPosition.x, I am obliged to change its localposition when the object is rotated, but I want to change its world position.

Say I have 20 rotated objects and I want to change the vertices all according to world position, there is no easy way to do that in unity, because I'm obliged to increase the vertex coordinates in their local rotation, and therefore local position.

Is there a way to solve the above issue? so that increasing vertex.x sends a vertex towards the right no matter the rotation of the mesh?

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

4 Replies

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

Answer by YM_Industries · Nov 22, 2012 at 08:51 AM

You can use transform.TransformDirection, transform.TransformPoint and the inverse functions of these to accomplish this. (This is basically just a summary of the comments above, posted here so the question will show up as answered.)

Comment
Add comment · Show 3 · 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 MountDoomTeam · Nov 22, 2012 at 01:37 PM 1
Share

complete solution is-transform.TransformPoint prior to moving the vertices,and transform.InverseTransformPoint again prior to writing them back to the mesh

avatar image YM_Industries · Nov 22, 2012 at 08:24 PM 0
Share

Awesome, glad you solved it!

avatar image YM_Industries · Nov 22, 2012 at 08:25 PM 0
Share

How did I manage to make 3 answers? I only meant to make one...

avatar image
3

Answer by YM_Industries · Nov 22, 2012 at 05:38 AM

I'm not entirely sure I understand exactly what you want to do here, but these should point you in the right direction. Let me know if you need more help. You can use transform.TransformPoint() to transform a point from local space to world space. You can also use transform.InverseTransformPoint() to convert from world space to local space.

So your solution might look something like this:

 Vector3 newVertex = new Vector3(transform.TransformPoint(vertex));
 newVertex.x+=5;
 newVertex = transform.InverseTransformPoint(newVertex);

Good luck!

Comment
Add comment · Show 5 · 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 MountDoomTeam · Nov 22, 2012 at 06:45 AM 0
Share

hi thanks i didnt know about inverse transform point! at the moment I already use

      var vertex = vtxArray[i];
     vtxArray[i] = transform.TransformPoint(vtxArray[i]);

so it takes lots of tiles and changes them as if they were a continuous plane. however I started rotating some of the tiles, and the vertex changes now happen perpendicular to the way the tiles are facing, rather than happening relative to the way the world is facing. I want to bend the tiles of the floor up, and then the tiles of the adjoining walls up as well, but the adjoining walls bend in.

I could make 6 different cases for the 6 different rotations of the tiles, but I would prefer a more logical solution.

For example if I could keep the GameObject rotation at right angles, but to reset the perceived rotations setting at 0, 0, 0 in the Inspector, then the vertex calculations would all happen along the same rotation. for that I would have to somehow reset the GameObject, or recalculate the mesh.

the problem is you can calculate the world position of all the vertices, but vertex.x still the local rotation of the GameObject, so if the GameObject is rotated, then transform point becomes a bit ineffective for making vertex changes according to world space.

avatar image YM_Industries · Nov 22, 2012 at 07:37 AM 0
Share

Still not entirely sure what you want, but do you want to effectively un-parent your vertex from your GameObject?

avatar image MountDoomTeam · Nov 22, 2012 at 08:31 AM 0
Share

I think I have to learn how to use transform.TransformDirection it changes direction from local to world space.

avatar image YM_Industries · Nov 22, 2012 at 08:37 AM 0
Share

Probably. I use transform.TransformDirection quite a lot in my game, and I only learned it 2 days ago. Just one of those things that's really useful.

avatar image MountDoomTeam · Nov 22, 2012 at 08:49 AM 0
Share

thanks man! I'll have to read a lot about it, it's pretty hazy right now-I marked you up on another thread! I hope someone knows how to TransformDirection of a vertex axis movement!Cheers

avatar image
1

Answer by YM_Industries · Nov 22, 2012 at 08:51 AM

You can use transform.TransformDirection, transform.TransformPoint and the inverse functions of these to accomplish this. (This is basically just a summary of the comments above, posted here so the question will show up as answered.)

Comment
Add comment · Show 9 · 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 MountDoomTeam · Nov 22, 2012 at 08:59 AM 0
Share

the question isn't really answered though, because I need to move 3 individual vertex coordinates, and TransformDirection is used to calculate Vector3 directions, it's actually really complicated for a beginner to calculate vertex(x.y.z) to individually change up and down left and right according to world directions rather than local rotation. I have still no idea how to use the TransformDirection for vertices.

avatar image YM_Industries · Nov 22, 2012 at 09:19 AM 0
Share

No problem if the question isn't answered, just mark it as answered once it is. transform.TransformDirection isn't meant to be used on vertices. Vertices should use transform.TransformPoint ins$$anonymous$$d.

avatar image MountDoomTeam · Nov 22, 2012 at 11:06 AM 0
Share

lol! ok. so if you turn the object and increase vertex x it goes up ins$$anonymous$$d of right... maybe there is a way to make it go towards world x axis.

avatar image YM_Industries · Nov 22, 2012 at 11:07 AM 0
Share

When you say towards the world x axis, do you just want the vertex to have its X value increase? In simple terms, what do you actually want to happen here?

avatar image MountDoomTeam · Nov 22, 2012 at 12:25 PM 0
Share

in layman's terms, when I turn an object and increased its vertex.y coordinates, I don't want them to translate sideways, I want to translate upwards. Same as they would do if the object was not rotated.

so if I take 10 objects and rotate them all different, and increase some vertex.y coordinates of all of them, I want their vertices to all move upwards and not all upwards according to their local rotation.

Show more comments
avatar image
0

Answer by drudiverse · Aug 22, 2015 at 11:33 PM

I am not totally convinced about this page...

The transform. transformDirection will tell you the vector orientation of the object, which is super difficult afterwards to use...

So transform transformpoint, fine gets you the world position and scale of vertices...

and afterwards transfor direction, you would have to use it to pivot every vertex around some point in space to find the position of every vertex including their world position and world rotation...

so you would have to use some kind of crazy rotate around to match the difference in between upwards and rotated object.

I am pretty sure of that from experience.

How to do it is sooo much coding and rotations. OMG. i don't know off hand how to do it and it cant be a trivial afternoon task for an average programmer.

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

11 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

Related Questions

Store initial rotation in JavaScript 2 Answers

Reset posiotion 1 Answer

How to reset rotation of object after AddTorque has been applied? 1 Answer

Camera position/rotation reset after 5 seconds of mouse inactivity 0 Answers

Help With Simple Rotation 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