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 /
avatar image
0
Question by cregox · Jun 06, 2012 at 09:45 PM · fbxpivot

Fixing an imported GameObject Pivot

Following another similar question I'm attaching here the problematic FBX.

It contains objects with dislocated rotation axis / pivot. So, when I try to apply a billboard script to it, it simply doesn't work.

The simplest solution would probably be to fix it on 3DS, Maya, Blender, etc, but I wanted to do it in script for whatever reason. And I couldn't, even after a lot of research.

I do realize I could manually adjust them using an empty parent, but there are 100 leaves there and that would be way too troublesome. We could also move it using RotateAround, but I couldn't figure out a way to script it into the Billboard because we can't set it into a value (rather than moving).

Also using UnifyCommunity's SetPivot didn't work very well on the FBX - it did center the Pivot, but it moved the leaf out of its original position and into the pivot position.

So, there are 2 questions here:

  1. How to adjust the pivot on that FBX, using scripts only?

  2. How to do it at run time only?

If that's even possible.

Araucaria_unity.zip (276.5 kB)
Comment
Add comment · Show 3
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 hijinxbassist · Jun 06, 2012 at 10:15 PM 0
Share

Why dont you want to fix it the modeling program?? Is there a specific reason, or are you just curious? This type of coding doesnt seem practical since it takes all of 10 seconds in the modeling program VS hrs or days(research, waiting for an answer, then writing code).

Sounds like just writing this question took 3 times as long than just fixing the problem in the proper fashion. Im not sure when you would ever need this code again, other than hack-fix for a prob that shouldn't be there to begin with.

avatar image Wolfram · Jun 06, 2012 at 10:26 PM 0
Share

Whoa, especially since there are over 100 objects! I thought we were talking about a few that could be adjusted by hand.

avatar image cregox · Jun 07, 2012 at 12:46 AM 0
Share

@hijinxbassit as I said, for whatever reason! :P there are many little reasons I don't want to get in, but yeah, one of them is taking the challenge, learning while trying it.

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Wolfram · Jun 06, 2012 at 10:37 PM

Sorry, looks to me the model is shot. The leaves don't have any useful local coordinates at all - they are all the same. So the information where each leaf is supposed to be connected is lost, and it is not contained in the .fbx.

You could still write a script that finds the center of each leaf by looping over all leaves and accessing their renderer.bounds.center, then inserting a new GameObject at the stem, setting its transform.position to that center, then reparenting the leaf to that object, which will make the leaf's center the "origin" of that parent object. You can then rotate that parent object, and this will rotate the leaf around its actual center.

But this would still be an approximation, since the leaves are not necessarily connected to the branches at their center, in fact each leaf seems to have an eintirely different (relative) place where it is connected to its branch. Most importantly, their rotation will still be wrong (which is why your billboarding script is failing, even if the center of rotation has been corrected as described above). This could also be fixed, but would require more extensive and complex scripting mathematics.

So your only chance is to fix the original model and reimporting that into Unity. If that's not possible, it will still be faster to completely remodel the trees, or find others in the web ;-)

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 Wolfram · Jun 06, 2012 at 10:50 PM 0
Share

Fixing the model might be as simple as choosing different export options (i.e., not baking/flushing/flattening/whatever-it-is-called-in-your-particular-modeling-program the local object coordinates into worldspace), if you still have the original model. If all you have is the FBX, I fear you're out of luck.

avatar image cregox · Jun 07, 2012 at 12:49 AM 0
Share

Cool. I'll try your suggestion on $$anonymous$$onday, since most of that job is already done. Using RotateAround with the renderer.bounds.center did work great to rotate all of them in their places... So I thought this might be a good way to go... It's only about making the rotation properly, which would be way easier with LookAt. Thanks for your time, $$anonymous$$r $$anonymous$$resse. :-)

avatar image cregox · Jun 11, 2012 at 06:10 PM 0
Share

The idea from the second paragraph, of parenting with renderer.bounds.center, worked perfectly! It doesn't really matter where they're connected as long as the rotating looks good enough. I'll soon update answers and scripts accordingly. Thanks again!!

avatar image
0

Answer by crogers · Jun 08, 2012 at 10:33 PM

Realtime engines do not support the concept of a pivot point that is not at 0,0,0

to "fix" in the art package, simply move the verts of your objects to make 0,0,0 to be the pivot you want,

Comment
Add comment · Show 1 · 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 cregox · Jun 11, 2012 at 06:11 PM 0
Share

Thanks for the answer, but it completely missed the point.

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

6 People are following this question.

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 pivot point in maya 0 Answers

Working with complex FBX files 0 Answers

How can I change default shader for new/imported objects? 1 Answer

Problem with the father pivot when I import a multi object FBX 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