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 question was closed May 09, 2013 at 11:53 PM by Fornoreason1000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Fornoreason1000 · May 09, 2013 at 09:12 PM · modeluvtrianglesmapping

Tris and UVS mapping for mesh generation.

hi, I've been generating meshes via Mesh class. Regular planes are simple, since there geometer is a big loop with a single cut. but for more complex planes such as this im unsure how one would map the triangles or UVs.

reading this doc(http://docs.unity3d.com/Documentation/Manual/UsingtheMeshClass.html) tells me that the vertices follow a "clock-wise" rule, which is easy to implement on a 4 vert plane. but a 4 vert with an inset? there can anyone explain how one would work out which vert is which? assuming the lower left most is 0?

here is the mesh im trying to generate: alt text

trial and error seems to be getting me nowhere as hopelessly deformed meshes pop up in front of my screen. why is this overlooked in the docs, it has regular one 4 vert plane and nothing else...All I know is that the triangles need to be a 30 sized array, with number ranging from 0-7.

the vertices themselves are there, after trial an error of seen the deformed geometry wap itself.

I don't understand how the UV's work either, with regular planes the vector values are 1 or 0. are they based on ratios between vertices? I don't even know where to start with these guys.

if it helps here is a snippet of plane-gen code

  mesh.vertices = new Vector3[] {
             Manager.GUI.ScreenToWorldPoint(new Vector3(0f,0f,0f)),
              Manager.GUI.ScreenToWorldPoint(new Vector3(padding,padding,0f)),
             Manager.GUI.ScreenToWorldPoint(new Vector3(width,padding,0f)),
              Manager.GUI.ScreenToWorldPoint(new Vector3(width + padding,0f,0f)),
             Manager.GUI.ScreenToWorldPoint(new Vector3(width, height, 0f)),
             Manager.GUI.ScreenToWorldPoint(new Vector3(width + padding, height + padding, 0f)),
             Manager.GUI.ScreenToWorldPoint(new Vector3 (padding, height,0f)),
             Manager.GUI.ScreenToWorldPoint(new Vector3 (0f, height + padding,0f)),
 
         };
 
         mesh.triangles = new int[] { 
          0, 5, 6, 
          0, 6, 2, 
          0, 4, 1, 
          0 ,4, 3,
          0 ,3, 4,
          7, 5, 2, 
          3, 4, 5,
          5, 3, 2,
          6, 0, 2,
          3, 4, 1
 };
         mesh.uv = new Vector2[] {
             new Vector2(0,0), new Vector2(1,0),
             new Vector2(1,1), new Vector2(0,1),
             new Vector2(0,0), new Vector2(1,0),
             new Vector2(1,1), new Vector2(1,1)
 
 
         };
 
 
         mesh.RecalculateNormals();

I just punched random numbers for the triangles and UVs as you can tell. thanks in advance

d4.png (8.2 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

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by Loius · May 09, 2013 at 10:26 PM

(Your padding isn't actual padding; it should be multiplied by two when finding the far right/bottom sides because there are two pads + widht/height to get to those; that may be throwing you off)

This is all standard 3D stuff, not unity-specific; that's why it's not detailed in the manual (I assume)

I see this pattern in your vertices:

 7  5
  64
  12 
 0  3

You need to build all the triangles, and they all need to be wound the same way - CW triangles would be:

 7,5,6,
 6,5,4,
 4,5,3,
 2,4,3,
 0,2,3,
 0,1,2,
 0,7,6,
 0,6,1,
 
 1,6,4,
 1,4,2

UV is a ratio of what part of the image should show at the vertex. If you want the whole image to cover that set of triangles, then uv for the four corners is:

 0,0,
 .
 .
 1,0,
 .
 1,1,
 .
 0,1

The UV for the inner points is just some maths; point 6 would be (p/(p*2+w), (p+w)/(p*2+h))

Comment
Add comment · Show 3 · 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 Fornoreason1000 · May 09, 2013 at 10:34 PM 0
Share

thanks... I don't usually work with 3d stuff such as meshes like this, i usually build things like game play code. sorry if this was a long but annoying for you.

I tried looking this up with google but it kept co$$anonymous$$g up with the $$anonymous$$esh class itself any suggestions with fnding information like this?

thanks again...

avatar image Eric5h5 · May 09, 2013 at 10:45 PM 1
Share

As Loius said, none of this is Unity-specific, so when searching don't include "Unity".

avatar image Fornoreason1000 · May 09, 2013 at 11:55 PM 0
Share

thanks, I just thought that Unity handled them specifically this way... question closed

Follow this Question

Answers Answers and Comments

15 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

Related Questions

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

problem with MirrorReflection 1 Answer

Would like to hear the best way to make houses with interiors 0 Answers

Easy way to convert a bunch of vertices to triangles or uv's? 1 Answer

MMD How to export model and animations to Unity as 3rd person controller? 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