public AnimationInstance(ModelInstance modelInstance, W3DAnimation animation, AnimationMode mode, AnimationFlags flags) { _animation = animation; _mode = mode; _flags = flags; _boneInstances = modelInstance.ModelBoneInstances; _keyframeIndices = new int[animation.Clips.Length]; if (_flags.HasFlag(AnimationFlags.StartFrameFirst) || _flags == AnimationFlags.None) { _currentTimeValue = TimeSpan.Zero; } else if (_flags.HasFlag(AnimationFlags.StartFrameLast)) { _currentTimeValue = _animation.Duration; } else { //TODO: implement other flags //throw new NotImplementedException(); } }
internal static W3DAnimation FromW3dFile(W3dFile w3dFile) { var w3dAnimations = w3dFile.GetAnimations(); var w3dCompressedAnimations = w3dFile.GetCompressedAnimations(); var animations = new W3DAnimation[w3dAnimations.Count + w3dCompressedAnimations.Count]; if (animations.Length == 0) { // sometimes w3d files are referenced inside animation states that do not contain any animation chunks return(null); } if (animations.Length != 1) { throw new NotSupportedException(); } for (var i = 0; i < w3dAnimations.Count; i++) { animations[i] = new W3DAnimation(w3dAnimations[i]); } for (var i = 0; i < w3dCompressedAnimations.Count; i++) { animations[w3dAnimations.Count + i] = new W3DAnimation(w3dCompressedAnimations[i]); } return(animations[0]); }
public AnimationInstance(ModelInstance modelInstance, W3DAnimation animation) { _animation = animation; _boneInstances = modelInstance.ModelBoneInstances; _keyframeIndices = new int[animation.Clips.Length]; _currentTimeValue = TimeSpan.Zero; }
public AnimationInstance(ModelInstance modelInstance, W3DAnimation animation, AnimationMode mode, AnimationFlags flags, GameObject gameObject) { _gameObject = gameObject; _animation = animation; _mode = mode; _flags = flags; _boneInstances = modelInstance.ModelBoneInstances; _keyframeIndices = new int[animation.Clips.Length]; }
/// <summary> /// Construct a new <see cref="AnimationInstance"/> /// </summary> /// <param name="modelBoneInstances">The bone instances to use, which will be modified as the animation plays</param> /// <param name="animation">The animation to apply to the bones</param> /// <param name="mode">The animation mode</param> /// <param name="flags">Additional animation flags</param> /// <param name="gameObject"></param> /// <param name="random">Random number generator used when combined with <see cref="AnimationFlags.RandomStart"/></param> public AnimationInstance(ModelBoneInstance[] modelBoneInstances, W3DAnimation animation, AnimationMode mode, AnimationFlags flags, GameObject gameObject, Random random) { _animation = animation; _mode = mode; _flags = flags; _boneInstances = modelBoneInstances; _keyframeIndices = new int[animation.Clips.Length]; _gameObject = gameObject; _random = random; }
internal static W3DAnimation FromW3dFile(W3dFile w3dFile) { var w3dAnimations = w3dFile.GetAnimations(); var w3dCompressedAnimations = w3dFile.GetCompressedAnimations(); var animations = new W3DAnimation[w3dAnimations.Count + w3dCompressedAnimations.Count]; if (animations.Length != 1) { throw new NotSupportedException(); } for (var i = 0; i < w3dAnimations.Count; i++) { animations[i] = new W3DAnimation(w3dAnimations[i]); } for (var i = 0; i < w3dCompressedAnimations.Count; i++) { animations[w3dAnimations.Count + i] = new W3DAnimation(w3dCompressedAnimations[i]); } return(animations[0]); }