none
Kinect v2 and Unity 5: Working with 3D Object RRS feed

  • Question

  • Hii,

    I'm still learning to use Kinect with Unity Project. From my post before (Kinect v2 and Unity 5), finally I can do rotation based on a Joint rotation, Thanks to David's answer.

    Now, I'am facing new problem with the object orientation itself because of rotation data that I've set. Any object that is associated with rotation code is facing down. I've tried on many joint, the result are the same. here's the pic:

    Facing down object

    I downloaded free 3D object from Armour 3D Blend for learning unity. Is there anyone know about this problem ?

    Thanks


    Adityo Setyonugroho

    Sunday, August 30, 2015 1:46 PM

Answers

  • Hello.

    Your code is wrong.

    "this.gameObject" is current GameObject that script add to, it's not your model.

    You can try reference to Model GameObject, like this:

    public GameObject referenceObject;

    referenceObject.transform.rotation = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);


    The "referenceObject" is set to your Model GameObject In UnityEditor.

    • Edited by nugao Monday, August 31, 2015 10:12 AM
    • Marked as answer by Adityo Setyonugroho Thursday, September 17, 2015 5:27 AM
    Monday, August 31, 2015 10:03 AM

All replies

  • Hello.

    Please post the rotation code snippet.


    • Edited by nugao Monday, August 31, 2015 1:40 AM
    Monday, August 31, 2015 1:39 AM
  • Hi,

    this is the code that I used:

    if (body.IsTracked)
                {
                    var pos = body.Joints[Windows.Kinect.JointType.SpineBase].Position;
                    var orientation = body.JointOrientations[Windows.Kinect.JointType.SpineBase].Orientation;
                    this.gameObject.transform.position = new Vector3(pos.X * 10, pos.Y * 10, pos.Z * 10);
                    this.gameObject.transform.rotation = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);
                    break;
                }


    Adityo Setyonugroho



    Monday, August 31, 2015 3:16 AM
  • Hello.

    Your code is wrong.

    "this.gameObject" is current GameObject that script add to, it's not your model.

    You can try reference to Model GameObject, like this:

    public GameObject referenceObject;

    referenceObject.transform.rotation = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);


    The "referenceObject" is set to your Model GameObject In UnityEditor.

    • Edited by nugao Monday, August 31, 2015 10:12 AM
    • Marked as answer by Adityo Setyonugroho Thursday, September 17, 2015 5:27 AM
    Monday, August 31, 2015 10:03 AM
  • Hi,

    the code that I used before already attached with the model itself. Now, model can do horizontal and vertical rotation, but initial position is facing down.

    based on your answer, so I need to create an empty object with the script, then I need to reference the model into my object to do rotation right ?

    Thanks


    Adityo Setyonugroho

    Wednesday, September 2, 2015 5:03 AM
  • Hi Adityo,

    You may wish to consider using the GameObject's transform.localRotation to apply the orientation quaternion.  This should orient it relative to its starting rotation rather than setting an absolute rotation value.

    Hope this helps,

    David

    Friday, September 4, 2015 11:28 PM
    Moderator
  • Hello.


    Try:

    referenceObject.transform.rotation = Quaternion.Euler( -90f, 0f, 0f ) * new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W);

    TO fix rotation.

    Sunday, September 6, 2015 1:25 AM
  • Hi,

    Thanks for your reply. I was away for couple of day, and now starting to do it again. I tried to change it into localRotation, but it is also did the same thing as rotation. The object still facing down. The same problem also appeared on nugao Quaternion.Euler

    can I share sample here ? so maybe others can use it to learn too ?

    Thanks


    Adityo Setyonugroho


    Thursday, September 10, 2015 2:02 PM
  • Hello.

    You can send the U3d Project to me.

    Friday, September 11, 2015 5:21 AM
  • Haii,

    To nugao, I've sent to you 7z file of my project, thanks btw hehe. so far, I'm still trying with other way also. Position is already correct, the only problem just rotation.

    I'll upload my project soon to GitHub, so others can look into it for learning purpose or tutorial.

    Thanks guys.


    Adityo Setyonugroho

    Sunday, September 13, 2015 7:23 PM
  • Hello Adityo,

    Have you uploaded this to github yet?

    i'm asking because i'm currently studying this particular subject!

    Much appreciated!

    Niels

    Tuesday, September 15, 2015 1:36 PM
  • Hi,

    Thanks guys for helping me out to figure out this particular problem hehe :D.

    Currently, my GitHub project page is not available, because there still a couple of things that have not been done yet. But, soon I'll update it again.

    Regarding to learn and trying Kinect v2 with Unity5, there are a assets from store that is Amazing ! I use it with my current work. It was build based on MS SDK of Kinect v2. You can check it here from RF Solution, this guy is amazing:

    https://www.assetstore.unity3d.com/en/#!/content/18708

    Based on the statement, you can get it free if it is for educational purpose.

    Thank You

    Best Regards,


    Adityo Setyonugroho


    Saturday, September 26, 2015 7:07 AM