• 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 /
  • Help Room /
avatar image
0
Question by Nankong · Mar 12, 2016 at 02:33 PM · unity 5rotationjointkinect

Rotation doesn't work with JointOrientation from kinect in Unity3D 5

A weird thing happen to my code, I don't know why I worked like this, but it did.

My code is like this:

             // Getting joint orientation data from kinect 
             // and construct it with Unity Quaternion
             Kinect.Vector4 targetRotaV4 = body.JointOrientations[jt].Orientation;
             Quaternion targetRotaQ = new Quaternion(targetRotaV4.X, targetRotaV4.Y, targetRotaV4.Z, targetRotaV4.W);
             Debug.Log("target rotation: " + targetRotaQ); // it did print something
 
             // Rotate the gameobject from its local rotation 
             // to the rotation I got from kinect
             jointObj.localRotation = Quaternion.RotateTowards(jointObj.localRotation, targetRotaQ, 45.0f);
             Debug.Log("Joint Object rotation: " + jointObj.localRotation); 
             // It did print value, too, not just (0, 0, 0, 0), 
             // but in the game, the gameobject didn't rotate, and the rotation didn't change in properties which kept 0
 
             // But!! When I ran the following code, it rotated! Everything looked good.
             /*
             Quaternion testRote = new Quaternion(0.1f, 0.1f, 0.1f, 0.1f);
             jointObj.localRotation = Quaternion.RotateTowards(jointObj.localRotation, testRote, 15);
             Debug.Log("Joint local rotation" + jointObj.localRotation);
             */

So my question is, why! Why the rotation couldn't work with my JointOrientation data from kinect which I did get the data because I print the value and it was not null or 0.

Plz help me out!

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

Answer by totovr92 · Nov 22, 2018 at 01:15 PM

Because the Kinect quaternions seem to assume that any bone points to the sky before rotating,
I turned the bones of my model to the sky before applying the quaternions.

I think you observed your model was jerky and unstable because the quaternions rotated wrongly oriented objects.
Suppose a quaternion rotates objects around y-axis and consider rotating the following two objects by it.

leftArm.transform.rotation = ElbowLeft * Quaternion.AngleAxis(90, new Vector3(0, 1, 0)) * Quaternion.AngleAxis(-90, new Vector3(0, 0, 1));

Comment
Add comment · 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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is this code in the script not stopping the rotation of the Gameobject? 0 Answers

Rotating objects around other without rotating itself 1 Answer

Many objects with decimal place in the millionths, can this cause any performance issues? 0 Answers

How to instantiate an item when i catching it with kinect? 0 Answers

How to rotate Wheelcollider in Unity53.4f1 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges