Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Adamagocs · Jun 07, 2011 at 12:23 AM · meshruntimeissuevertices

Runtime mesh generation

Hy all,

I'm trying to create a mesh in runtime but I don't understand the Mesh class: How the vertices work for example.

I want to create a script that create's a mesh, and I can give them parameter like generatemesh(heights[], dimensionx, dimensiony) like a terrain. the heights should have different values only in one axis. so for example in every x=1 coord the height will be 5 and in every x=2 coord will be 10.

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
3

Answer by Jesse Anders · Jun 07, 2011 at 01:46 AM

The 'vertices' array contains the positions of the vertices in the mesh, and the 'triangles' array indexes into the 'vertices' array, with each set of 3 consecutive indices describing a triangle.

You can arrange the vertices however you want, but for something like this you'd typically arrange the vertices by row and then by column or vice versa. Generating the triangle indices then just involves a loop and a little arithmetic.

For examples of how to create meshes via code, check out the examples in the documentation for the Mesh class (if you haven't already), and the 'procedural mesh' examples on the Unity website.

Comment
Add comment · Show 4 · 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 Adamagocs · Jun 07, 2011 at 04:12 PM 0
Share

Thanks for explaining, it's working now! But I got some new issue. I created square from 2 triangle, but the texture only appears on the first triangle. What should I do?

avatar image Jesse Anders · Jun 07, 2011 at 04:38 PM 0
Share

$$anonymous$$ake sure both triangles are wound the same way (I'm assu$$anonymous$$g you're not using a two-sided shader). If that doesn't solve the problem, try selecting the object and then exa$$anonymous$$ing the mesh in the scene view (it should appear in blue wireframe) to make sure there are actually two triangles.

avatar image Adamagocs · Jun 07, 2011 at 11:41 PM 0
Share

I'm sure that everything is alright, if I remove material the pink non-materialed "texture" is okay. I thought I must do something with that "uv" but that is another thing what I don't understand.

avatar image Jesse Anders · Jun 08, 2011 at 12:02 AM 0
Share

Incorrect texture coordinates could be the problem (although one triangle of a quad being rendered completely invisible is a bit unusual). Typical texture coordinates for a quad would be (0, 0), (1, 0), (0, 1), and (1, 1), with the order depending on the order of the vertex positions.

avatar image
0

Answer by insominx · Feb 08, 2013 at 09:54 PM

This video breaks the whole thing down pretty well: Unity Tips and Tricks

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 AceWillNeverDie · Sep 26, 2015 at 12:24 PM 0
Share

Thank you very much bro)

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

Change color of mesh triangle based on Y position in world space 1 Answer

Run Time Plastic Shrink/Wrap , Mesh Manipulation 0 Answers

Split single triangle mesh into 2 Equal Parts 0 Answers

Combining Mesh at Runtime via Script causes temporary FPS drop 1 Answer

Best way to transition one mesh to another with the option to change the target mesh 0 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