2014-12-27 3 views
6

я пытаюсь переместить аватар с помощью Unity3D по данным, поступающим от Kinect V2, проблема, когда я применить мульти трещиноватости к единству Slerp трансформируют,v2 совместная Kinect ориентация на Unity3D кватернионов

как я могу рассчитать новый кватернион, который позволяет мне правильно имитировать человеческие движения в реальном времени?

  float ox, oy, oz, ow; 

      ox = body.JointOrientations[_SpineMid].Orientation.X; 
      oy = body.JointOrientations[_SpineMid].Orientation.Y; 
      oz = body.JointOrientations[_SpineMid].Orientation.Z; 
      ow = body.JointOrientations[_SpineMid].Orientation.W; 
      //SpineMid.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      SpineMid.transform.localRotation = Quaternion.Slerp(SpineMid.transform.localRotation, new Quaternion(ox, oy, oz, ow), Time.time * 0.1f); 

here i'm only moving the SpineMid and it seems to be relatively good

  float ox, oy, oz, ow; 

      ox = body.JointOrientations[_SpineMid].Orientation.X; 
      oy = body.JointOrientations[_SpineMid].Orientation.Y; 
      oz = body.JointOrientations[_SpineMid].Orientation.Z; 
      ow = body.JointOrientations[_SpineMid].Orientation.W; 
      //SpineMid.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      SpineMid.transform.localRotation = Quaternion.Slerp(SpineMid.transform.localRotation, new Quaternion(ox, oy, oz, ow), Time.time * 0.1f); 

      ox = body.JointOrientations[_SpineBase].Orientation.X; 
      oy = body.JointOrientations[_SpineBase].Orientation.Y; 
      oz = body.JointOrientations[_SpineBase].Orientation.Z; 
      ow = body.JointOrientations[_SpineBase].Orientation.W; 
      //SpineBase.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      SpineBase.transform.localRotation = Quaternion.Slerp(SpineBase.transform.localRotation, new Quaternion(ox, oy, oz, ow), Time.time * 0.1f); 

here i'm applying the same Slerp Transform to SpineMid and SpainBase

самая смешная часть, когда я попытался применить предыдущее преобразование Slerp к каждому суставу в в аватаре

поплавка Ох, Оу, oz, ow;

  ox = body.JointOrientations[_SpineMid].Orientation.X; 
      oy = body.JointOrientations[_SpineMid].Orientation.Y; 
      oz = body.JointOrientations[_SpineMid].Orientation.Z; 
      ow = body.JointOrientations[_SpineMid].Orientation.W; 
      //SpineMid.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      SpineMid.transform.localRotation = Quaternion.Slerp(SpineMid.transform.localRotation, new Quaternion(ox, oy, oz, ow), Time.time * 0.1f); 

      ox = body.JointOrientations[_SpineBase].Orientation.X; 
      oy = body.JointOrientations[_SpineBase].Orientation.Y; 
      oz = body.JointOrientations[_SpineBase].Orientation.Z; 
      ow = body.JointOrientations[_SpineBase].Orientation.W; 
      //SpineBase.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      SpineBase.transform.localRotation = Quaternion.Slerp(SpineBase.transform.localRotation, new Quaternion(ox, oy, oz, ow), Time.time * 0.1f); 


      ox = body.JointOrientations[_Neck].Orientation.X; 
      oy = body.JointOrientations[_Neck].Orientation.Y; 
      oz = body.JointOrientations[_Neck].Orientation.Z; 
      ow = body.JointOrientations[_Neck].Orientation.W; 
      //Neck.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      Neck.transform.localRotation = Quaternion.Slerp(Neck.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_Head].Orientation.X; 
      oy = body.JointOrientations[_Head].Orientation.Y; 
      oz = body.JointOrientations[_Head].Orientation.Z; 
      ow = body.JointOrientations[_Head].Orientation.W; 
      //Head.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      Head.transform.localRotation = Quaternion.Slerp(Head.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_ShoulderRight].Orientation.X; 
      oy = body.JointOrientations[_ShoulderRight].Orientation.Y; 
      oz = body.JointOrientations[_ShoulderRight].Orientation.Z; 
      ow = body.JointOrientations[_ShoulderRight].Orientation.W; 
      //ShoulderRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      ShoulderRight.transform.localRotation = Quaternion.Slerp(ShoulderRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_ElbowRight].Orientation.X; 
      oy = body.JointOrientations[_ElbowRight].Orientation.Y; 
      oz = body.JointOrientations[_ElbowRight].Orientation.Z; 
      ow = body.JointOrientations[_ElbowRight].Orientation.W; 
      //ElbowRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      ElbowRight.transform.localRotation = Quaternion.Slerp(ElbowRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_HandRight].Orientation.X; 
      oy = body.JointOrientations[_HandRight].Orientation.Y; 
      oz = body.JointOrientations[_HandRight].Orientation.Z; 
      ow = body.JointOrientations[_HandRight].Orientation.W; 
      //HandRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      HandRight.transform.localRotation = Quaternion.Slerp(HandRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_ShoulderLeft].Orientation.X; 
      oy = body.JointOrientations[_ShoulderLeft].Orientation.Y; 
      oz = body.JointOrientations[_ShoulderLeft].Orientation.Z; 
      ow = body.JointOrientations[_ShoulderLeft].Orientation.W; 
      //ShoulderLeft.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      ShoulderLeft.transform.localRotation = Quaternion.Slerp(ShoulderLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_ElbowLeft].Orientation.X; 
      oy = body.JointOrientations[_ElbowLeft].Orientation.Y; 
      oz = body.JointOrientations[_ElbowLeft].Orientation.Z; 
      ow = body.JointOrientations[_ElbowLeft].Orientation.W; 
      //ElbowLeft.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      ElbowLeft.transform.localRotation = Quaternion.Slerp(ElbowLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_HandLeft].Orientation.X; 
      oy = body.JointOrientations[_HandLeft].Orientation.Y; 
      oz = body.JointOrientations[_HandLeft].Orientation.Z; 
      ow = body.JointOrientations[_HandLeft].Orientation.W; 
      //HandLeft.transform.localRotation = Quaternion.Lerp(transform.localRotation, new Quaternion(ox*360, oz*360, oy*360, ow*360), 0.03f); 
      HandLeft.transform.localRotation = Quaternion.Slerp(HandLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_HipsLeft].Orientation.X; 
      oy = body.JointOrientations[_HipsLeft].Orientation.Y; 
      oz = body.JointOrientations[_HipsLeft].Orientation.Z; 
      ow = body.JointOrientations[_HipsLeft].Orientation.W; 
      //HipsLeft.transform.rotation = new Quaternion(ox, oy, oz, ow); 
      HipsLeft.transform.localRotation = Quaternion.Slerp(HipsLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_KneeRight].Orientation.X; 
      oy = body.JointOrientations[_KneeRight].Orientation.Y; 
      oz = body.JointOrientations[_KneeRight].Orientation.Z; 
      ow = body.JointOrientations[_KneeRight].Orientation.W; 
      //KneeRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      KneeRight.transform.localRotation = Quaternion.Slerp(KneeRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_AnkleRight].Orientation.X; 
      oy = body.JointOrientations[_AnkleRight].Orientation.Y; 
      oz = body.JointOrientations[_AnkleRight].Orientation.Z; 
      ow = body.JointOrientations[_AnkleRight].Orientation.W; 
      //AnkleRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      AnkleRight.transform.localRotation = Quaternion.Slerp(AnkleRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_FootRight].Orientation.X; 
      oy = body.JointOrientations[_FootRight].Orientation.Y; 
      oz = body.JointOrientations[_FootRight].Orientation.Z; 
      ow = body.JointOrientations[_FootRight].Orientation.W; 
      //FootRight.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      FootRight.transform.localRotation = Quaternion.Slerp(FootRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_HipsRight].Orientation.X; 
      oy = body.JointOrientations[_HipsRight].Orientation.Y; 
      oz = body.JointOrientations[_HipsRight].Orientation.Z; 
      ow = body.JointOrientations[_HipsRight].Orientation.W; 
      //HipsRight.transform.rotation = new Quaternion(ox, oy, oz, ow); 
      HipsRight.transform.localRotation = Quaternion.Slerp(HipsRight.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_KneeLeft].Orientation.X; 
      oy = body.JointOrientations[_KneeLeft].Orientation.Y; 
      oz = body.JointOrientations[_KneeLeft].Orientation.Z; 
      ow = body.JointOrientations[_KneeLeft].Orientation.W; 
      //KneeLeft.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      KneeLeft.transform.localRotation = Quaternion.Slerp(KneeLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_AnkleLeft].Orientation.X; 
      oy = body.JointOrientations[_AnkleLeft].Orientation.Y; 
      oz = body.JointOrientations[_AnkleLeft].Orientation.Z; 
      ow = body.JointOrientations[_AnkleLeft].Orientation.W; 
      //AnkleLeft.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      AnkleLeft.transform.localRotation = Quaternion.Slerp(AnkleLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

      ox = body.JointOrientations[_FootLeft].Orientation.X; 
      oy = body.JointOrientations[_FootLeft].Orientation.Y; 
      oz = body.JointOrientations[_FootLeft].Orientation.Z; 
      ow = body.JointOrientations[_FootLeft].Orientation.W; 
      //FootLeft.transform.localRotation = new Quaternion(ox, oy, oz, ow); 
      FootLeft.transform.localRotation = Quaternion.Slerp(FootLeft.transform.localRotation, new Quaternion(ox * 360, oy * 360, oz * 360, ow * 360), 0.03f); 

applying Slerp Transformation to every joint in the avatar

Примечание: все эти экраны печати было принято с Т-Позе перед KinectV2 датчика.

+0

Прошли ли вы с этим? Я считаю, что у меня может быть аналогичная проблема. – dudledok

+0

@dudledok еще нет ... –

+0

Любой прогресс сейчас? –

ответ

1

Насколько я помню, ориентации не являются локальными, и вам необходимо ориентировать каждое соединение на небо, прежде чем применять соответствующую ориентацию.

Смежные вопросы