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 /
  • Help Room /
avatar image
0
Question by sarahnorthway · May 12, 2017 at 10:06 PM · meshfbximport settings

FBX Import Settings on Mesh Assets

From the Project window, clicking on an FBX file brings up the Import Settings in the Inspector panel. In particular, I want to use Optimize Mesh, Weld Vertices and Calculate Normals, which all make my meshes more efficient.

Meshes can also exist in the filesystem as .asset files, but clicking on these brings up a mostly blank Inspector panel with no import options.

So, how do I use the Optimize Mesh / Weld Vertices / Calculate Normals utils on meshes saved as .asset files?

Are those utilities accessible in the Unity API?

Can asset meshes be repackaged back to FBX?

Does anyone have source code for those functions?

alt text

importsettings.png (121.3 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

· Add your reply
  • Sort: 
avatar image
1

Answer by sarahnorthway · May 24, 2017 at 04:21 AM

Optimize Mesh is: UnityEditor.MeshUtility.Optimize()

Calculate Normals is: Mesh.RecalculateNormals(). It doesn't include smoothing angle option and doesn't change the number of vertices, but Unwrapping.GenerateSecondaryUVSet() does. Though I think it only adds vertices and won't remove them. So first you need:

Weld Vertices I tweaked from a couple sources:

 public static void WeldVertices(Mesh mesh, float threshold = float.Epsilon) {
     Vector3[] oldVertices = mesh.vertices;
     Color[] oldColors = mesh.colors;
     Vector3[] newVertices = new Vector3[oldVertices.Length];
     Color[] newColors = new Color[oldVertices.Length];
     int[] old2new = new int[oldVertices.Length];
     int newSize = 0;
     
     // make new vertices with no duplicates
     for (int i = 0; i < oldVertices.Length; i++) {
         bool foundMatch = false;
         for (int j = 0; j < newSize; j++) {
             if (Vector3.SqrMagnitude(newVertices[j] - oldVertices[i]) < threshold) {
                 if (oldColors.Length >= i + 1 && newColors[j] == oldColors[i]) {
                     old2new[i] = j;
                     foundMatch = true;
                 }
             }
         }
 
         if (!foundMatch) {
             // Add new vertex
             newVertices[newSize] = oldVertices[i];
             if (oldColors.Length >= i + 1) {
                 newColors[newSize] = oldColors[i];
             }
             old2new[i] = newSize;
             newSize++;
         }
     }
 
     // make new triangles
     int[] oldTris = mesh.triangles;
     int[] newTris = new int[oldTris.Length];
     for (int i = 0; i < oldTris.Length; i++) {
         newTris[i] = old2new[oldTris[i]];
     }
 
     Vector3[] finalVertices = new Vector3[newSize];
     Color[] finalColors = new Color[newSize];
     for (int i = 0; i < newSize; i++) {
         finalVertices[i] = newVertices[i];
         finalColors[i] = newColors[i];
     }
 
     mesh.Clear();
     mesh.vertices = finalVertices;
     mesh.colors = finalColors;
     mesh.triangles = newTris;
     mesh.uv = null;
     mesh.uv2 = null;
 }
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

106 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 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

mesh glitch on build 1 Answer

Mesh looks like overlapping. 0 Answers

Animated rigged blender model generating colliders problem 1 Answer

Mesh and material missing after .fbx Import as AssetBundle 2 Answers

it is possible to rename the mesh of the FBX file? 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