Line | |
---|
1 | #include "WalkThroughRecorder.h"
|
---|
2 | #include "Camera.h"
|
---|
3 | #include "Vector3.h"
|
---|
4 | #include <sstream>
|
---|
5 |
|
---|
6 | using namespace std;
|
---|
7 |
|
---|
8 |
|
---|
9 | namespace CHCDemoEngine
|
---|
10 | {
|
---|
11 |
|
---|
12 |
|
---|
13 | WalkThroughRecorder::WalkThroughRecorder(const std::string &filename):
|
---|
14 | mFile(filename.c_str())
|
---|
15 | {
|
---|
16 | }
|
---|
17 |
|
---|
18 |
|
---|
19 | void WalkThroughRecorder::WriteFrame(Camera *cam)
|
---|
20 | {
|
---|
21 | FrameInfo info(cam->GetPosition(), cam->GetDirection());
|
---|
22 | mFile << info << endl;
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | WalkThroughPlayer::WalkThroughPlayer(const std::string &filename):
|
---|
27 | mFrame(0)
|
---|
28 | {
|
---|
29 | ifstream file(filename.c_str());
|
---|
30 | FrameInfo info;
|
---|
31 | int i=0;
|
---|
32 |
|
---|
33 | std::string token;
|
---|
34 |
|
---|
35 | while(std::getline(file, token))
|
---|
36 | {
|
---|
37 | std::stringstream line(token);
|
---|
38 |
|
---|
39 | line >> info;
|
---|
40 | mFrameInfos.push_back(info);
|
---|
41 | }
|
---|
42 | }
|
---|
43 |
|
---|
44 |
|
---|
45 | bool WalkThroughPlayer::ReadNextFrame(Camera *cam)
|
---|
46 | {
|
---|
47 | cam->SetDirection(mFrameInfos[mFrame].mDirection);
|
---|
48 | cam->SetPosition(mFrameInfos[mFrame].mPosition);
|
---|
49 |
|
---|
50 | mFrame = (mFrame + 1) % (int)mFrameInfos.size();
|
---|
51 |
|
---|
52 | return mFrame != 0;
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.