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
1
Question by kablammyman · Jun 06, 2011 at 09:52 PM · meshmeshrenderer

modify a mesh that is from an fbx import

So, i have an animated humanoid model that was from an fbx import. The model is made a few meshes (head, arms, legs body) and bones for animation. I have the animations all chopped up etc etc. and works as is.

So, the issue is trying to modify a mesh of a specific body part. I have made some code to modify a mesh in C# that works well when using it on a cube or some other primitive shape, but it does not work at all on the model (or its body parts) i imported.

For example, if i attach the script to the model's head, it will change the texture, angle, and material of the head, but the vertices of the mesh does NOT change...and thats the most important part. However, attach this same script to a cube or something, it it works as intended.

So, I can only guess that the skinned mesh within my model is making things difficult? I have no idea why its not updating/changing. Does anybody have any clues to why i cant change the verts at run time? I do some stuff at Start() and Update(), even tho i wont need to update anything if this works as intended (its a one time/loading change)

If you want to see code, check this out, the code is more or less the same. http://unity3d.com/support/documentation/ScriptReference/Mesh.html

thanks for your help

Comment
Add comment · Show 1
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 Chris D · Jun 06, 2011 at 11:20 PM 0
Share

can you post more details about your code? The link only provides the general idea of what you're after; it may be the specifics that are throwing things off.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by kablammyman · Jun 07, 2011 at 05:33 PM

the code is literally the code from the examples, but I foudn out what to do.

Changing the mesh for a skinned mesh object does nothing. What you have to do is change the "sharedMesh" instead. The problem is that if your model is a prefab, any changes you make will permanently change the prefab (without saving, quitting, or anything like that)!

WTF??? This is not good, and makes no sense.

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 kablammyman · Jun 07, 2011 at 05:54 PM 0
Share

the docs tell me what I just found out the hard way. In case anyone is interested, check it out:

http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$eshFilter-shared$$anonymous$$esh.html

I will make a copy of the mesh first before editing. The trouble will be a trying to "undo" the changes at shutdown, or when the editor stops, or whatever.

avatar image kablammyman · Jun 07, 2011 at 06:03 PM 0
Share

OnDisable () will at as a destructor for me...problem solved.

now i need to figure out why the changes i make to the shared mesh dont look the same as they would to a normal mesh

avatar image kablammyman · Jun 07, 2011 at 07:12 PM 0
Share

figured it out. you need to give the sharmedmesh the list of triangles before giving the verts. I didnt have this problem with a normal mesh.

avatar image
0

Answer by Tasarran · Dec 09, 2011 at 05:40 PM

Here's a snippet of code that I know works. You should be able to apply this to any object, and it will randomly tweak all the verts. If this doesn't work, I would guess it is a conflict with the bones.

 // load the vertices
     var mesh : Mesh = gameObject.GetComponent(MeshFilter).mesh;
     var vertices : Vector3[] = mesh.vertices;
 // step through and multiply the coordinates of each point, in effect scaling that point a random amount from the origin    
     for(i=0 ; i<vertices.length ; i++)
     {
         vertices[i] *= Random.Range(0.9, 1.1);
     }
 // apply the vertex changes back to the mesh, recalc normals & bounds    
     mesh.vertices = vertices;
     if (recalculateNormals)    
         mesh.RecalculateNormals();
     mesh.RecalculateBounds();
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

2 People are following this question.

avatar image avatar image

Related Questions

My meshes arent loading properly. 1 Answer

Im reading a .obj file and converting it to a mesh (doesnt work) 0 Answers

Modifying SkinnedMeshRenderer.sharedMesh.uv Doesnt Reset after Stopping game. 1 Answer

Add a ''valid mesh renderer'' (Can't use my own trees) 0 Answers

White line in a mesh level 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