1 /* ResidualVM - A 3D game interpreter 2 * 3 * ResidualVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the AUTHORS 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef STARK_RESOURCES_ANIM_HIERARCHY_H 24 #define STARK_RESOURCES_ANIM_HIERARCHY_H 25 26 #include "common/str.h" 27 28 #include "engines/stark/resources/object.h" 29 #include "engines/stark/resourcereference.h" 30 31 namespace Stark { 32 33 class Visual; 34 35 namespace Formats { 36 class XRCReadStream; 37 } 38 39 namespace Resources { 40 41 class Anim; 42 class BonesMesh; 43 class ItemVisual; 44 class TextureSet; 45 46 /** 47 * An animation hierarchy is a container resource referencing the available 48 * animations for an item. 49 * 50 * This resource keeps track of the currently selected animation. 51 */ 52 class AnimHierarchy : public Object { 53 public: 54 static const Type::ResourceType TYPE = Type::kAnimHierarchy; 55 56 AnimHierarchy(Object *parent, byte subType, uint16 index, const Common::String &name); 57 virtual ~AnimHierarchy(); 58 59 // Resource API 60 void readData(Formats::XRCReadStream *stream) override; 61 void onAllLoaded() override; 62 63 /** Set and apply the current animation kind for an item */ 64 void setItemAnim(ItemVisual *item, int32 usage); 65 66 /** Unselect the current animation and remove it from an item */ 67 void unselectItemAnim(ItemVisual *item); 68 69 /** Apply the current animation to an item */ 70 void selectItemAnim(ItemVisual *item); 71 72 /** Obtain the currently selected animation */ 73 Anim *getCurrentAnim(); 74 75 /** Retrieve the first bone mesh from the anim hierarchy children, if any */ 76 BonesMesh *findBonesMesh(); 77 78 /** 79 * Retrieve the first texture of the appropriate type from the anim 80 * hierarchy children, if any 81 */ 82 TextureSet *findTextureSet(uint32 textureType); 83 84 Visual *getVisualForUsage(uint32 usage); 85 86 /** Randomize an idle action animation */ 87 Anim *getIdleActionAnim() const; 88 89 protected: 90 Anim *getAnimForUsage(uint32 usage); 91 void printData() override; 92 93 Common::Array<ResourceReference> _animationReferences; 94 Common::Array<Anim *> _animations; 95 96 ResourceReference _animHierarchyReference; 97 AnimHierarchy * _animHierarchy; 98 99 float _field_5C; 100 uint32 _animUsage; 101 Anim *_currentAnim; 102 uint32 _idleActionsFrequencySum; 103 }; 104 105 } // End of namespace Resources 106 } // End of namespace Stark 107 108 #endif // STARK_RESOURCES_ANIM_HIERARCHY_H 109