public AnimatedModelData(Matrix[] bonesBindPose, Matrix[] bonesInverseBindPose, int[] bonesParent, AnimationData[] animations) { this.bonesParent = bonesParent; this.bonesBindPose = bonesBindPose; this.bonesInverseBindPose = bonesInverseBindPose; this.animations = animations; }
public void Load(string modelFileName) { if (!isInitialized) Initialize(); model = Game.Content.Load<Model>(GameAssetsPath.MODELS_PATH + modelFileName); // Get animated model data Dictionary<string, object> modelTag = (Dictionary<string, object>)model.Tag; if (modelTag == null) { throw new InvalidOperationException("This is not a valid animated model."); } // Read tag data animatedModelData = (AnimatedModelData)modelTag["AnimatedModelData"]; modelBoundingBox = (BoundingBox)modelTag["ModelBoudingBox"]; modelBoundingSphere = (BoundingSphere)modelTag["ModelBoudingSphere"]; // Animation animationSpeed = 1.0f; activeAnimationKeyframe = 0; activeAnimationTime = TimeSpan.Zero; if (animatedModelData.Animations.Length > 0) activeAnimation = animatedModelData.Animations[0]; bones = new Matrix[animatedModelData.BonesBindPose.Length]; bonesAbsolute = new Matrix[animatedModelData.BonesBindPose.Length]; bonesAnimation = new Matrix[animatedModelData.BonesBindPose.Length]; bonesTransform = new Matrix[animatedModelData.BonesBindPose.Length]; for (int i = 0; i < bones.Length; i++) { bones[i] = animatedModelData.BonesBindPose[i]; bonesTransform[i] = Matrix.Identity; } // Get the animated model effect - Shared by all meshes animatedModelEffect = new AnimatedModelEffect(model.Meshes[0].Effects[0]); // Create a default material lightMaterial = new LightMaterial(); }