From b916619dd6511605610a9249823d3e797ed5928d Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 18 Jun 2012 19:55:39 +0100 Subject: mirror camera etc --- gaunt01/src/morphmesh.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gaunt01/src/morphmesh.cpp') 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 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=(seqtimefadeoutTime&&fadeoutTime>-1?1.0-(seqtime/(stopTime-startTime)):1.0); vector weights; map::iterator i; @@ -96,6 +100,7 @@ vector sequence::evaluate(float time){ morphmesh::morphmesh() { loaded=false; + speed=1.0f; /* //testing track function @@ -155,14 +160,16 @@ void morphmesh::draw(const vector& weights){ } void morphmesh::drawAnimated(){ - float time=ofGetElapsedTimef(); + //compute time increment + time+=(ofGetElapsedTimef()-lastTime)*speed; + lastTime=ofGetElapsedTimef(); vector weights; map::iterator i; for( i = sequences.begin(); i != sequences.end(); i++ ) { if (i->second.active) { vector 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); -- cgit v1.2.3