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 /
  • Help Room /
avatar image
0
Question by OrbitSoft · Jul 29, 2014 at 02:55 PM · meshtriangles

How to correctly assign triangles to a "Procedural Mesh"

I've watched a lot of tutorials about procedural generating of meshes but none of them actually talks about how to correctly assign triangles with real code, not just assigning the array... I think i understeand how it works the manual-way, the clockwise thing and so on... But after creating a simple test mesh i can't see any pattern in the triangles array.

alt text

I made a mesh with a house shape, and the triangles look like this:

 int[] triangles = { 0,3,2, 0,2,1, 3,4,2 };

But i can see no pattern in this.

So the question is: Is there any specific algorythm or are there any tutorials / someone can help? Or do i just have to figure it out?

mesh.png (1.6 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

4 Replies

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

Answer by VesuvianPrime · Jul 29, 2014 at 03:17 PM

Hey Wampir888

What kind of pattern are you looking for? When writing procedural mesh generation logic you're mostly going to be working with triangle strips:

alt text

So long as you keep your verts in a good order you can step through the triangles relatively easily. Even at a glance we can see that your triangles will be:

0,1,2

1,3,2

2,3,4

and so on.

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 OrbitSoft · Jul 29, 2014 at 03:26 PM 0
Share

Hi, actually i'm looking to make a font based mesh, so its more compilcated, but i have to start from somewhere... The thing i can't unders$$anonymous$$nd is how to write an algorithm that automatically detects which vertices a triangle will be composed of. Lets say i want to create a strip like the one in your image, i have no idea what formula to use in a for loop to get the vertices.

EDIT: Thanks a lot for the reply i now kind of know how it works.

avatar image Astiolo · Apr 07, 2015 at 03:18 AM 0
Share

This is a bit old. But VesuvianPrime, you seem to have made a mistake. Given the first triangle of 0,1,2 the second one should be 0,2,3.

Anyway, it's obvious how to write them out manually, but creating an algorithm isn't so simple and I am also interested in a good answer.

avatar image
0

Answer by dhurstdev · Dec 24, 2016 at 09:09 AM

I would refer here, you problem is prob. the order you set or normals or you never put the mesh on a GameObject etc...: http://answers.unity3d.com/questions/1207764/creating-a-plane-from-a-plane-equation.html#answer-1288444 & thank @TSLzipper... Also, you can double click the mesh and it will show you num Verts and num Tris... So where they show or now, you can see if those are correct first! GL

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 dhurstdev · Dec 24, 2016 at 11:48 PM

I would refer here, you problem is prob. the order you set or normals or you never put the mesh on a GameObject etc...: http://answers.unity3d.com/questions/1207764/creating-a-plane-from-a-plane-equation.html#answer-1288444 & thank @TSLzipper... Also, you can double click the mesh and it will show you num Verts and num Tris... So where they show or now, you can see if those are correct first! GL

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 UnPluks · Jan 03, 2017 at 05:08 AM

Hello. For anyone interested, this is what I do. The figure should be seperated into two shapes, a square and a triangle, otherwise it can still be done. First you get all the vertices in order, that would be {0, 3, 4, 2, 1} Then you check groups of 3. so for example, the first three is {0,3,4} so we must "mark" 3 as used. so we have a new group of numbers {0,4,2,1} Then again we take 3 {0,4,2} and mark 4 as used. later you have {0,2,1} thats your last triangle. and you have a valid arrangement. If you want more info you can ask me I can make a tutorial on my Youtube channel "Creagines"

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

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

Related Questions

Some triangles are black on a mesh generated by script 1 Answer

How can I remove shooted mesh of object? 0 Answers

Mesh generation triangles issue 0 Answers

Normals and triangles 0 Answers

Vertex Coloured Shader for trianges. 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