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 SolidRoots · Jan 20, 2014 at 06:55 AM · 3d modelsmesh manipulation

How to manipulate the Shape of a 3D object at runtime

I am attempting to create a simple Clay modeling app for Kindergartners. What I would like is to allow the player to Dent and Stretch a piece of Clay by touching any area of the clay (ex: touching an area of the clay should show a visible dent in the clay and stretch the clay as a result). How would I go about doing this? I am new to Unity and am unable to find information for this kind of behavior. Would appreciate if someone could point me in the right direction or suggest some methods that I could take a look at.

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 · Jan 20, 2014 at 07:01 AM 0
Share

This is a cool idea, but this is a complicated place to start with Unity. You might start by downloading the Procedural Examples project from the Asset Store (free). You might also take a look at the $$anonymous$$egaShapes and $$anonymous$$egaFiers stuff:

http://www.west-racing.com

It's a bit pricy compared to a lot of Unity add-ons, but it might save you a bunch of development time.

avatar image moghes · Jan 20, 2014 at 07:50 AM 0
Share

I would recommend Procedural Examples as well. It gets input from a mouse, and I am working on Leap controller version of this example.. Check it out as ask if you have any questions.

avatar image SolidRoots · Jan 24, 2014 at 10:11 PM 0
Share

Thank you for the suggestions. I pretty much figured that this would be tricky and I did have a look at the $$anonymous$$ega Shapes, it seems like that is the best option for me, as time is a bit of an issue.

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by brycedaawg · Jan 20, 2014 at 04:49 PM

The geometry of a GameObject is held within it's Mesh; it contains useful data such as triangles and vertex arrays which can be manipulated in order to alter the GameObject's shape. It's pretty easy to stuff up a mesh if you don't know what you're doing with it, so here's a brief explanation of how Unity handles it's vertices contained within a Mesh.

Firstly, Unity draws GameObject's exclusively using triangles. A cube, for instance, would be made up of six sides, with each side consisting of two triangles put together to make a square. One way of storing vertex data for a shape like this would be to keep it in a single array. To Draw from this array, Unity could iterate through it three vertices at a time, rendering out each triplet of vertices in the order that they appear. The problem with this approach comes into play when you consider most Meshes use each vertex more than once, meaning that this would require a lot of duplicate vertices.

The other, more clever way of storing vertex data is to have two arrays; one that stores vertex data and another that stores the triangles. This triangles array stores integers that represent the index of the intended vertex inside the vertex array. It is this approach that Unity uses.

So to circle back to the original question; how to manipulate the shape of a 3d object at runtime, you need to set mesh.vertices and mesh.triangles to alter the shape of a GameObject. Keep in mind that both these properties return a copy of the original data. To alter them, you need to store a copy of the original data as a variable, make any changes you wish to the copy and then set the property to the copy using the = operator.

Here's a link to Unity's script reference of the Mesh class. You'll also need to look over uv's because they're required to draw a Mesh properly. Hopefully this gives you something to work with in terms of learning how to manipulate a GameObject's Mesh. Good luck with your Clay Modelling App!

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 SolidRoots · Jan 24, 2014 at 10:15 PM 0
Share

Awesome, this helped me really wrap my $$anonymous$$d around how $$anonymous$$esh Geometry works in Unity. Thank you for this very precise break down, I finally have a starting point to try and test some things out. $$anonymous$$uch appreciated!

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

21 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

How Can I make 3D Roads? 1 Answer

Detect click on dynamically generated mesh in Unity2d 1 Answer

delete specific triangles / polygons in a mesh 2 Answers

How to generate a track / path mesh using waypoints,How do I generate a track / path mesh using waypoints 0 Answers

Unity Lags With Imported 3D Models 2 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