private void LoadAnimationIntoCache(string modelKey) { // Builds the animation object for all model, action, direction // combinations. Object is then added to the AnimationCache. AnimationCache animationCache = AnimationCache.Instance; foreach (BaseAction directionalAction in _directionalActions) { // Use the respective importer for the action IAnimationImporter animationImporter = directionalAction.GetAnimationImporter(); var newAnimations = animationImporter.ImportAnimations(modelKey, DirectionType.Down); foreach (AnimationDNABlock newAnimation in newAnimations) { string animationKey = $"{modelKey}_{directionalAction.AnimationTag}_{DirectionType.GetAnimationForDirection(newAnimation.Direction)}"; animationCache.Add(animationKey, newAnimation); } } // The "Idle" action reuses the first image of the death animation, so we need // to import the first frame of all death sprites without a direction tag. BaseAction deathAnimation = new DeathAction(); var deathImporter = deathAnimation.GetAnimationImporter(); var deathAnimations = deathImporter.ImportAnimations(modelKey, DirectionType.None); foreach (AnimationDNABlock newAnimation in deathAnimations) { string animationKey = $"{modelKey}_{deathAnimation.AnimationTag}"; animationCache.Add(animationKey, newAnimation); } }
public GLTFImporter(IShaderStore shaderStore, IMeshImporter meshImporter, IMaterialImporter materialImporter, INodeImporter nodeImporter, IAnimationImporter animationImporter) { _shaderStore = shaderStore ?? new ShaderStore(this); _meshImporter = meshImporter ?? new MeshImporter(); _materialImporter = materialImporter ?? new MaterialImporter(_shaderStore, this); _nodeImporter = nodeImporter ?? new NodeImporter(); _animationImporter = animationImporter ?? new AnimationImporter(); }
public void LoadAnimationIntoCache(string modelKey) { /* * Builds the animation object for all model, action, direction * combinations. Object is then added to the AnimationCache. */ AnimationCache animationStore = AnimationCache.Instance; // All directional actions List <BaseAction> directionalActions = new List <BaseAction>(); directionalActions.Add(new SlashAction()); directionalActions.Add(new SpellcastAction()); directionalActions.Add(new ThrustAction()); directionalActions.Add(new WalkAction()); directionalActions.Add(new ShootAction()); directionalActions.Add(new DeathAction()); foreach (BaseAction actionAnimation in directionalActions) { // Use the respective importer for the action IAnimationImporter importer = actionAnimation.GetAnimationImporter(); List <AnimationDNABlock> newAnimations = importer.ImportAnimations(modelKey, DirectionType.DOWN); foreach (AnimationDNABlock newAnimation in newAnimations) { string animationKey = String.Format("{0}_{1}_{2}", modelKey, actionAnimation.GetAnimationTag(), DirectionType.GetAnimationForDirection(newAnimation.Direction)); animationStore.Add(animationKey, newAnimation); } } // The "Idle" action reuses the first image of the death animation, so we need // to import the first frame of all death sprites without a direction tag. BaseAction deathAnimation = new DeathAction(); IAnimationImporter deathImporter = deathAnimation.GetAnimationImporter(); List <AnimationDNABlock> deathAnimations = deathImporter.ImportAnimations(modelKey, DirectionType.NONE); foreach (AnimationDNABlock newAnimation in deathAnimations) { string animationKey = String.Format("{0}_{1}", modelKey, deathAnimation.GetAnimationTag()); animationStore.Add(animationKey, newAnimation); } }
public void SetAnimationImporter(IAnimationImporter animationImporter) { m_animationImporter = animationImporter; }