-
Notifications
You must be signed in to change notification settings - Fork 0
/
Frame.h
69 lines (56 loc) · 1.98 KB
/
Frame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// A single frame in an animation for our model. Represents both key and
// interpolated frames.
//
// Author: Michael DiBernardo
//
// REFERENCES:
// 1. Assignment spec.
// 2. Foster, Garret. "Understanding and Implementing Scene Graphs."
// Available online at http://www.gamedev.net/reference/programming/features/scenegraph/
#ifndef __FRAME_H__
#define __FRAME_H__
#include <fstream>
#include <iostream>
#include <math.h>
#include <sstream>
#include <string>
using std::ifstream;
class Frame {
public:
// Construct a new Frame given a pointer to the beginning of a keyframe
// record in a file. Advances the given input by a single Frame record, and
// does NOT take ownership of the given stream.
// This should really be a static factory function so that we can throw
// errors without dying, but pretty much any error in this process will
// require the program to die anyways, so it's no big loss...
explicit Frame(ifstream* fp);
// Constructs a new Frame with uninitialized values for its fields. Used
// by overloaded operators.
explicit Frame(int numFields);
// Copy constructor.
Frame(const Frame& rhs);
// Frees this keyframe. Doesn't really do anything.
~Frame();
// Gets the number of fields in this frame (ie the number of parameters
// recorded for it).
int getNumFields() const;
// Returns the list of field values that compose this frame.
const double* getFields() const;
// Returns when this frame is supposed to occur in the sequence of animation.
// Units are milliseconds.
unsigned long getTimeInMS() const;
// Vector addition.
Frame operator+(const Frame& rhs) const;
// Vector subtraction.
Frame operator-(const Frame& rhs) const;
// Scalar multiplication.
Frame operator*(double scalar) const;
private:
// What time is this frame supposed to be displayed at?
unsigned long time_;
// What are the values of all the joint angles etc.?
double* fields_;
// How many fields are there?
int numFields_;
};
#endif