Skeleton のジョイント値を記録するプログラムを作成しました。. 基本的には、RightHand.joint を使用してセンサーから X、Y、Z 座標を取得します。これらの値を使用して 3D モデルをアニメーション化したいと考えています。どういうわけか、x、y 値を現実世界の投影に変換する式を取得しましたが、 Z座標でそれを行う方法がわかりません..また、次のことを行う必要がある理由もわかりません
int x = (int) Math.Floor(((float.Parse(temp[0]) * 0.5f) + 0.5f) * maxWidth);
int y = (int) Math.Floor(((float.Parse(temp[1]) * -0.5f) + 0.5f) * maxHeight);
*0.5f (+0.5f) を実行する代わりに、x と y の値に画面の幅と高さを掛けるだけで十分ではありませんか。. 誰かがそれを説明できれば非常に役に立ち、Z座標を取得する方法も?
コードは次のとおりです。
protected override void Update(GameTime gameTime)
{
//// TODO: Add your update logic here
using (StreamReader r = new StreamReader(f))
{
string line;
Viewport view = graphics.GraphicsDevice.Viewport;
int maxWidth = view.Width;
int maxHeight = view.Height;
while ((line = r.ReadLine()) != null)
{
string[] temp = line.Split(',');
int x = (int)Math.Floor(((float.Parse(temp[0]) * 0.5f) + 0.5f) * maxWidth);
int y = (int)Math.Floor(((float.Parse(temp[1]) * -0.5f) + 0.5f) * maxHeight);
//Wrong Z - value Cal (Testing)
int z = (int)Math.Floor(((float.Parse(temp[2])* 0.5) + 0.5f) * maxHeight);
motion_z.Add(new Point3D(x, y, z));
}
}
ModelPosition.X = (float)(motion_z[i].X);
ModelPosition.Y = (float)(motion_z[i].Y);
ModelPosition.Z = (float)(motion_z[i].Z);
i++;
base.Update(gameTime);
}