コード例 #1
0
ファイル: J3D.cs プロジェクト: Sage-of-Mirrors/JStudio
        public void DrawBoundsForJoints(bool boundingBox, bool boundingSphere, IDebugLineDrawer lineDrawer)
        {
            IList <SkeletonJoint> boneList = (m_currentBoneAnimation != null) ? JNT1Tag.AnimatedJoints : JNT1Tag.BindJoints;

            Matrix4[] boneTransforms = new Matrix4[boneList.Count];
            ApplyBonePositionsToAnimationTransforms(boneList, boneTransforms);

            for (int i = 0; i < boneTransforms.Length; i++)
            {
                SkeletonJoint curJoint, origJoint;
                curJoint = origJoint = JNT1Tag.BindJoints[i];

                //Matrix4 cumulativeTransform = Matrix4.Identity;
                //while (true)
                //{
                //    Matrix4 jointMatrix = Matrix4.CreateScale(curJoint.Scale) * Matrix4.CreateFromQuaternion(curJoint.Rotation) * Matrix4.CreateTranslation(curJoint.Translation);
                //    cumulativeTransform *= jointMatrix;
                //    if (curJoint.Parent == null)
                //        break;

                //    curJoint = curJoint.Parent;
                //}

                //boneTransforms[i] = cumulativeTransform;
                boneTransforms[i].Transpose();
                Vector3    curPos = boneTransforms[i].ExtractTranslation();
                Quaternion curRot = boneTransforms[i].ExtractRotation();

                WLinearColor jointColor = origJoint.Unknown1 == 0 ? WLinearColor.Yellow : WLinearColor.Blue;
                if (boundingSphere)
                {
                    // Many bones have no radius, simply skip them to avoid adding them to the line renderer.
                    if (origJoint.BoundingSphereDiameter == 0f)
                    {
                        continue;
                    }

                    lineDrawer.DrawSphere(curPos, origJoint.BoundingSphereDiameter / 2, 12, jointColor, 0f, 0f);
                }
                if (boundingBox)
                {
                    Vector3 extents = (origJoint.BoundingBox.Max - origJoint.BoundingBox.Min) / 2;

                    // Many bones have no extents, simply skip them to avoid adding them to the line renderer.
                    if (extents.LengthSquared == 0f)
                    {
                        continue;
                    }

                    lineDrawer.DrawBox(curPos, extents, curRot, jointColor, 0f, 0f);
                }
            }
        }
コード例 #2
0
ファイル: J3D.cs プロジェクト: Sage-of-Mirrors/JStudio
 public void DrawBoundsForShapes(bool boundingBox, bool boundingSphere, IDebugLineDrawer lineDrawer)
 {
     foreach (var shape in SHP1Tag.Shapes)
     {
         if (boundingSphere)
         {
             lineDrawer.DrawSphere(shape.BoundingBox.Center, shape.BoundingSphereDiameter / 2f, 12, WLinearColor.White, 0f, 0f);
         }
         if (boundingBox)
         {
             lineDrawer.DrawBox(shape.BoundingBox.Min, shape.BoundingBox.Max, WLinearColor.Green, 0f, 0f);
         }
     }
 }