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 jack_sparrow · May 25, 2012 at 09:33 AM · kinectopenni

Open NI skeleton incorrect rotation

Hi, Everyone

i am trying to connect my 3d model which i exported from 3DsMax. i did connect but the problem is my 3D model rotate hand and legs in inverse rotation. it's been 3 days i tried to correct this Prob bubt i can't figure out.

----:here's the skeleton code:----

 using UnityEngine;
 using System;
 using System.Collections;
 using OpenNI;
 
 public class OpenNISkeleton : MonoBehaviour 
 {
     public Transform Head;
     public Transform Neck;
     public Transform Torso;
     public Transform Waist;
 
     public Transform LeftCollar;
     public Transform LeftShoulder;
     public Transform LeftElbow;
     public Transform LeftWrist;
     public Transform LeftHand;
     public Transform LeftFingertip;
 
     public Transform RightCollar;
     public Transform RightShoulder;
     public Transform RightElbow;
     public Transform RightWrist;
     public Transform RightHand;
     public Transform RightFingertip;
 
     public Transform LeftHip;
     public Transform LeftKnee;
     public Transform LeftAnkle;
     public Transform LeftFoot;
 
     public Transform RightHip;
     public Transform RightKnee;
     public Transform RightAnkle;
     public Transform RightFoot;
 
     public bool UpdateJointPositions = false;
     public bool UpdateRootPosition = false;
     public bool UpdateOrientation = true;
     public float RotationDamping = 15.0f;
     public float Scale = 0.001f; 
 
     protected Transform[] transforms;
     protected Quaternion[] initialRotations;
     protected Vector3 rootPosition;
 
     public void Start()
     {
        int jointCount = Enum.GetNames(typeof(SkeletonJoint)).Length + 1; // Enum starts at 1
        transforms = new Transform[jointCount];
        initialRotations = new Quaternion[jointCount];
 
        transforms[(int)SkeletonJoint.Head] = Head;
        transforms[(int)SkeletonJoint.Neck] = Neck;
        transforms[(int)SkeletonJoint.Torso] = Torso;
        transforms[(int)SkeletonJoint.Waist] = Waist;
        transforms[(int)SkeletonJoint.LeftCollar] = LeftCollar;
        transforms[(int)SkeletonJoint.LeftShoulder] = LeftShoulder;
        transforms[(int)SkeletonJoint.LeftElbow] = LeftElbow;
        transforms[(int)SkeletonJoint.LeftWrist] = LeftWrist;
        transforms[(int)SkeletonJoint.LeftHand] = LeftHand;
        transforms[(int)SkeletonJoint.LeftFingertip] = LeftFingertip;
        transforms[(int)SkeletonJoint.RightCollar] = RightCollar;
        transforms[(int)SkeletonJoint.RightShoulder] = RightShoulder;
        transforms[(int)SkeletonJoint.RightElbow] = RightElbow;
        transforms[(int)SkeletonJoint.RightWrist] = RightWrist;
        transforms[(int)SkeletonJoint.RightHand] = RightHand;
        transforms[(int)SkeletonJoint.RightFingertip] = RightFingertip;
        transforms[(int)SkeletonJoint.LeftHip] = LeftHip;
        transforms[(int)SkeletonJoint.LeftKnee] = LeftKnee;
        transforms[(int)SkeletonJoint.LeftAnkle] = LeftAnkle;
        transforms[(int)SkeletonJoint.LeftFoot] = LeftFoot;
        transforms[(int)SkeletonJoint.RightHip] = RightHip;
        transforms[(int)SkeletonJoint.RightKnee] = RightKnee;
         transforms[(int)SkeletonJoint.RightAnkle] = RightAnkle;
        transforms[(int)SkeletonJoint.RightFoot] = RightFoot;
 
        // save all initial rotations
        // NOTE: Assumes skeleton model is in "T" pose since all rotations are relative to that pose
        foreach (SkeletonJoint j in Enum.GetValues(typeof(SkeletonJoint)))
        {
          if (transforms[(int)j])
          {
           // we will store the relative rotation of each joint from the gameobject rotation
           // we need this since we will be setting the joint's rotation (not localRotation) but we 
           // still want the rotations to be relative to our game object
           initialRotations[(int)j] = Quaternion.Inverse(transform.rotation) * transforms[(int)j].rotation;
          }
        }
 
        // start out in calibration pose
        RotateToCalibrationPose();
     }
 
     public virtual void UpdateRoot(Point3D skelRoot)
     {
        rootPosition = new Vector3(skelRoot.X, skelRoot.Y, -skelRoot.Z) * Scale;
        if (UpdateRootPosition)
        {
          transform.localPosition = transform.rotation * rootPosition;
        }
     }
 
     public virtual void UpdateJoint(SkeletonJoint joint, SkeletonJointTransformation skelTrans)
     {
        // make sure something is hooked up to this joint
        if (!transforms[(int)joint])
        {
          return;
        }
 
        // modify orientation (if confidence is high enough)
         if (UpdateOrientation && skelTrans.Orientation.Confidence > 0.5)
         {
          // Z coordinate in OpenNI is opposite from Unity
          // Convert the OpenNI 3x3 rotation matrix to unity quaternion while reversing the Z axis
          Vector3 worldZVec = new Vector3(-skelTrans.Orientation.Z1, -skelTrans.Orientation.Z2, skelTrans.Orientation.Z3);
          Vector3 worldYVec = new Vector3(skelTrans.Orientation.Y1, skelTrans.Orientation.Y2, -skelTrans.Orientation.Y3);
          Quaternion jointRotation = Quaternion.LookRotation(worldZVec, worldYVec);
          Quaternion newRotation = transform.rotation * jointRotation * initialRotations[(int)joint];
 
          transforms[(int)joint].rotation = Quaternion.Slerp(transforms[(int)joint].rotation, newRotation, Time.deltaTime * RotationDamping);
         }
 
        // modify position (if needed, and confidence is high enough)
        if (UpdateJointPositions)
        {
             Vector3 v3pos = new Vector3(skelTrans.Position.Position.X, skelTrans.Position.Position.Y, -skelTrans.Position.Position.Z);
          transforms[(int)joint].localPosition = (v3pos * Scale) - rootPosition;
        }
     }
 
     public virtual void RotateToCalibrationPose()
     {
        foreach (SkeletonJoint j in Enum.GetValues(typeof(SkeletonJoint)))
        {
          if (null != transforms[(int)j])
          {
           transforms[(int)j].rotation = transform.rotation * initialRotations[(int)j];
          }
        }
 
        // calibration pose is skeleton base pose ("T") with both elbows bent in 90 degrees
        RightElbow.rotation = transform.rotation * Quaternion.Euler(0, -90, 90) * initialRotations[(int)SkeletonJoint.RightElbow];
         LeftElbow.rotation = transform.rotation * Quaternion.Euler(0, 90, -90) * initialRotations[(int)SkeletonJoint.LeftElbow];
     }
 }


please help me ..

thanx

regards

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
Best Answer

Answer by jack_sparrow · Jun 21, 2012 at 02:26 PM

hi

Finally got the Solution. open "OpenNI.XML" file edit openNI mirror mode to true.

and that's it ..

cheers

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

how a kinect controlled character can be stabilized? 0 Answers

Unity Kinect and Zigfu strange spine rotation 1 Answer

ZigFu's Unity Kinect Skeleton 1 Answer

Use kinect depth map as input? 1 Answer


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