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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
2
Question by samid · May 16, 2013 at 09:32 PM · meshnormalsgeometry

Conform mesh to arbitrary surfaces?

Hi there, wondering whether this is feasible or not. I'm looking to create a planar mesh mouse cursor that conforms (folds) to follow adjacent surface normals. See image and code below to see the start of my logic - the red area being the photoshopped goal.

I can't imagine how to do this without checking each vertex of the cursor against colliders, starting from the original hit point and radiating out. First problem with this logic is that it's doing my head in simply considering how to start. Second problem is whether it's feasible to shoot out that many rays each frame.

Any suggestions on how to proceed would be greatly appreciated.

alt text

 void Update () {
     RaycastHit cursorHit;
     Ray cursorRay = cam.ScreenPointToRay (Input.mousePosition); 
     if (Physics.Raycast(cursorRay,out cursorHit,500,hitLayer)) {
         materialMarker.transform.position = cursorHit.point;
         materialMarker.transform.rotation = Quaternion.LookRotation(cursorHit.normal);
         materialMarker.transform.Rotate(90,0,0);
         materialMarker.transform.Translate(Vector3.up*0.01f);
     }    
 }
normals.jpg (160.0 kB)
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

3 Replies

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

Answer by Bunny83 · May 16, 2013 at 10:54 PM

Well an arbitrary approach is not really easy. You have to create the geometry procedural. The tricky thing is the edge clipping. The easiest approach would be to use MeshCollider for all of the surfaces. That way you get a lot of information from the hit point when you raycast at the object. You get the triangle index you hit as well as the barycentric coordinate of the hit. With those you can create a sub-piece on this triangle. Now you would check if your desired size of your projected plane is larger than the distance from the hitpoint to the 3 edges of the triangle. If it is larger you have to find the neighbor triangle and create the next piece of mesh there.

As i said it's not easy to get this working with arbitrary gemoetry.

btw: Do you want a linear projection onto the object or should it really be "folded" around the edge so it doesn't keep it's original shape?

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 samid · May 17, 2013 at 02:14 PM 0
Share

No, an arbitrary approach is not easy. I was hoping it would be slightly easier than the method you suggest. A lot to learn. Found this example, and in slow motion I still cannot quite work it out...perhaps it's all produced with normal averaging, depth of fielding projectors.

Anyway, a project for the weekend! Thanks!

avatar image Bunny83 · May 17, 2013 at 03:08 PM 0
Share

Well, if you just want a "highlight" it might work with a custom shader were you feed in a worldposition of your mouse target and in the fragment shader you simply highlight every "fragment" that's within a certain radius(in 3d space). This should give this effect without any additional geometry ;) You might be able to simply add another material to the mesh under the cursor (the meshes around the cursor) and let this material just draw the highlight. It would actually be a similar approach to the projector, but without any special projection math ;)

avatar image
0

Answer by Graham-Dunnett · May 16, 2013 at 09:36 PM

Sounds like something the Projector could do for you.

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 samid · May 16, 2013 at 10:14 PM 0
Share

Thanks for the suggestion, I was looking into it earlier but unfortunately I don't see it being quite that simple...unless my illustration below is way off base?

alt text

projector.jpg (150.5 kB)
avatar image
0

Answer by adrien_grs · Sep 07, 2015 at 01:20 PM

Hey!

Did you managed to solve this problem ? I am very curious about this issue :)

Thank you in advance,

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

16 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

Related Questions

Procedural mesh, half the faces have wrong normals 1 Answer

What are normals? 1 Answer

duplicate and flip mesh in code 5 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Trying to create a hard edged procedural torus mesh 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