summaryrefslogtreecommitdiff
path: root/gaunt01/src/morphmesh.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-06-18 19:55:39 +0100
committerTim Redfern <tim@eclectronics.org>2012-06-18 19:55:39 +0100
commitb916619dd6511605610a9249823d3e797ed5928d (patch)
tree32d911f72a7b62da0643f749f07fdf85c54af1d0 /gaunt01/src/morphmesh.cpp
parent7527cc22efd63be17430924b2ee9e621582a2dd1 (diff)
mirror camera etc
Diffstat (limited to 'gaunt01/src/morphmesh.cpp')
-rw-r--r--gaunt01/src/morphmesh.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/gaunt01/src/morphmesh.cpp b/gaunt01/src/morphmesh.cpp
index a126002..6dc3338 100644
--- a/gaunt01/src/morphmesh.cpp
+++ b/gaunt01/src/morphmesh.cpp
@@ -82,8 +82,12 @@ void sequence::stop(){
vector<morphWeight> sequence::evaluate(float time){
float now=ofGetElapsedTimef();
- float seqtime=time-startTime;
- float looptime=fmod(seqtime,length);
+ float seqtime=now-startTime;
+ float animtime=time-startTime;
+ //for this to be correct time has to begin at actual startTime and proceed relatively
+ //stopTime has to be based on absolute time
+ //fadeweight algorithm has to be absolute
+ float looptime=fmod(animtime,length);
float fadeWeight=(seqtime<fadeinTime?seqtime/fadeinTime:seqtime>fadeoutTime&&fadeoutTime>-1?1.0-(seqtime/(stopTime-startTime)):1.0);
vector<morphWeight> weights;
map<string,track>::iterator i;
@@ -96,6 +100,7 @@ vector<morphWeight> sequence::evaluate(float time){
morphmesh::morphmesh()
{
loaded=false;
+ speed=1.0f;
/*
//testing track function
@@ -155,14 +160,16 @@ void morphmesh::draw(const vector<morphWeight>& weights){
}
void morphmesh::drawAnimated(){
- float time=ofGetElapsedTimef();
+ //compute time increment
+ time+=(ofGetElapsedTimef()-lastTime)*speed;
+ lastTime=ofGetElapsedTimef();
vector<morphWeight> weights;
map<string,sequence>::iterator i;
for( i = sequences.begin(); i != sequences.end(); i++ ) {
if (i->second.active) {
vector<morphWeight> newWeights=i->second.evaluate(time);
weights.insert(weights.end(),newWeights.begin(),newWeights.end());
- if (i->second.stopTime>0&&time>i->second.stopTime) i->second.active=false;
+ if (i->second.stopTime>0&&ofGetElapsedTimef()>i->second.stopTime) i->second.active=false;
}
}
draw(weights);