• 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 AgentFire · Aug 16, 2014 at 02:02 PM · mesharrayplanevertextriangulation

How to create a 2D mesh from a vertex array?

I have read basics of creating a mesh in run-time in Unity, however, the task I have placed before myself seems too hard for me and I'd like to have some help here.

The input is an array of 2D vertices, representing a closed concave or convex polyline. I want to create a 2D mesh (a plane one) based on those vertices.

An example of the input is displayed below:

 <Vertex X="-2000" Y="-1800" />
 <Vertex X="-2000" Y="1800" />
 <Vertex X="-1800" Y="2000" />
 <Vertex X="1800" Y="2000" />
 <Vertex X="2000" Y="1800" />
 <Vertex X="2000" Y="-1800" />
 <Vertex X="1800" Y="-2000" />
 <Vertex X="-1800" Y="-2000" />
 (It is quite possible to have the last row equal to the first one here.)

Which should create a mesh with this form (click to enlarge):

![alt text][1]

[1]: http://i.snag.gy/6WjwE.jpg

Now, I have heard this thing might be called triangulation, however, I cannot find a good explanation of the algorythm involving concave polyline as well as convex one. Most mentioned Delaunay's does not cover concave triangulation.

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

1 Reply

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

Answer by robertbu · Aug 16, 2014 at 02:02 PM

Take a look at the Triangular script in the Unity Wiki. I think it does what you want out of the box.

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 AgentFire · Aug 16, 2014 at 08:42 PM 0
Share

@robertbu Thanks!

avatar image Cherno · Aug 17, 2014 at 01:55 AM 0
Share

If it helped you, please flag robertbu's answer as correct.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Unidirectional slicing algorithm of a mesh 0 Answers

Changing Y Value in Vertex Array? 1 Answer

Array of Verticies 1 Answer

Mesh.triangles specification 1 Answer

Texture issue on subdivided+triangulated mesh 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges