Search Unity

negative scale issues - maintaining RH coordinates

Discussion in 'Scripting' started by klap, Dec 4, 2012.

  1. klap

    klap

    Joined:
    Jul 18, 2012
    Posts:
    2
    Dear all,

    I am going to maintain a subtree in the scenegraph with respect to an external coordinate system (Right Hand, Z is up, Y is forward). Reason: I want to load a scene from a file where the geometry is stroed in the external coordinate system.

    Therefore I created a root node "scene" and attached the loaded subtree with respect to the external coord systen.
    To view it correctly in Unity3D I chanded the scene root node transformation accordingly (position=(0 0 0), rotation=(90 0 0), scale (1 1 -1)). That works fine so far.

    Now I am going to add animations to my sceene. The keyframe locations are also stored in the file with respect to external coord system. To make a gameObject move relatively to its parent I interpolate between the keyframes and assign the result to the localTransformation in a coroutine each frame.

    This works as expected if the scale in the scene-node is (1 1 1).
    If the scale in the schene-node is (1 1 -1) I get strange effects:

    - The location of the animated node in the inspector window evolves as expected but
    - The location of the animated node in the 3D view evolves unexpectedly, Unity seems to add the initial rotation to the location I set to localTransformation. Also the x, and y angle seems to be negative.
    - After animation has stopped: if I go to the Inspector Window, click in the rotation input field and press tab-key to leave its focus, the 3D view updates to the expected end location.

    This behaviour seems to be caused by the -1 in the scale component in the scene-node transformation.
    How can I work around this, respectively how can I force unity to update the view accordinly to the value I supply via go.localTransformation each frame.

    Are there other issues with a negative scale which could cause problems later on?
    Is it generally better to transform all into the Unity3D coord system while importing?

    Would like to know about your experience with that
    Thanks
    Klap
     
  2. klap

    klap

    Joined:
    Jul 18, 2012
    Posts:
    2
    .. solved so far: overwriting the localScale with (1 1 1) each frame helped!?

    However, maintaining the scenegraph in an own right hand coordinate system and transforming into Unity space using a root node transformation seems to be the easiest way in my case.

    Will I get in trouble later on if I decide to proceed this way, (invalidating the meaning of Vector3.(up|forward|..) is acceptable for me).
    What are the risks? what is the best practice?

    Thanks
    Klap