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 someGamer2 · Aug 03, 2017 at 03:29 AM · meshmodelvertex

How to resize mesh to fbx model gameobject?

Hi, I'm using the mesh filter and renderer to get a hold of the vertices of the mesh and assign spheres to the mesh, but I'm using an fbx model which has a skinned mesh renderer by default. I've managed to assign spheres to each vertex but the mesh itself doesn't match the size or the rotation of the actual model.

alt text

I want to assign the spheres to the textured fbx model like in the image but i can't get the vertex information from it. I read on other posts about SkinRenderer.BakeMesh(), but I have no idea how to use it because the document is really ambiguous on how to use it. I have an array of vertices which I get from mesh.vertices. I tried changing the size and rotation in the blend file that it was made in but no difference. I also tried to putting the mesh in an empty gameobject and resizing it that way but the result is the same. Thanks!

screen-shot-2017-08-03-at-041425.png (161.1 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
0
Best Answer

Answer by HarshadK · Aug 03, 2017 at 05:08 AM

The mesh.vertices array gives the local position of the vertices which is relative to the center of the object. And seems like you are trying to assign your spheres at those positions and the position you are passing is world position which is why they are not at correct positions. Use Transform.TransformPoint to convert local position of your vertices to world position and pass that position to your spheres.

Considering the script is assigned to your model itself below is an untested code but should give you the idea.

 for(int i = 0; i < mesh.vertices.Length; i++) {
     // Here the position is transformed based on which object the script is attached to.
     sphere.transform.position = transform.TransformPoint(mesh.vertices[i]);
 }


Comment
Add comment · Show 2 · 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 someGamer2 · Aug 03, 2017 at 06:47 AM 0
Share

The spheres no longer attach to the vertices using this code they just fly of in another direction. This is the code

 for(int i = 0; i < particleSetUp.vertices.Length; i++)
 {
     //myTransform.position = myTransform.parent.position + particleSetUp.vertices[Random.Range(0, i)];
     myTransform.position = myTransform.TransformPoint( particleSetUp.vertices[Random.Range(0, i)]);
 
 
 }


I'm using Random.Range cause I want the spheres to attach to a random point on the mesh. This class is attached to each individual spheres created.

avatar image someGamer2 · Aug 03, 2017 at 10:09 AM 0
Share

Thanks I got it to work in the end, I just needed to change "transform.Transformpoint" to "transform.parent.TransformPoint" the spheres were the child of the textured model. Now I need the spheres to move around with the mesh while animating. Thanks for your help!

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

76 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

Related Questions

Android performance problem on model joints(Rig). 1 Answer

Simple mesh deformation : Mesh.vertices or vertex shader with displacement texture ? 1 Answer

Mesh vertex count differs on Mac/Windows 1 Answer

horseshoe game - convex mesh colliders with interior spaces 1 Answer

iOS hardware limitations. 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