1

さてProcessingでSimpleOpenNIライブラリを使ったスケッチを作ったり、骨格の上に3Dデザインを載せたりしているのですが、Kinectの前に別の人が立ったらモデルが違うと思っていました。私はテストを行っているので、人は私より背が高いか小さいです.SimpleOpenNIによって作成されたスケルトンをスケーリングする方法があるかどうかを知りたいので、私のスケッチの標準にすることができます。スケッチでは同じ高さになり、3D のすべてのパーツは同じ場所に残ります。スケルトンを使った初めてのプロジェクトなので、ヒントをいただければ幸いです。ありがとう!

4

1 に答える 1

2

3D スケルトンを同じ縮尺で描画する場合は、固定カメラを使用して固定位置にあるスケルトンの表現で 3D シーンを作成し (そうすれば縮尺は変化しません)、単純にジョイントの向き (回転) を使用できます。カスタム アバター/キャラクター表現を更新するための行列) (位置ではない)。

SimpleOpenNI のメソッドを使用して、向きを PMatrix3D として取得しますgetJointOrientationSkeleton()。その後、Processing のapplyMatrix()を使用して、カスタム メッシュの方向を設定できます。

PMatrix3D  orientation = new PMatrix3D();
context.getJointOrientationSkeleton(userId,SimpleOpenNI.SKEL_HEAD,orientation);
pushMatrix();
applyMatrix(orientation);//rotate box based on head orientation
box(40);
popMatrix();  

または最小限のサンプルとして:

import SimpleOpenNI.*;
SimpleOpenNI  context;
PMatrix3D  orientation = new PMatrix3D();//create a new matrix to store the steadiest orientation (used in rendering)
PMatrix3D  newOrientaton = new PMatrix3D();//create a new matrix to store the newest rotations/orientation (used in getting data from the sensor)
void setup() {
  size(640, 480,P3D);
  context = new SimpleOpenNI(this);
  context.enableUser();//enable skeleton tracking
}
void draw(){
  context.update(); 
  background(0);
  lights();
  translate(width * .5, height * .5,0);
  if(context.isTrackingSkeleton(1)){//we're tracking user #1
        newOrientaton.reset();//reset the raw sensor orientation 
        float confidence = context.getJointOrientationSkeleton(userId,SimpleOpenNI.SKEL_HEAD,newOrientaton);//retrieve the head orientation from OpenNI
        if(confidence > 0.001){//if the new orientation is steady enough (and play with the 0.001 value to see what works best)
          orientation.reset();//reset the matrix and get the new values
          orientation.apply(newOrientaton);//copy the steady orientation to the matrix we use to render the avatar
        }
        //draw a box using the head's orientation
        pushMatrix();
        applyMatrix(orientation);//rotate box based on head orientation
        box(40);
        popMatrix();  
  }
}

キャラクターの階層を整理し、目的の視点でカメラをセットアップするのはあなた次第です。

于 2014-05-31T00:12:38.747 に答える