1
我寫了一個程序來記錄骨架的關節值。 。基本上RightHand.joint從傳感器獲取X,Y,Z座標,現在我想使用這些值來動畫我的3D模型..不知何故,我已經獲得了將x,y值轉換爲真實世界投影的公式,但是不知道如何做,與Z座標..而且我不明白爲什麼我們需要做以下映射x,y,z座標到Xine的Kinect中的屏幕座標或投影座標
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);
不是它足以只需乘以屏幕寬度x和y的值&高度,而不是做* 0.5f(+ 0.5f)。 。如果有人能解釋這將是非常有益的,也如何獲得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);
}
我這樣做,用不同的形式給出。在XNA中,我將x,y,z值的位置賦予模型而無需修改。通過World Matrix我可以縮放,移動,旋轉模型。 (我的「模型」是用圓柱體和球體構建的) – EdgarT
基本上我希望我的模型有一個更自然的運動。例如。一條魚 。 。所以,而不是使用複雜的功能來做到這一點,我只是想記錄一個議案,並動畫它 –
你能否解釋我的骨骼協調和深度之間的差異 –