Skip to content

Commit

Permalink
Merge branch 'develop-0071' of github.com:obviousjim/ofxCameraTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
obviousjim committed Oct 17, 2013
2 parents 4dc307d + 3aa11fd commit e0ea3c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 0 additions & 2 deletions couples/ofxTimeline/ofxTLCameraTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,10 @@ void ofxTLCameraTrack::nudgeBy(ofVec2f nudgePercent){
}

void ofxTLCameraTrack::save(){
// cout << " saving camera track to " << xmlFileName << endl;
track.writeToFile(xmlFileName);
}

void ofxTLCameraTrack::load(){
// cout << " loading camera track from " << xmlFileName << endl;
track.loadFromFile(xmlFileName);
}

Expand Down
16 changes: 14 additions & 2 deletions src/ofxCameraTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ void ofxCameraTrack::sample(int frame){
ofLogError("ofxCameraTrack -- can't sample a null camera");
}

for(int i = 0; i < samples.size(); i++){
if(samples[i].frame == frame){
samples[i].position = camera->getPosition();
samples[i].orientation = camera->getOrientationQuat();
return;
}
}

CameraSample c;
c.frame = frame;
c.position = camera->getPosition();
Expand All @@ -46,6 +54,10 @@ void ofxCameraTrack::sample(int frame){
cout << "Sampled. First frame is " << samples[0].frame << " " << samples[samples.size()-1].frame << endl;
}

void ofxCameraTrack::addSample(){
sample(samples.size()-1);;
}

string ofxCameraTrack::getXMLRep(){
ofxXmlSettings settings;
settings.addTag("camera");
Expand Down Expand Up @@ -110,14 +122,14 @@ void ofxCameraTrack::writeToFile(string fileName){
}

void ofxCameraTrack::loadFromFile(string fileName){
samples.clear();
ofxXmlSettings settings;
if(settings.loadFile(fileName)){
string rep;
settings.copyXmlToString(rep);
loadFromXMLRep(rep);
}
else{
samples.clear();
ofLogError("ofxCameraTrack -- couldn't load camera file " + fileName);
}
}
Expand Down Expand Up @@ -174,7 +186,7 @@ CameraSample ofxCameraTrack::interpolateBetween(CameraSample sample1, CameraSamp
CameraSample interp;
float alpha;
//CUT
if(sample1.easeOut == CAMERA_EASE_CUT || sample2.easeOut == CAMERA_EASE_CUT ){
if(sample1.easeOut == CAMERA_EASE_CUT || sample2.easeIn == CAMERA_EASE_CUT ){
alpha = 0;
}
//LINEAR
Expand Down
2 changes: 1 addition & 1 deletion src/ofxCameraTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ofxCameraTrack {
vector<CameraSample>& getSamples();
void sample();
void sample(int frame);

void addSample();
void writeToFile(string fileName);
void loadFromFile(string fileName);
void reset();
Expand Down

0 comments on commit e0ea3c2

Please sign in to comment.