summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-06-22 11:40:11 +0100
committerTim Redfern <tim@eclectronics.org>2012-06-22 11:40:11 +0100
commit11a2a8968984d35e59809d5c4ef602db9fac52dc (patch)
tree6f9c6ad3464824880efdf0e1b1ca67ac42dfc7ef
parentb916619dd6511605610a9249823d3e797ed5928d (diff)
new media files
-rw-r--r--gaunt01/bin/data/GUI_instructions.pngbin0 -> 102846 bytes
-rw-r--r--gaunt01/bin/data/_GUI_nzsLogo.pngbin0 -> 27745 bytes
-rw-r--r--gaunt01/bin/data/aggressive1.wavbin0 -> 1613452 bytes
-rw-r--r--gaunt01/bin/data/aggressive2.wavbin0 -> 1002096 bytes
-rw-r--r--gaunt01/bin/data/chirp1.wavbin0 -> 116796 bytes
-rw-r--r--gaunt01/bin/data/chirp2.wavbin0 -> 119032 bytes
-rw-r--r--gaunt01/bin/data/rattle1.wavbin0 -> 166728 bytes
-rw-r--r--gaunt01/bin/data/rattle2.wavbin0 -> 159996 bytes
-rw-r--r--gaunt01/bin/data/rattle3.wavbin0 -> 178472 bytes
-rw-r--r--gaunt01/src/bird.cpp17
-rw-r--r--gaunt01/src/bird.h2
-rw-r--r--gaunt01/src/testApp.cpp135
-rw-r--r--gaunt01/src/testApp.h1
13 files changed, 90 insertions, 65 deletions
diff --git a/gaunt01/bin/data/GUI_instructions.png b/gaunt01/bin/data/GUI_instructions.png
new file mode 100644
index 0000000..3ea1a4d
--- /dev/null
+++ b/gaunt01/bin/data/GUI_instructions.png
Binary files differ
diff --git a/gaunt01/bin/data/_GUI_nzsLogo.png b/gaunt01/bin/data/_GUI_nzsLogo.png
new file mode 100644
index 0000000..ecf3750
--- /dev/null
+++ b/gaunt01/bin/data/_GUI_nzsLogo.png
Binary files differ
diff --git a/gaunt01/bin/data/aggressive1.wav b/gaunt01/bin/data/aggressive1.wav
new file mode 100644
index 0000000..9e0d715
--- /dev/null
+++ b/gaunt01/bin/data/aggressive1.wav
Binary files differ
diff --git a/gaunt01/bin/data/aggressive2.wav b/gaunt01/bin/data/aggressive2.wav
new file mode 100644
index 0000000..66d9ee2
--- /dev/null
+++ b/gaunt01/bin/data/aggressive2.wav
Binary files differ
diff --git a/gaunt01/bin/data/chirp1.wav b/gaunt01/bin/data/chirp1.wav
new file mode 100644
index 0000000..8668085
--- /dev/null
+++ b/gaunt01/bin/data/chirp1.wav
Binary files differ
diff --git a/gaunt01/bin/data/chirp2.wav b/gaunt01/bin/data/chirp2.wav
new file mode 100644
index 0000000..7ca2c20
--- /dev/null
+++ b/gaunt01/bin/data/chirp2.wav
Binary files differ
diff --git a/gaunt01/bin/data/rattle1.wav b/gaunt01/bin/data/rattle1.wav
new file mode 100644
index 0000000..dbda05d
--- /dev/null
+++ b/gaunt01/bin/data/rattle1.wav
Binary files differ
diff --git a/gaunt01/bin/data/rattle2.wav b/gaunt01/bin/data/rattle2.wav
new file mode 100644
index 0000000..5c4bbb7
--- /dev/null
+++ b/gaunt01/bin/data/rattle2.wav
Binary files differ
diff --git a/gaunt01/bin/data/rattle3.wav b/gaunt01/bin/data/rattle3.wav
new file mode 100644
index 0000000..103d1dc
--- /dev/null
+++ b/gaunt01/bin/data/rattle3.wav
Binary files differ
diff --git a/gaunt01/src/bird.cpp b/gaunt01/src/bird.cpp
index 7d9fb02..6e7ff92 100644
--- a/gaunt01/src/bird.cpp
+++ b/gaunt01/src/bird.cpp
@@ -21,6 +21,15 @@ bird::bird()
//how to track state/ bring animation in and out
state=SCANNING;
+
+ sounds=new ofSoundPlayer[7];
+ sounds[0].loadSound("aggressive1.wav");
+ sounds[1].loadSound("aggressive2.wav");
+ sounds[2].loadSound("chirp1.wav");
+ sounds[3].loadSound("chirp2.wav");
+ sounds[4].loadSound("rattle1.wav");
+ sounds[5].loadSound("rattle2.wav");
+ sounds[6].loadSound("rattle3.wav");
texture.loadImage("TextureBird.jpg");
@@ -28,7 +37,7 @@ bird::bird()
position=ofVec3f(ofRandom(ofGetWidth()/4,(3*ofGetWidth())/4),ofRandom(ofGetHeight()/4,(3*ofGetHeight())/4),-ofGetHeight()/10);
heading=-90;
direction=ofVec3f(0,-1,0); //director for a heading of 0, level
- velocity=1.0f/30;
+ velocity=1.0f/20;
turnRate=20;
diveRate=0;
@@ -182,7 +191,7 @@ void bird::update(map<int,player>& players, float angle){
//influence direction
turnRate+=playhead[nearnum]*.1;
//check if relatively high
- if (position.z<-ofGetHeight()/40) {
+ if (position.z<-ofGetHeight()/20) {
if (diveRate<2.0f) {
//increase dive rate
diveRate+=0.1f;
@@ -218,7 +227,7 @@ void bird::update(map<int,player>& players, float angle){
if (diveRate<0.5f) {
model.sequences["swoop"].fadeout(0.5);
model.sequences["flap"].start();
- state=SWOOPING;
+ state=SCANNING;
}
break;
case ATTACKING:
@@ -288,7 +297,7 @@ void bird::drawDebug(){
if (DEBUG) {
ofSetHexColor(0xff00ff);
char numStr[100];
- sprintf(numStr, "radius: %4.2f\nheading: %4.2f\nangle: %4.2f\ndive: %4.2f\nheight: %4.2f", centre.distance(ofVec2f(position.x,position.y)),heading,edgeangle,diveRate,position.z);
+ sprintf(numStr, "dive: %4.2f\nheight: %4.2f\n%s", diveRate,position.z,state==1?"SCANNING":state==2?"SWOOPING":"ATTACKING");
ofDrawBitmapString(numStr,10,10);
}
diff --git a/gaunt01/src/bird.h b/gaunt01/src/bird.h
index 29a7a70..967e7bd 100644
--- a/gaunt01/src/bird.h
+++ b/gaunt01/src/bird.h
@@ -108,7 +108,7 @@ class bird
float lastTime;
-
+ ofSoundPlayer* sounds;
ofImage texture;
diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp
index db133c8..2664979 100644
--- a/gaunt01/src/testApp.cpp
+++ b/gaunt01/src/testApp.cpp
@@ -23,7 +23,7 @@ void testApp::setup(){
this->windowWidth = ofGetWidth();
this->windowHeight = ofGetHeight();
}
-
+
mirror=true;
bLearnBakground = true;
@@ -52,12 +52,12 @@ void testApp::setup(){
bgImg.allocate(640,480);
bgImg.setUseTexture(true);
-
+
grayImage.allocate(640,480);
grayBg.allocate(640,480);
*/
-
+
colorImg.allocate(640,480);
colorImg.setUseTexture(true);
currentFrame.allocate(CAM_WIDTH_FG, CAM_HEIGHT_FG);
@@ -67,16 +67,16 @@ void testApp::setup(){
grayFrame.allocate(CAM_WIDTH_FG, CAM_HEIGHT_FG);
grayBg.allocate(CAM_WIDTH_FG, CAM_HEIGHT_FG);
grayDiff.allocate(CAM_WIDTH_FG, CAM_HEIGHT_FG);
-
+
mogoutput.allocate(CAM_WIDTH_FG, CAM_HEIGHT_FG);
learningRate = 0.01f;
bFirstFrame=true;
-
+
diffchannel=chan_V;
hsvback = cvCreateImage(cvGetSize(currentFrame.getCvImage()), currentFrame.getCvImage()->depth, currentFrame.getCvImage()->nChannels);
//backchan = cvCreateImage(cvGetSize(currentFrame.getCvImage()), 8, 1);
-
+
removeShadows=false;
shadowThreshold=10;
////////////////////////////
@@ -128,18 +128,19 @@ void testApp::setup(){
drawingborder=false;
- billboards=new ofImage[4];
+ billboards=new ofImage[5];
billboards[0].loadImage("GUI_title.png");
billboards[1].loadImage("GUI_nzsLogo.png");
billboards[2].loadImage("GUI_objective.png");
billboards[3].loadImage("GUI_gotya.png");
+ billboards[4].loadImage("GUI_instructions.png");
- for (int i=0;i<4;i++) {
+ for (int i=0;i<5;i++) {
billboards[i].setAnchorPercent(0.5,0.5);
}
scaleFactor=ofVec2f(windowWidth/1280.0f,windowHeight/768.0f);
- gameState=TITLES; //PLAYING; //
+ gameState=PLAYING; //TITLES; //
segTimes[TITLES]=4.0;
segTimes[CREDIT]=2.5;
@@ -316,13 +317,13 @@ void testApp::updatePlane(){
else printf("bound plane 4 not found\n");
pn=(p-projector.getGlobalPosition()).getPerpendicular(ofVec3f(-1,0,0));
bounds[3]=ofPlane(p,pn); //,-pn,ofVec2f(1000,1000));
-
+
l=ofVec2f(windowWidth/2,windowHeight/2);
r=projector.castPixel(l.x,l.y);
if (plane.intersect(r,centre)) printf("found centre point at %f,%f,%f\n",centre.x,centre.y,centre.z);
else printf("centre point not found\n");
ofVec3f c=centre.rotated(cam_angle,ofVec3f(-1,0,0));
-
+
Bird.setBounds(bounds);
Bird.setCentre(ofVec2f(c.x,c.y));
@@ -461,11 +462,11 @@ void testApp::update(){
colorImg.setFromPixels(vidPlayer.getPixels(), 640,480);
//accumImg.setFromPixels(vidPlayer.getPixels(), 640,480);
}
-
+
if (mirror) colorImg.mirror(false,true);
colorImg.updateTexture();
-
+
/*
grayImage = colorImg;
@@ -498,42 +499,42 @@ void testApp::update(){
//hard coded size threshold of 100 pix
contourFinder.findContours(grayDiff, 200, (640*480)/3, 20, false); // don't find holes
-
+
*/
-
+
cv::Mat img = colorImg.getCvImage();
-
+
//if (frameno%1==0) { //I THINK THIS APPROACH IS OK to attempt to lower cpu hit from accumulating?
-
+
//cv::Rect roi(0, 0, 32, 32); //doesn't seem that easy to apply the ROI weighted and you still have to convert a whole image each frame?
-
+
//cv::Mat imgroi = img(roi);
-
+
if (bFirstFrame) {
img.convertTo(accumulator, CV_32FC3);
bFirstFrame=false;
}
-
+
cv::Mat im3;
img.convertTo(im3, CV_32FC3);
-
+
//accumulator;
accumulateWeighted(im3, accumulator, max(1.0f/(ofGetElapsedTimef()*30.0f),learningRate));
accumulator.convertTo(outmat,CV_8UC3);
-
+
IplImage* tmp = new IplImage(outmat);
background=tmp;
background.updateTexture();
-
+
//printf("tmp: %ix%i channels: %i depth:%i\n",tmp->width,tmp->height,tmp->nChannels,tmp->depth);
-
-
+
+
//get correct channel into backchan
-
+
vector<cv::Mat> chans;
-
+
//to remove shadows, need hsv of foreground and background
if (diffchannel>chan_B||removeShadows) cvtColor(outmat, hsvback, CV_BGR2HSV);
switch (diffchannel) {
@@ -562,64 +563,64 @@ void testApp::update(){
chans[2].copyTo(backchan);
break;
}
-
+
tmp = new IplImage(backchan);
grayBg = tmp;
-
+
//}
//first, optionally remove shadows from FG
//possibly use 1/4 screen res?
-
+
//to remove shadows, need hsv of foreground and background
if (diffchannel>chan_B||removeShadows) cvtColor(img, hsvfront, CV_BGR2HSV);
-
+
cv::Mat outimg;
-
+
if (removeShadows) {
vector<cv::Mat> slicesFront, slicesBack;
cv::Mat valFront, valBack, satFront, satBack;
-
+
// split image to H,S and V images
split(hsvfront, slicesFront);
split(hsvback, slicesBack);
-
+
slicesFront[2].copyTo(valFront); // get the value channel
slicesFront[1].copyTo(satFront); // get the sat channel
-
+
slicesBack[2].copyTo(valBack); // get the value channel
slicesBack[1].copyTo(satBack); // get the sat channel
-
+
int x,y;
for(x=0; x<currentFrame.getWidth(); ++x) {
for(y=0; y<currentFrame.getHeight(); ++y) {
bool sat = ((satFront.at<cv::Vec3b>(y,x)[0] > satBack.at<cv::Vec3b>(y,x)[0]-shadowThreshold) &&
(satFront.at<cv::Vec3b>(y,x)[0] < satBack.at<cv::Vec3b>(y,x)[0]+shadowThreshold));
-
+
if(sat && (valFront.at<cv::Vec3b>(y,x)[0] < valBack.at<cv::Vec3b>(y,x)[0])) {
- hsvfront.at<cv::Vec3b>(y,x)[0]= hsvback.at<cv::Vec3b>(y,x)[0];
- hsvfront.at<cv::Vec3b>(y,x)[1]= hsvback.at<cv::Vec3b>(y,x)[1];
+ hsvfront.at<cv::Vec3b>(y,x)[0]= hsvback.at<cv::Vec3b>(y,x)[0];
+ hsvfront.at<cv::Vec3b>(y,x)[1]= hsvback.at<cv::Vec3b>(y,x)[1];
hsvfront.at<cv::Vec3b>(y,x)[2]= hsvback.at<cv::Vec3b>(y,x)[2];
}
-
+
}
}
//convert back into RGB if necessary
-
+
if (diffchannel<chan_H) cvtColor(hsvfront, outimg, CV_HSV2BGR);
else outimg=hsvfront;
-
+
}else {
outimg=img;
- }
+ }
+
-
//select correct channel for comparison and put into grayFrame
-
+
//vector<cv::Mat> chans;
split(outimg,chans);
-
+
switch (diffchannel) {
case chan_R:
chans[0].copyTo(frontchan);
@@ -640,14 +641,14 @@ void testApp::update(){
chans[2].copyTo(frontchan);
break;
}
-
+
//IplImage* tmp = new IplImage(outmat);
tmp = new IplImage(frontchan);
grayFrame = tmp;
-
+
grayDiff.clear();
grayDiff.allocate(640,480);
-
+
// take the abs value of the difference between background and incoming and then threshold:
grayDiff.absDiff(grayBg, grayFrame);
grayDiff.threshold(threshold);
@@ -658,14 +659,14 @@ void testApp::update(){
/*
//MOG
mog(img, outmat, mogf);
-
+
// Complement the image
//cv::threshold(outmat, output, threshold, 255, cv::THRESH_BINARY_INV);
IplImage* tmp1 = new IplImage(outmat);
//printf("tmp: %ix%i channels: %i depth:%i\n",tmp->width,tmp->height,tmp->nChannels,tmp->depth);
//printf("grayDiff: %ix%i channels: %i depth:%i\n",grayDiff.getCvImage()->width,grayDiff.getCvImage()->height,grayDiff.getCvImage()->nChannels,grayDiff.getCvImage()->depth);
grayDiff=tmp1; //copy to ofx
-*/
+*/
grayDiff.resize(windowWidth,windowHeight); //wasteful??
@@ -774,7 +775,7 @@ void testApp::draw(){
glDisable(GL_BLEND);
ofPopMatrix();
-
+
glDisable(GL_DEPTH_TEST);
ofSetHexColor(0xffffff);
bindTexture(colorImg); //colorImg.getTextureReference().bind();
@@ -922,7 +923,7 @@ void testApp::draw(){
else ofSetHexColor(0x555555);
ofPushMatrix();
ofRotate(cam_angle,1,0,0);
-
+
ofLine(Bird.position,Bird.playpos[i]);
ofPopMatrix();
@@ -941,7 +942,7 @@ void testApp::draw(){
char numStr[16];
sprintf(numStr, "%i", blobsManager.blobs[i].id);
ofDrawBitmapString(numStr, blob.boundingRect.x, blob.boundingRect.y);
-
+
/*
ofPushMatrix();
ofRotate(cam_angle,1,0,0);
@@ -982,6 +983,12 @@ void testApp::draw(){
*/
}
cam.end();
+ if (drawInstructions) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ billboards[4].draw(windowWidth/2,windowHeight/2);
+ glDisable(GL_BLEND);
+ }
}
//--------------------------------------------------------------
@@ -1001,25 +1008,33 @@ void testApp::keyPressed(int key){
updatePlane();
break;
case 'z':
+ case 'Z':
cam_angle-=1;
updatePlane();
break;
case 'q':
+ case 'Q':
drawStats=!drawStats;
break;
case 'm':
+ case 'M':
mirror=!mirror;
break;
case 's':
+ case 'S':
saveSettings("settings.xml");
break;
+ case 'i':
+ case 'I':
+ drawInstructions=!drawInstructions;
+ break;
case '9':
mode=PLAY;
break;
case '0':
mode=CALIBRATE;
break;
-
+
case '1':
diffchannel = chan_R;
break;
@@ -1038,14 +1053,14 @@ void testApp::keyPressed(int key){
case '6':
diffchannel = chan_V;
break;
-
+
/*
case 's':
removeShadows=!removeShadows;
printf(removeShadows?"removing shadows\n":"not removing shadows\n");
break;
-
-
+
+
case '1':
if (Bird.currentseq!="hover") {
//mesh.sequences["trans_flaphover"].stopAt(0.3);
@@ -1124,7 +1139,7 @@ void testApp::keyPressed(int key){
gameState=(gameState+1)%4;
gameStart=ofGetElapsedTimef();
break;
-
+
*/
}
}
@@ -1164,7 +1179,7 @@ void testApp::windowResized(int w, int h){
}
-//--------------------------------------------------------------
+//-------------------------------------------0-------------------
void testApp::gotMessage(ofMessage msg){
}
diff --git a/gaunt01/src/testApp.h b/gaunt01/src/testApp.h
index 320292b..4fa679e 100644
--- a/gaunt01/src/testApp.h
+++ b/gaunt01/src/testApp.h
@@ -154,6 +154,7 @@ class testApp : public ofBaseApp{
map<int,player> players;
bool drawStats;
+ bool drawInstructions;
bool firstframe; //for background removal
float bgnum;