ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

anim.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_RESOURCES_ANIM_H
00024 #define STARK_RESOURCES_ANIM_H
00025 
00026 #include "common/rect.h"
00027 #include "common/str.h"
00028 
00029 #include "engines/stark/resources/object.h"
00030 
00031 namespace Common {
00032 class SeekableReadStream;
00033 }
00034 
00035 namespace Stark {
00036 
00037 class SkeletonAnim;
00038 class VisualActor;
00039 class VisualProp;
00040 class VisualSmacker;
00041 class Visual;
00042 namespace Formats {
00043 class XRCReadStream;
00044 }
00045 
00046 namespace Resources {
00047 
00048 class Direction;
00049 class Image;
00050 class Item;
00051 class ItemVisual;
00052 
00058 class Anim : public Object {
00059 public:
00060     static const Type::ResourceType TYPE = Type::kAnim;
00061 
00062     enum SubType {
00063         kAnimImages   = 1,
00064         kAnimProp     = 2,
00065         kAnimVideo    = 3,
00066         kAnimSkeleton = 4
00067     };
00068 
00069     enum ActionUsage {
00070         kActionUsagePassive = 1,
00071         kActionUsageActive  = 2
00072     };
00073 
00074     enum UIUsage {
00075         kUIUsageInventory = 1,
00076         kUIUsageUseCursorPassive = 4,
00077         kUIUsageUseCursorActive = 5
00078     };
00079 
00080     enum ActorActivity {
00081         kActorActivityIdle       = 1,
00082         kActorActivityWalk       = 2,
00083         kActorActivityTalk       = 3,
00084         kActorActivityRun        = 6,
00085         kActorActivityIdleAction = 10
00086     };
00087 
00089     static Object *construct(Object *parent, byte subType, uint16 index, const Common::String &name);
00090 
00091     Anim(Object *parent, byte subType, uint16 index, const Common::String &name);
00092     ~Anim() override;
00093 
00094     // Resource API
00095     void readData(Formats::XRCReadStream *stream) override;
00096 
00098     uint32 getCurrentFrame() { return _currentFrame; }
00099 
00101     virtual void selectFrame(uint32 frameIndex);
00102 
00104     virtual Visual *getVisual() = 0;
00105 
00107     virtual void applyToItem(Item *item);
00108 
00110     virtual void removeFromItem(Item *item);
00111 
00113     bool isInUse() const;
00114 
00116     uint32 getActivity() const;
00117 
00119     virtual int getPointHotspotIndex(const Common::Point &point) const;
00120 
00122     virtual Common::Point getHotspotPosition(uint index) const { return Common::Point(-1, -1); }
00123 
00129     virtual void playAsAction(ItemVisual *item);
00130 
00132     virtual bool isAtTime(uint32 time) const;
00133 
00135     virtual uint32 getMovementSpeed() const;
00136 
00138     virtual uint32 getIdleActionFrequency() const;
00139 
00148     virtual void shouldResetItem(bool resetItem);
00149 
00154     virtual void resetItem();
00155 
00161     virtual bool isDone() const;
00162 
00163 protected:
00164     void printData() override;
00165 
00166     uint32 _activity;
00167     uint32 _currentFrame;
00168     uint32 _numFrames;
00169     int32 _refCount;
00170 };
00171 
00175 class AnimImages : public Anim {
00176 public:
00177     AnimImages(Object *parent, byte subType, uint16 index, const Common::String &name);
00178     ~AnimImages() override;
00179 
00180     // Resource API
00181     void readData(Formats::XRCReadStream *stream) override;
00182     void onAllLoaded() override;
00183     void saveLoad(ResourceSerializer *serializer) override;
00184 
00185     // Anim API
00186     void selectFrame(uint32 frameIndex) override;
00187     Visual *getVisual() override;
00188     int getPointHotspotIndex(const Common::Point &point) const override;
00189     Common::Point getHotspotPosition(uint index) const override;
00190 
00191 protected:
00192     void printData() override;
00193 
00194     float _field_3C;
00195 
00196     uint32 _currentDirection;
00197     Common::Array<Direction *> _directions;
00198 
00199     Image *_currentFrameImage;
00200 };
00201 
00202 class AnimProp : public Anim {
00203 public:
00204     AnimProp(Object *parent, byte subType, uint16 index, const Common::String &name);
00205     ~AnimProp() override;
00206 
00207     // Resource API
00208     void readData(Formats::XRCReadStream *stream) override;
00209     void onPostRead() override;
00210 
00211     // Anim API
00212     Visual *getVisual() override;
00213     uint32 getMovementSpeed() const override;
00214 
00215 protected:
00216     void printData() override;
00217 
00218     Common::String _field_3C;
00219     Common::Array<Common::String> _meshFilenames;
00220     Common::String _textureFilename;
00221     uint32 _movementSpeed;
00222     Common::String _archiveName;
00223 
00224     VisualProp *_visual;
00225 };
00226 
00230 class AnimVideo : public Anim {
00231 public:
00232     AnimVideo(Object *parent, byte subType, uint16 index, const Common::String &name);
00233     ~AnimVideo() override;
00234 
00235     // Resource API
00236     void readData(Formats::XRCReadStream *stream) override;
00237     void onAllLoaded() override;
00238     void onGameLoop() override;
00239     void onEnginePause(bool pause) override;
00240     void saveLoadCurrent(ResourceSerializer *serializer) override;
00241 
00242     // Anim API
00243     Visual *getVisual() override;
00244     void playAsAction(ItemVisual *item) override;
00245     void shouldResetItem(bool resetItem) override;
00246     void resetItem() override;
00247     bool isAtTime(uint32 time) const override;
00248     bool isDone() const override { return _done || !isInUse(); }
00249 
00250 protected:
00251     typedef Common::Array<Common::Point> PointArray;
00252     typedef Common::Array<Common::Rect> RectArray;
00253 
00254     void printData() override;
00255     Common::SeekableReadStream *openOverrideFile(const Common::String &extension) const;
00256 
00258     void updateSmackerPosition();
00259 
00260     Common::String _smackerFile;
00261     Common::String _archiveName;
00262 
00263     VisualSmacker *_smacker;
00264 
00265     uint32 _width;
00266     uint32 _height;
00267 
00268     PointArray _positions;
00269     RectArray _sizes;
00270 
00271     int32 _frameRateOverride;
00272     bool _preload;
00273     bool _loop;
00274     bool _done;
00275 
00276     ItemVisual *_actionItem;
00277     bool _shouldResetItem;
00278 };
00279 
00283 class AnimSkeleton : public Anim {
00284 public:
00285     AnimSkeleton(Object *parent, byte subType, uint16 index, const Common::String &name);
00286     ~AnimSkeleton() override;
00287 
00288     // Resource API
00289     void readData(Formats::XRCReadStream *stream) override;
00290     void onPostRead() override;
00291     void onAllLoaded() override;
00292     void onGameLoop() override;
00293     void onPreDestroy() override;
00294 
00295     // Anim API
00296     void applyToItem(Item *item) override;
00297     void removeFromItem(Item *item) override;
00298     Visual *getVisual() override;
00299     void playAsAction(ItemVisual *item) override;
00300     bool isAtTime(uint32 time) const override;
00301     bool isDone() const override { return _done || !isInUse(); }
00302     uint32 getMovementSpeed() const override;
00303     uint32 getIdleActionFrequency() const override;
00304     void shouldResetItem(bool resetItem) override;
00305     void resetItem() override;
00306 
00308     uint32 getRemainingTime() const;
00309 
00311     uint32 getCurrentTime() const;
00312 
00313 protected:
00314     void printData() override;
00315 
00316     bool _castsShadow;
00317     Common::String _archiveName;
00318     Common::String _animFilename;
00319     bool _loop;
00320     uint32 _movementSpeed;
00321     uint32 _idleActionFrequency;
00322 
00323     uint32 _totalTime;
00324     uint32 _currentTime;
00325     bool _done;
00326 
00327     SkeletonAnim *_skeletonAnim;
00328     VisualActor *_visual;
00329 
00330     ItemVisual *_actionItem;
00331     bool _shouldResetItem;
00332 };
00333 
00334 } // End of namespace Resources
00335 } // End of namespace Stark
00336 
00337 #endif // STARK_RESOURCES_ANIM_H


Generated on Sat Dec 14 2019 05:00:43 for ResidualVM by doxygen 1.7.1
curved edge   curved edge