이것은 첫 번째 그래픽 주제 인 uni에서 구현의 일부분 만 저를 위해 작동하지 않습니다. 나는 관절을 제대로 그리도록 할 수는 있지만 관절 사이에 '뼈'를 넣는 함수를 작성하려고합니다. 이 시점에서 뼈는 직각 프리즘으로 변형 된 큐브 일뿐입니다. 나중에 믹서기 등에서 적절한 모델을 도입하려고 시도합니다.Kinect SDK를 사용하여 전체 3D 뼈대 만들기
내 문제는 회전입니다. 약 5 시간 정도 지나면 내 파트너와 나는 일종의 일을하지만, 팔이나 다리를 움직이면 큐브가 뒤틀려 이상하게 보입니다. 어떤 도움을 주시면 감사하겠습니다. 아래는 뼈를 그리는 함수입니다.
뼈 방향에 대한private void DrawBone(Skeleton skeleton, JointType jointType0, JointType jointType1)
{
Joint joint0 = skeleton.Joints[jointType0];
Joint joint1 = skeleton.Joints[jointType1];
// If we can't find either of these joints, exit
if (joint0.TrackingState == JointTrackingState.NotTracked ||
joint1.TrackingState == JointTrackingState.NotTracked)
{
return;
}
// Don't draw if both points are inferred
if (joint0.TrackingState == JointTrackingState.Inferred &&
joint1.TrackingState == JointTrackingState.Inferred)
{
return;
}
// We assume all drawn bones are inferred unless BOTH joints are tracked
if (joint0.TrackingState == JointTrackingState.Tracked && joint1.TrackingState == JointTrackingState.Tracked)
//jointvector(joint) takes a joint and returns a Vector2 with its position data, with the z invtred to work properly with directx11
Vector3 bonevector = Vector3.Subtract(jointVector(joint0), jointVector(joint1));
//cubevector is supposed to describe the initial vector of a cube centred at (0,0,0) with a side length of 2. A fair amount of guesswork has gone into this bit.
Vector3 cubevector = new Vector3(0, 2, 0);
//midpoint of two joints
Vector3 transTest = Vector3.Divide(Vector3.Add(jointVector(joint0),jointVector(joint1)), 2);
//divide by two because our original cube has side length 2
float scaleFactor = Math.Abs(bonevector.Length()/cubevector.Length());
//we haven't been taught quaternions in class or anything, but after a fair while searching for similar problems they seemed like the go-to option for rotations.
world = Matrix.Transformation(new Vector3(0, 0, 0), new Quaternion(0), new Vector3(0.05f, scaleFactor, 0.05f), new Vector3(0, 0, 0), new Quaternion(Vector3.Cross(cubevector, bonevector), (float)Math.Acos(Vector3.Dot(bonevector, cubevector))), transTest);
//view and proj are defined elsewhere and are working fine, it's just the world that is being lame
worldViewProj = world * view * proj;
worldViewProj.Transpose();
sDXdata.context.UpdateSubresource(ref worldViewProj, sDXdata.constantBuffer);
//36 vertices of the cube (two triangles per face) defined elsewhere
sDXdata.context.Draw(36, 0);
return;
안녕하세요 빈스, 너 혹시이 일이 생겼니? 모델을 3D로 어떻게 표시했는지 이해하는 데 관심이 있습니다. –