source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/WalkThroughRecorder.h @ 3220

Revision 3220, 1.5 KB checked in by mattausch, 16 years ago (diff)

worked on video replay function

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