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
2
Question by ina · Mar 03, 2011 at 09:31 PM · meshproceduralverticesmirrormeshfilter

Mirror vertices procedurally

For a mesh being edited procedurally, how do you mirror the manipulation operation across a particular axis/plane?

Can you assume the vertices are always zeroed around the origin?

--

Would you necessarily have to create a "buffer" to store the coordinates, to know which vertex/normal index to invert to mirror?

Is this the idea on mirroring a manipulation on position coord with yz plane symmetry?

function storeGlobal(mesh){ var vertices=mesh.vertices; var normals=mesh.normals; for(i=0;i<vertices.length;i++){ globalMeshVar[vertices[i]]=normals[i]; } }

function mirror(coord,plane,disp){ var vertices=globalMeshVar.vertices; var normals=globalMeshVar.normals; for(i=0;i<vertices.length;i++){ if((vertices[i] - coord)==0){ globalMeshVar[vertices[i]]+=disp*normals[i]; globalMeshVar[plane - vertices[i]]+=disp*(-normals[i]); } } }

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by duck · Mar 03, 2011 at 09:35 PM

Yes, vertices in mesh data are stored in local coordinates, so to mirror them about any of the three local axes, you can just invert the sign of the position value.

For example, flipping the vertices on the mesh's local X axis:

var vertices = mesh.vertices;

for (var i = 0; i < vertices.Length; ++i) { var v = vertices[i]; vertices[i] = Vector3( -v.x, v.y, v.z ); }

mesh.vertices = vertices; mesh.RecalculateBounds();

Comment
Add comment · Show 4 · 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 ina · Mar 04, 2011 at 04:12 AM 0
Share

Still not sure how the workflow goes: would I have to store an intermediate array of mesh data to know which mesh index to "flip"? (See updated snippet above)

avatar image ina · Mar 09, 2011 at 05:12 PM 0
Share

This looks like it just flips the vertices ins$$anonymous$$d of actually mirroring ... I guess my confusion has to do with how you assign the vertices array for a mirror operation programmatically

avatar image duck ♦♦ · Mar 10, 2011 at 10:02 AM 0
Share

what's the difference between flipping and mirroring?...

avatar image ina · Mar 10, 2011 at 09:45 PM 0
Share

mirroring maintains the geometry on the other side as well..

avatar image
0

Answer by Martin_Th · Feb 03 at 05:46 PM

I can mirror my mesh but some faces are not visible. I recalculate the normal vector from the faces. Is their anything to do else?,I can mirror my mesh with this but some areas are not visible. Is thier any workaround?

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

1 Person is following this question.

avatar image

Related Questions

Selecting a single polygon / face at runtime 1 Answer

MeshCollider is not getting updated when adding vertex to mesh 1 Answer

UV-ing a sphere procedurally 1 Answer

sharedMesh - what is the mesh shared with? 1 Answer

Bounds of dynamic mesh not updating 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