PDA

View Full Version : Help needed - pivot rotation to Unity



MarcusM
12-12-2013, 04:31 AM
Hi

I need help in export pivot rotations from Layout to Unity game engine.
In Layout i placed pivots and rotate them but in Unity are only positions, without rotations done in Layout...

118642

RebelHill
12-12-2013, 05:58 AM
can't do it.

MarcusM
12-12-2013, 06:56 AM
Thank you for answer.

I thought so... it's hard to imagine that this basic thing is impossible.
Now i must play with empty objects in Unity.. or do it in Maya ;]

RebelHill
12-12-2013, 07:13 AM
I think you'll find that most game engines dont support any kind of pivot rotation, and so far as I know, you cant have rotated pivots in fbx either, hence, I dont believe doing it in maya or max, or anywhere else will make a difference, you'll have to set things up with unrotated pivots.

MarcusM
12-12-2013, 07:47 AM
I have done this in Maya and exported as fbx. In Unity i have good pivot rotation.
I tried everything in Layout but not managed this...

Deep Purple
12-12-2013, 09:05 AM
I have done this in Maya and exported as fbx. In Unity i have good pivot rotation.
I tried everything in Layout but not managed this...

Hi Marcus!

I just now tried exporting a box with an off-center rotation pivot, exported to FBX,
then imported to Maya, exported from Maya and loaded both FBX files into Unity 3D,
the rotation pivot as well as the rotations themselves were preserved in all cases in all applications.

Maybe I understand your problem incorrectly, but rotation pivots are definitely supported in LightWave to the same capacity as they are in Maya.

Cheers,
DavidF

118643
118644

RebelHill
12-12-2013, 09:49 AM
Animated item rotations are preserved, but I didnt think pivot rotations were.. I thought LW "undid" pivot rotation when exporting fbx, it certainly does on import.

MarcusM
12-12-2013, 09:54 AM
Hi Marcus!

I just now tried exporting a box with an off-center rotation pivot, exported to FBX,
then imported to Maya, exported from Maya and loaded both FBX files into Unity 3D,
the rotation pivot as well as the rotations themselves were preserved in all cases in all applications.

Maybe I understand your problem incorrectly, but rotation pivots are definitely supported in LightWave to the same capacity as they are in Maya.

Cheers,
DavidF

118643
118644

Thank you for your interest in the problem.

I chcked attached objects in Unity and in both pivots are just moved in space. I mean not only changing positions but also rotations. After put fbx in to Unity, in object rotation should be values, not "0"

In my example(image) from first (upper) post i have many screws what should be take of but not straight up etc.

It's good to solve this.

Deep Purple
12-12-2013, 10:19 AM
I see, you mean the "Rotate Pivot",
i created a simple object and set the "Rotate Pivot" heading to 30 degrees, set the regular rotation back to 0(otherwise they would cancel out), with the resulting object being rotated properly after import into Unity.

Maybe I am missing something but it does seem to work correctly,
could I get some test content demonstrating the problem?
I would love to fix it, but first I need to be able to reproduce the problem.

Cheers,
DavidF

118647

Deep Purple
12-12-2013, 10:25 AM
Hi RebelHill!

The effects of "Rotate", "Move Pivot" and "Rotate Pivot" should all be properly exported to the FBX file.

Cheers,
DavidF

MarcusM
12-12-2013, 10:28 AM
I see, you mean the "Rotate Pivot",
i created a simple object and set the "Rotate Pivot" heading to 30 degrees, set the regular rotation back to 0(otherwise they would cancel out), with the resulting object being rotated properly after import into Unity.

Maybe I am missing something but it does seem to work correctly,
could I get some test content demonstrating the problem?
I would love to fix it, but first I need to be able to reproduce the problem.

Cheers,
DavidF

118647

Sorry but still not this what i mean. Not rotating object(mesh). Just rotation values(pivot rotation).

In my opinion, in Layout, i should use "Rotate pivot" and then export object. But this rotation is not represented in Unity.

RebelHill
12-12-2013, 10:37 AM
OK... it appears from here... http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html?url=WS1a9193826455f5ff1f92379812724681e 696651.htm,topicNumber=d0e7429 that fbx DOES support to storing of pivot rotations (pivots dont have to be at 0,0,0 for parent local)... So, Im assuming that LW does indeed remove pivot rotations when exporting to fbx (which I always thought it did as going LW<>MB you get problems if things have rotated/recorded pivots).

I'll have to wait till I get back home to try out a simple base case in maya (from LW) to inspect whats happened to pivot rotation in the export process... but LW certainly loses them on either its export or import (take something, rotate its pivot, export fbx, reload the fbx into LW, pivot rotation gone). Now... I guess its possible that unity itself is losing the pivot rotation upon import, whether this is due to LW losing it on export, or something else in LWs fbx implementation that cuases unity to lose it, couldnt tell you, but I'll have a dig, see if I can find out where the missing bit is (would help if I had unity, which I dont).

Deep Purple
12-12-2013, 10:42 AM
Sorry but still not this what i mean. Not rotating object(mesh). Just rotation values(pivot rotation).

In my opinion, in Layout, i should use "Rotate pivot" and then export object. But this rotation is not represented in Unity.

Hi Marcus!

The object exported to the "pivot_rotation_lightwave.fbx" file was rotated using "Rotate Pivot", which arrives in Unity fine (30 degrees set in Layout are 30 degrees in Unity).
When you use "Rotate Pivot" you actually see no rotation happening in Layout, since the regular rotation is set to the equal and opposite value (-30 degrees in this case) by the "Rotate Pivot" tool.
After manually changing the regular rotation value back to 0 you see the 30 degree rotation in Layout and, after export to FBX, in Unity as well.

Could I get access to a scene which demonstrates the issue you are experiencing, I may be doing something different than you are,
from what I see the rotation, pivot translation and pivot translation are exported to the FBX file.

Cheers,
DavidF

MarcusM
12-12-2013, 10:43 AM
OK... it appears from here... http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html?url=WS1a9193826455f5ff1f92379812724681e 696651.htm,topicNumber=d0e7429 that fbx DOES support to storing of pivot rotations (pivots dont have to be at 0,0,0 for parent local)... So, Im assuming that LW does indeed remove pivot rotations when exporting to fbx (which I always thought it did as going LW<>MB you get problems if things have rotated/recorded pivots).

I'll have to wait till I get back home to try out a simple base case in maya (from LW) to inspect whats happened to pivot rotation in the export process... but LW certainly loses them on either its export or import (take something, rotate its pivot, export fbx, reload the fbx into LW, pivot rotation gone). Now... I guess its possible that unity itself is losing the pivot rotation upon import, whether this is due to LW losing it on export, or something else in LWs fbx implementation that cuases unity to lose it, couldnt tell you, but I'll have a dig, see if I can find out where the missing bit is (would help if I had unity, which I dont).

I can confirm that i managed export fbx from Maya to Unity with pivot values(rotations) today. That means problem is in LW.

Deep Purple
12-12-2013, 10:53 AM
Hi Marcus!
Could I get a simple LW scene and a simple Maya scene which demonstrates the issue.
With the content I created myself the LightWave FBX export behaves the same way as the Maya FBX export, same result in Unity.

Cheers,
DavidF

Deep Purple
12-12-2013, 10:55 AM
OK... it appears from here... http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html?url=WS1a9193826455f5ff1f92379812724681e 696651.htm,topicNumber=d0e7429 that fbx DOES support to storing of pivot rotations (pivots dont have to be at 0,0,0 for parent local)... So, Im assuming that LW does indeed remove pivot rotations when exporting to fbx (which I always thought it did as going LW<>MB you get problems if things have rotated/recorded pivots).

I'll have to wait till I get back home to try out a simple base case in maya (from LW) to inspect whats happened to pivot rotation in the export process... but LW certainly loses them on either its export or import (take something, rotate its pivot, export fbx, reload the fbx into LW, pivot rotation gone). Now... I guess its possible that unity itself is losing the pivot rotation upon import, whether this is due to LW losing it on export, or something else in LWs fbx implementation that cuases unity to lose it, couldnt tell you, but I'll have a dig, see if I can find out where the missing bit is (would help if I had unity, which I dont).

One oddity I do see in Unity, the pivot position actually moves the object.
This happens with FBX files from Maya as well though, which makes it seem like an issue with the Unity FBX importer.

Unity 3D is free, easy to install, takes a chunk of hard drive space though ;-)

Cheers,
DavidF

MarcusM
12-12-2013, 11:02 AM
Hi Marcus!
Could I get a simple LW scene and a simple Maya scene which demonstrates the issue.
With the content I created myself the LightWave FBX export behaves the same way as the Maya FBX export, same result in Unity.

Cheers,
DavidF

Ok please try export box from attached scene, without rotating mesh. You see that pivot is out from box and seriously rotated. What result you receive see in Unity.
(In Unity in top left corner you have option to change pivot/center and global/local.)

You must check code, it will say everything ;]

118649

Taking the opportunity i would like you to check one more thing. Fbx from LW creating in Unity many materials for each object layer, when material names in LW are the same for few layers.
It should not be in this way, a lot of extra work. Before export to fbx, when you add whatever image as texture, then in Unity are that many materials what chould be, not for each layer.

Deep Purple
12-12-2013, 11:28 AM
I see!
What are you using in Maya to rotate the pivot?
That would help getting to the bottom of this issue.

Thanks,
DavidF

MarcusM
12-12-2013, 11:48 AM
In Maya:
1. zero transformations (Modify -> freeze transformation)
2. rotate object what you want
3. copy rotation value
4. one more time freeze transform
5. paste with values with minus
6. export

RebelHill
12-12-2013, 12:39 PM
Ok...

So LW def IS exporting pivot rotation into the FBX file... note the attached example. The light only has had its pivot rotated (to HPB, -77,42.9,0), its local rotations zeroed, and then given a 33deg pitch rotation from that point.

You can note in the fbx file the lines...

Property: "PreRotation", "Vector3D", "",-42.9000083654999,77.3000307240265,-2.89344294922962e-014
Property: "PostRotation", "Vector3D", "",-90,0,0
Property: "RotationActive", "bool", "",1

and...

Property: "Lcl Rotation", "Lcl Rotation", "A+",-33.0000009183087,-2.33098628827844e-006,-5.71013439694154e-006


Im not exactly sure what reason is for the postRotation of x-90, nor why the other rotation vals are inverted... Im presuming this is to account for LWs rotation order and its backwards Z+-... Now it appears to import elsewhere with this pivot rotation intact, so it would appear that the problem is on unity's end. What's different about a maya generated fbx and an LW one I dont know... but there it is.

Deep Purple
12-12-2013, 01:18 PM
Ok...

So LW def IS exporting pivot rotation into the FBX file... note the attached example. The light only has had its pivot rotated (to HPB, -77,42.9,0), its local rotations zeroed, and then given a 33deg pitch rotation from that point.

You can note in the fbx file the lines...

Property: "PreRotation", "Vector3D", "",-42.9000083654999,77.3000307240265,-2.89344294922962e-014
Property: "PostRotation", "Vector3D", "",-90,0,0
Property: "RotationActive", "bool", "",1

and...

Property: "Lcl Rotation", "Lcl Rotation", "A+",-33.0000009183087,-2.33098628827844e-006,-5.71013439694154e-006


Im not exactly sure what reason is for the postRotation of x-90, nor why the other rotation vals are inverted... Im presuming this is to account for LWs rotation order and its backwards Z+-... Now it appears to import elsewhere with this pivot rotation intact, so it would appear that the problem is on unity's end. What's different about a maya generated fbx and an LW one I dont know... but there it is.

That x-90 on the light is an FBX peculiarity of old, same as for cameras, which have a similar offset bug on the y-axis.
Applications like Maya, LightWave, C4D, etc.. compensate for that 90 degree offset, while Unity does not. But that is a different issue.

Thanks for verifying the Pivots, Rebel Hill!

Cheers,
DavidF

RebelHill
12-12-2013, 01:21 PM
No worries...

Do notice though that if you reimport that same fbx straight back into LW... pivot rotation is lost. Maybe it wouldnt hurt to fix that up (as it means round tripping can be problematic sometimes if using rotated/recorded pivots).

Deep Purple
12-12-2013, 01:24 PM
In Maya:
1. zero transformations (Modify -> freeze transformation)
2. rotate object what you want
3. copy rotation value
4. one more time freeze transform
5. paste with values with minus
6. export

Thanks!

I tried those steps and what I get is a rotated object, not a rotated pivot point in Unity (when I switch between "center" and "pivot" the handles are identical)

I think the problem you are encountering is that Unity does not handle pivot transforms properly, actually moving the object while it should not, regardless if the object was exported from Maya or LightWave.
The same is true for the orientation issues for Lights and Cameras as I mentioned in the answer to Rebel Hill.

Cheers,
DavidF

Deep Purple
12-12-2013, 01:25 PM
No worries...

Do notice though that if you reimport that same fbx straight back into LW... pivot rotation is lost. Maybe it wouldnt hurt to fix that up (as it means round tripping can be problematic sometimes if using rotated/recorded pivots).

Thanks for pointing that out, I can use the test objects I already created for debugging fixing that import issue.

Cheers,
DavidF

MarcusM
12-12-2013, 03:45 PM
Thanks!

I tried those steps and what I get is a rotated object, not a rotated pivot point in Unity (when I switch between "center" and "pivot" the handles are identical)

I think the problem you are encountering is that Unity does not handle pivot transforms properly, actually moving the object while it should not, regardless if the object was exported from Maya or LightWave.
The same is true for the orientation issues for Lights and Cameras as I mentioned in the answer to Rebel Hill.

Cheers,
DavidF

I think you doing something wrong.
Check image in attachement. Box exported as FBX from Maya, with rotated pivot and puted on scene. There are rotation values and mesh is still not touched.
What more i can show... i want this result from LW.

118658

118661

RebelHill
12-12-2013, 04:07 PM
Just to see where the disconnect is happening... Take a pivot rotated object in LW... fbx out to maya, check the attributes there to see if the pivot rotation has held... if so, re-export a new fbx from maya, drop that into unity.

MarcusM
12-12-2013, 04:21 PM
Just to see where the disconnect is happening... Take a pivot rotated object in LW... fbx out to maya, check the attributes there to see if the pivot rotation has held... if so, re-export a new fbx from maya, drop that into unity.

You can see values below.

This is rotated pivot in LW.
118662

Thi is the same exported as FBX to Maya.
118663

MentalFish
12-12-2013, 05:59 PM
Here is a thought for a "quick fix" for now. If you have to work with a custom rotated pivot, what about adding a Null object and parenting the mesh to it, and use this null as the pivot, instead of the mesh's own pivot? Just use "Parent in Place", drag the null out of the mesh, when you want to reposition this "pivot", and back in to use the null as its pivot again.

MarcusM
12-13-2013, 01:32 AM
Here is a thought for a "quick fix" for now. If you have to work with a custom rotated pivot, what about adding a Null object and parenting the mesh to it, and use this null as the pivot, instead of the mesh's own pivot? Just use "Parent in Place", drag the null out of the mesh, when you want to reposition this "pivot", and back in to use the null as its pivot again.

When i had ready prefabs and realize that i need rotated pivot in some places then i do this with empty objects.

Exaple when i modelled everything in Modeler but pivot for screws and other hinges rotated in Maya. Without extra nulls.
118685

Deep Purple
12-13-2013, 05:49 PM
When i had ready prefabs and realize that i need rotated pivot in some places then i do this with empty objects.

Exaple when i modelled everything in Modeler but pivot for screws and other hinges rotated in Maya. Without extra nulls.
118685

Hi Marcus,
"Freeze Transforms" in Maya does something very different than "Rotate Pivot" does in LightWave.

"Freeze Transforms" actually *changes the mesh*, it does *not* rotate the pivot point.
The "Rotate Pivot" tool in LightWave actually rotates the pivot point.

In other words:
"Freeze Transforms" works as if you would go to Modeler and rotate the mesh into the desired position there, while zeroing out the rotation in Layout.

If I understand you correctly you would like to have something like "Freeze Transforms" in LightWave,
or an option in the FBX exporter to freeze the pivot rotation into the mesh as "Freeze Transforms" in Maya would do.

I can add that option for you and post a build of the new FBX exporter to this thread,
if you would like to test that solution.

Cheers,
DavidF

Deep Purple
12-13-2013, 06:03 PM
Just to see where the disconnect is happening... Take a pivot rotated object in LW... fbx out to maya, check the attributes there to see if the pivot rotation has held... if so, re-export a new fbx from maya, drop that into unity.

Hi RebelHill!

I think I know what is happening, explained on a slightly higher technical level:

"Freeze Transforms" has nothing to do with pivot points, as you can see in the ASCII FBX output,
it actually rotates the vertices in the mesh, as you can see in the export of a Box created with the following steps:

1. Create Box (enlarge all axes 10x)
2. Rotate 20 degrees on X
3. Apply "Freeze Transforms"
4. Rotate -20 degrees on X
5. Export to FBX (ASCII)

118693

The only rotation in that file is the -20 degree rotation, the 20 degree rotation is actually frozen into the mesh vertex positions.

Maya does not have an equivalent of "Rotate Pivot" as far as I see,
the equivalent in Maya only exists on Joints, where it is called "Joint Orientation".
(LightWave "Rotate Pivot" = Maya "Joint Orientation" = FBX "PreRotation")

The result is that Maya, and apparently Unity bake the FBX "PreRotation" (=LW Rotate Pivot) down to the local rotation, causing the rotations to cancel out to zero if the two are just negatives of each other.

If we compare "Freeze Transforms" to "Rotate Pivot" we are comparing apples to oranges,
one is a transformation baked into the mesh), at the time "Freeze Transform" is executed, the other is an actual pivot rotation in the motion system.

Cheers,
DavidF

RebelHill
12-13-2013, 06:09 PM
"Freeze Transforms" has nothing to do with pivot points...Maya does not have an equivalent of "Rotate Pivot" as far as I see,
the equivalent in Maya only exists on Joints, where it is called "Joint Orientation"(=PreRotation in the FBX file).

You sure... cos Ive ALWAYS used freeze transforms on joints before in maya, and it does just the same thing as rotate pivot (sets the joints local rotation axis to its set rotation... as in pre-rotating... its always been the same as LWs RPR).

Ah... ok, a quick read up... Freeze transforms actually behaves differently on joints (behaves like rotate pivot/rpr)... as in it freezes only rotations (so you're right about the mesh thing). As for the naming... Im still on 2009 here, maybe they stuck in a specicifc orient joint tool in more recent versions.

Celshader
12-13-2013, 06:21 PM
Ah... ok, a quick read up... Freeze transforms actually behaves differently on joints (behaves like rotate pivot/rpr)... as in it freezes only rotations (so you're right about the mesh thing). As for the naming... Im still on 2009 here, maybe they stuck in a specicifc orient joint tool in more recent versions.

It has been a long time, but I remember using Maya's Freeze Transforms on meshes when exporting Maya layouts to Terragen. There is a set of two LScripts for LW that will do the same thing, if you wish to collapse the objects of an LWS into a single LWO:

https://www.lightwave3d.com/assets/plugins/entry/load-objects-into-empties/

Instructions on usage:
http://forums.cgsociety.org/showpost.php?p=2012076&postcount=3

MarcusM
12-14-2013, 06:58 AM
Hi Marcus,
"Freeze Transforms" in Maya does something very different than "Rotate Pivot" does in LightWave.

"Freeze Transforms" actually *changes the mesh*, it does *not* rotate the pivot point.
The "Rotate Pivot" tool in LightWave actually rotates the pivot point.

In other words:
"Freeze Transforms" works as if you would go to Modeler and rotate the mesh into the desired position there, while zeroing out the rotation in Layout.

If I understand you correctly you would like to have something like "Freeze Transforms" in LightWave,
or an option in the FBX exporter to freeze the pivot rotation into the mesh as "Freeze Transforms" in Maya would do.

I can add that option for you and post a build of the new FBX exporter to this thread,
if you would like to test that solution.

Cheers,
DavidF

Hi

Ok i see now the difference. If you could change FBX exporter for Layout and give to tests it would be great!

You can see now big capabilities from having that option. :)

Greetings,
Marek

MarcusM
12-16-2013, 03:40 PM
Is it possible to make in furute pivot rotation tool in Modeler(or transform)? Then for example Transform Tool could have possibility to rotate by (layer) pivot orientation.
Also rotate pivot according to selected polygon normal/edge/point.

MarcusM
03-26-2014, 08:02 AM
Hi

Is there any progress in thread matter?
Passed some time but i still remember and waiting ;]