[3173] | 1 | #ifndef _WALKTHROUGHRECORDER_H__
|
---|
| 2 | #define _WALKTHROUGHRECORDER_H__
|
---|
| 3 |
|
---|
| 4 | #include "common.h"
|
---|
[3210] | 5 | #include <fstream>
|
---|
[3219] | 6 | #include "Vector3.h"
|
---|
[3173] | 7 |
|
---|
[3219] | 8 |
|
---|
[3173] | 9 | namespace CHCDemoEngine
|
---|
| 10 | {
|
---|
| 11 |
|
---|
[3210] | 12 | class Camera;
|
---|
| 13 |
|
---|
[3219] | 14 | struct FrameInfo
|
---|
| 15 | {
|
---|
| 16 | FrameInfo(const Vector3 &pos, const Vector3 &dir):
|
---|
| 17 | mPosition(pos), mDirection(dir)
|
---|
| 18 | {}
|
---|
[3210] | 19 |
|
---|
[3219] | 20 | FrameInfo() {}
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | /////////////
|
---|
| 24 |
|
---|
| 25 | Vector3 mPosition;
|
---|
| 26 | Vector3 mDirection;
|
---|
| 27 |
|
---|
| 28 | friend std::ostream& operator<< (std::ostream &s, const FrameInfo &A);
|
---|
| 29 | friend std::istream& operator>> (std::istream &s, FrameInfo &A);
|
---|
| 30 | };
|
---|
| 31 |
|
---|
| 32 |
|
---|
[3220] | 33 | /// Overload << operator for C++-style output
|
---|
[3219] | 34 | inline std::ostream& operator<< (std::ostream &s, const FrameInfo &A)
|
---|
| 35 | {
|
---|
| 36 | return s << A.mPosition << " " << A.mDirection;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 |
|
---|
[3220] | 40 | /// Overload >> operator for C++-style input
|
---|
[3219] | 41 | inline std::istream& operator>> (std::istream &s, FrameInfo &A)
|
---|
| 42 | {
|
---|
| 43 | return s >> A.mPosition >> A.mDirection;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 |
|
---|
[3210] | 47 | /** Records given walkthrough
|
---|
[3173] | 48 | */
|
---|
| 49 | class WalkThroughRecorder
|
---|
| 50 | {
|
---|
| 51 | public:
|
---|
[3210] | 52 | /** Writes walkthrough frames to file.
|
---|
| 53 | */
|
---|
| 54 | WalkThroughRecorder(const std::string &filename);
|
---|
[3220] | 55 |
|
---|
| 56 | ~WalkThroughRecorder();
|
---|
| 57 |
|
---|
[3210] | 58 | /** Writes current camera data.
|
---|
| 59 | */
|
---|
| 60 | void WriteFrame(Camera *cam);
|
---|
[3219] | 61 |
|
---|
[3220] | 62 |
|
---|
[3210] | 63 | protected:
|
---|
| 64 |
|
---|
| 65 | std::ofstream mFile;
|
---|
[3173] | 66 | };
|
---|
| 67 |
|
---|
[3220] | 68 |
|
---|
[3210] | 69 | /** Replays a given walkthrough
|
---|
| 70 | */
|
---|
| 71 | class WalkThroughPlayer
|
---|
| 72 | {
|
---|
| 73 | public:
|
---|
| 74 | /** Writes walkthrough frames to file.
|
---|
| 75 | */
|
---|
| 76 | WalkThroughPlayer(const std::string &filename);
|
---|
[3219] | 77 | /** Reads next frame. returns false if end of recorded frames is reached.
|
---|
[3210] | 78 | */
|
---|
[3219] | 79 | bool ReadNextFrame(Camera *cam);
|
---|
[3210] | 80 |
|
---|
[3219] | 81 |
|
---|
[3210] | 82 | protected:
|
---|
| 83 |
|
---|
[3219] | 84 | std::vector<FrameInfo> mFrameInfos;
|
---|
| 85 |
|
---|
| 86 | int mFrame;
|
---|
[3210] | 87 | };
|
---|
| 88 |
|
---|
| 89 |
|
---|
[3173] | 90 | }
|
---|
| 91 |
|
---|
| 92 | #endif
|
---|