Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Exuro89 · Dec 28, 2017 at 06:04 PM · meshvertices.objtexturecoord

Manually loading .obj file, issue understanding UVs

Hello!

I'm trying to convert a .obj to a mesh via a script but I've become confused as to how to map from what the obj has to the fields in the Mesh object. So the mesh object has

vertices normals uvs triangles

I'm moving all of the vertices from my .obj (indicated with v prefix) into an Vector3 array and pass that to vertices. Then I'll get the triangles, normals and uvs from the v/vt/vn lines. I've managed to get a pink object showing up that looks correct. I tried applying a texture and turns out my uvs aren't correct. My assumption was to take the vt from v/vt/vn lines and set up an array such that my vertex array has an accompaning vt array that would associate a vertex with a texture coord(vert[i] is paired with texCoord[i]. This sounds right to me, but I've noticed in my .obj that sometimes a vertex has different texture coordinates ie...

 f 12/2/3 10/2/3 11/2/3
 f 13/1/3 12/1/3 11/1/3

In the above example on the first line vertex 11 has a texture coordinate of coord 2. In the second like vertex 11 has coord 1 though. Would this not mean that a single vertex has two different coordinates? I'm a little confused as to what I'm supposed to do here. Any clarification on uvs and vertices would be great.

Edit: As a more concrete example, I have a 1x2x1 voxel, where I set one side of it to red and another side to blue(to break down where the problem is occuring). The 8 vertices that lie on the seam between the two colors are getting 2 texture coordinates each, which makes sense is thats where the colors meet. I'm not sure how this gets passed into the mesh object though as you need to have the same number of UVs as you do vertices.

Edit2: So I went and checked the vertex count between what the file has vs what unity does on its own. It turns out the unity one has 8 more vertices, so I'm guessing it checks to see that a vertice has another texture coord and adds a new vertex to that position with its texture coordinate. I'm going to have to figure out a way to handle seeing new texture coordinates for vertices and adding them to the vertex list.

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

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

Alternative Ways of Finding Vertices 2 Answers

How to find the closest 4 verts/corners ( along with their orientation ) of a rectangular object in relationship with another object? 1 Answer

mask one gameObject mesh by another mesh vertex transparency 1 Answer

Mesh SetVertices() vs vertices 2 Answers

Creating a mesh out of a linerenderer - how do you convert revolved vertices set to triangles and uv's 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