/Rendering/Models/Model.cs
C# | 137 lines | 22 code | 4 blank | 111 comment | 1 complexity | c6a41e38616d08b71d235dfae09f6d35 MD5 | raw file
Possible License(s): Apache-2.0
- namespace Delta.Rendering.Models
- {
- /// <summary>
- /// Sorry, this class is not yet implemented and needs to be merged first!
- /// </summary>
- internal class Model
- {
-
-
- #region IsAnimated (Public)
- /// <summary>
- /// "True" if the mesh is animated and contains animation data
- /// animation.
- /// </summary>
- public bool IsAnimated
- {
- get
- {
- return Animation != null;
- }
- }
- #endregion
-
- #region Animation (Public)
- /// <summary>
- /// Animation
- /// </summary>
- /// <returns>Animation</returns>
- public Animation Animation
- {
- get;
- private set;
- }
- #endregion
-
- /*TODO
- if (setAnimationData != null)
- {
- Animation = new Animation(this, setAnimationData);
- // Update once to get an initial pose (else you can't see the mesh)
- UpdateAnimation();
- }
- #region UpdateAnimation
- /// <summary>
- /// Updates the animation.
- /// </summary>
- public void UpdateAnimation()
- {
- //Animation.Update();
- //Matrix[] finalPoseMatrices = Geometry.FinalBoneMatrices;
- //for (int index = 0; index < finalPoseMatrices.Length; index++)
- //{
- // BoneData bone = Geometry.Data.Bones[index];
- // finalPoseMatrices[index] = bone.CombinedBoneSkinMatrix *
- // bone.FinalAnimationMatrix;
- //} // for
-
- // Update the bone data for skinned meshes
-
- //Geometry.UpdateAnimation(ref Matrix.Identity);
- //Geometry.UpdateFinalBoneMatrices(ref Matrix.Identity);
- if (Animation != null)
- {
- //Animation.Update(Geometry.Data.Bones);
- Animation.Update();//obs: null);
- }
- } // UpdateAnimation(drawTransformation)
- #endregion
-
- #region DebugShowSkeleton
- /// <summary>
- /// Debug show skeleton
- /// </summary>
- /// <param name="drawTransformation">Draw transformation</param>
- public void DebugShowSkeleton(ref Matrix drawTransformation)
- {
- int boneNum = 0;
- BoneData[] bones = Geometry.Data.Bones;
-
- // Draw a line from the parent to (all of) his children
- Matrix[] boneRenderMatrices = Geometry.FinalBoneMatrices;
- foreach (BoneData bone in bones)
- {
- //foreach (BoneData childBone in bone.Children)
- foreach (int childBoneId in bone.ChildrenIds)
- {
- //Line.Draw(
- // (boneAnimationMatrices[bone.Id] * drawTransformation).Translation,
- // (boneAnimationMatrices[childBoneId] * drawTransformation).Translation,
- // BoneColors[boneNum % BoneColors.Length]);
-
- // The bone matrices are baked with
- // "bone.InverseBoneMatrix * bone.AnimationTransformMatrix".
- // For visualizing the (animated / transformed) skeleton we only need
- // the bone position in the (current) animation frame. The needed
- // data is located in the 'Translation' part of the
- // 'bone.AnimationTransformMatrix' which we get back if we "remove"
- // the 'bone.InverseBoneMatrix' part of the baked matrix again.
- //
- // Bone.RenderTransform = Bone.InverseTransfrom * Bone.AnimTransform
- // Bone.AnimTransform = Bone.SpaceTransfrom * Bone.RenderTransform
-
- //Line.Draw(
- // (bone.InverseBoneSkinMatrix.Inverse *
- // boneRenderMatrices[bone.Id]).Translation,
- // (bones[childBoneId].InverseBoneSkinMatrix.Inverse *
- // boneRenderMatrices[childBoneId]).Translation,
- // BoneColors[boneNum % BoneColors.Length]);
-
- // Init with the "ParentBone.SpaceTransform" because we need to init
- // the "AnimationTransform" matrix, so we just share it instead to
- // to declare 2 matrices
- Matrix parentBoneAnimTransform = bone.InverseTransformMatrix.Inverse;
- Matrix.Multiply(ref parentBoneAnimTransform,
- ref boneRenderMatrices[bone.Id], ref parentBoneAnimTransform);
-
- // Init with the "ChildBone.SpaceTransform" because we need to init
- // the "AnimationTransform" matrix, so we just share it instead to
- // to declare 2 matrices
- Matrix childBoneAnimTransform =
- bones[childBoneId].InverseTransformMatrix.Inverse;
- Matrix.Multiply(ref childBoneAnimTransform,
- ref boneRenderMatrices[childBoneId], ref childBoneAnimTransform);
-
- Line.Draw(parentBoneAnimTransform.Translation,
- childBoneAnimTransform.Translation,
- BoneColors[boneNum % BoneColors.Length]);
-
- boneNum++;
- } // foreach
- } // foreach
- } // DebugShowSkeleton(drawTransformation)
- #endregion
-
- */
- }
- }