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 moontoad · Dec 11, 2014 at 09:16 PM · physics

How would I cut geometry in real-time?

Ok lets say I had a piece of rectangular wood. What if I wanted to use an axe to cut the one piece into two parts at any place in the geometry into two semi-equal parts? Is there an easy way to accomplish this?

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
0

Answer by richyrich · Dec 11, 2014 at 09:25 PM

Edit: Re-read the question ;)

The way I have done something similar was to define all my cuboids by a start point and an end point both at the centre of each end. To split, all that is required is to identify the hit point on the collider, then find the projection of this point to an imaginary line that runs between the two points - this gives you the breaking point.

You can then centre the original wood piece (transform.position) on the midpoint between the start and the break point. You then retrieve from a pool of pre-created objects, another GameObject and centre that halfway between the breaking point and the end.

You then recreate your meshes with procedural edit code. Let use know if you need more info.

Quick answer: Yes it can be done

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

Answer by Habitablaba · Dec 11, 2014 at 09:40 PM

I'm doing something similar in my game. My idea was to find the split point and create a plane at that location with a normal along the mesh object's forward vector (you could use whichever one splits your mesh the way you want it.

Then, I loop through all of the vertices in sets of 3 (for triangles) and determine which side of the plane they are on. Triangles that split the plane are arbitrarily assigned to a side in this case. I didn't want to deal with splitting triangles and all that.

In the below code, I'm just getting the list of triangles for each mesh. Later, two new arrays of vertices are created from the lists of triangles and the original vertex array.

After that, I create the needed game objects and add all the components they need. Then assign the new meshes to the proper object.

Hope this helps!

     var plane = 
        new Plane(this.transform.forward, pivotPoint);
     
     for(int i = 0; i < mesh.triangles.Length; i+=3)
     {
       index1 = mesh.triangles[i];
       index2 = mesh.triangles[i+1];
       index3 = mesh.triangles[i+2];
       
       vertA = (mesh.vertices[index1]);
       vertB = (mesh.vertices[index2]);
       vertC = (mesh.vertices[index3]);
       
       if(!plane.GetSide(vertA) && 
          !plane.GetSide(vertB) && 
          !plane.GetSide(vertC))
       {
         triangles1.Add(index1);
         triangles1.Add(index2);
         triangles1.Add(index3);
       }
       else
       {
         triangles2.Add(index1);
         triangles2.Add(index2);
         triangles2.Add(index3);
       }
     }
 
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D 360 degress platformer example needed 0 Answers

ways to get Collision2D 2 Answers

RaycastAll failing inconsistently 1 Answer

Every time my character hits or touches the walls he gets stuck or acts as if the object the character hit was a magnet. 0 Answers

Golfball sphere collider "Hops" over vertex-joined planes at intersection? 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