diff options
| author | Comment <tim@gray.(none)> | 2013-01-24 18:07:04 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-01-24 18:07:04 +0000 |
| commit | 3bf0663e94b6335cb748a50a8b95e8a98d2a0630 (patch) | |
| tree | a82627776c3bdeedbc99e2b6dcf97b78328a5047 /liveengine/src/layers.h | |
| parent | e54790009e0d7b6ae5cc4d3e54880ff0bdc63f86 (diff) | |
folded kinect into main branch
Diffstat (limited to 'liveengine/src/layers.h')
| -rwxr-xr-x | liveengine/src/layers.h | 85 |
1 files changed, 81 insertions, 4 deletions
diff --git a/liveengine/src/layers.h b/liveengine/src/layers.h index c6f4171..f8ed650 100755 --- a/liveengine/src/layers.h +++ b/liveengine/src/layers.h @@ -3,6 +3,7 @@ #include "ofxSVGTiny.h" #include "ofMain.h"
+#include "ofxSprite.h"
class layer
{
@@ -13,7 +14,10 @@ class layer virtual void load(string _f){};
virtual void draw(float a,int cx,int cy,float colShift){}; virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f){ draw(a,cx,cy,colShift);}; - bool getLoaded() {return isLoaded;};
+ bool getLoaded() {return isLoaded;}; + virtual void setNote(int note) {};
+ string name;
+ int startNote,endNote;
protected: bool isLoaded;
private:
@@ -37,18 +41,91 @@ class svglayer: public layer vector <ofColor> strokes; float xo,yo;
};
+ +class sunkenSprite: public ofxSprite { + public: + float playhead,frameRate;
+ void setFrameRate(float frameRate) { this->frameRate = frameRate;}; + void play() { + startTime=ofGetElapsedTimef(); + ofxSprite::play(); + } + void update() { + if (!getIsPlaying()) return;
+ playhead=fmod(speed * frameRate * (ofGetElapsedTimef()-startTime),(float)getTotalFrames()); + ofxSprite::setCurrentFrame(playhead); + + } + void setCurrentFrame(float frame) {
+ //this idea doesn't work - fucks up when frameRate is 0 -
+ //need to rethink
+
+ //when frameRate is 0 startTime doesn't matter
+ //this still might not be not entirely correct
+ if (frameRate>0) startTime-=(frame-pos) / ((float)(frameRate * speed ));
+ //printf("sunkensprite setting frame %i of %i\n",(int)frame,getTotalFrames());
+ //printf("1 checking frame %i of %i\n",(int)frame,getTotalFrames()); + ofxSprite::setCurrentFrame(frame);
+ /*
+ pos = frame;
+ printf("2 checking frame %i of %i\n",(int)frame,getTotalFrames());
+ printf("requesting movie frame %i of %i\n",(int)pos,getTotalFrames());
+ if (pos<0) if (loop) { pos += totalFrames; } else stop();
+ if (pos>=totalFrames) if (loop) {
+ while (pos>=totalFrames) pos -= totalFrames;
+ } else { pos = totalFrames-.00001f; isPlaying=false; }
+ printf("set movie frame %i of %i\n",(int)pos,totalFrames);
+ */ + } + void draw(int x,int y,int w,int h) { + + int f=playhead; + float fr=fmod(playhead,1.0); + ofSetColor(255,255,255,(1.0-fr)*255); + //not always? + getImageAtFrame(f).setUseTexture(true); + getImageAtFrame(f).reloadTexture();
+ getImageAtFrame(f).draw(x,y,w,h); + ofSetColor(255,255,255,fr*255);
+ f=(f+1)%getTotalFrames(); + getImageAtFrame(f).setUseTexture(true);
+ getImageAtFrame(f).reloadTexture();
+ getImageAtFrame(f).draw(x,y,w,h); + } + + private: + float startTime; + +}; class imglayer: public layer
{
public:
imglayer();
- imglayer(string _f);
+ imglayer(string _f,int _frames=1,int _start=1,float _rate=0,int note=0,int endnote=0);
virtual ~imglayer();
- void load(string _f);
+ void load(string _filename,int _frames=1,int _start=1,float _rate=0.0,int note=0,int endnote=0);
void draw(float a,int cx,int cy,float colShift); void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift);
+ void setNote(int n);
protected:
private:
- ofImage img;
+ sunkenSprite sprite;
+}; + +class videolayer: public layer
+{
+ public:
+ videolayer();
+ videolayer(string _f,int n,int e,float s);
+ virtual ~videolayer();
+ void load(string _f);
+ void draw(float a,int cx,int cy,float colShift); + void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift); + void setNote(int n); + protected:
+ private: + float speed;
+ ofVideoPlayer mov;
};
#endif // SVGLAYER_H
|
