summaryrefslogtreecommitdiff
path: root/gaunt01/src/bird.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gaunt01/src/bird.cpp')
-rw-r--r--gaunt01/src/bird.cpp66
1 files changed, 37 insertions, 29 deletions
diff --git a/gaunt01/src/bird.cpp b/gaunt01/src/bird.cpp
index 9418b65..0a17563 100644
--- a/gaunt01/src/bird.cpp
+++ b/gaunt01/src/bird.cpp
@@ -11,19 +11,27 @@ finally drawAnimated()
bird::bird()
{
- model.loadMesh("Bird-test.xml");
- texture.loadImage("TextureBird.jpg");
-
- //starting pos
- position=ofVec3f(ofGetWidth()/2,ofGetHeight()/3,ofGetHeight()/2);
- heading=ofVec3f(-1,0,0);
- direction=ofVec3f(-1,0,0);
- velocity=ofGetWidth()/100;
-
- turnAngle=0;
- diveAngle=0;
-
- lastTime=ofGetElapsedTimef();
+ if (model.loadMesh("Bird-poses.xml")) printf("mesh loaded with %i vertices, %i face indices, %i targets\n",model.getNumVertices(),model.getNumIndices(),model.getNumTargets());
+ else printf("mesh XML file not parsed\n");
+
+ if (model.loadSeqs("Bird-anim.xml")) printf("animation loaded with %i sequences\n",model.getNumSequences());
+ else printf("animation XML file not parsed\n");
+
+ model.sequences["flap"].start();
+ currentseq="hover";
+
+ texture.loadImage("TextureBird.jpg");
+
+ //starting pos
+ position=ofVec3f(ofGetWidth()/2,ofGetHeight(),-100); //ofGetHeight()/4);
+ heading=ofVec3f(-1,0,0);
+ direction=ofVec3f(-1,0,0);
+ velocity=ofGetWidth()/50;
+
+ turnAngle=-1;
+ diveAngle=0;
+
+ lastTime=ofGetElapsedTimef();
}
bird::~bird()
@@ -32,23 +40,23 @@ bird::~bird()
}
void bird::update(const vector<ofVec3f>& players){
- float time=ofGetElapsedTimef();
- float timeSeg=time-lastTime;
- lastTime=time;
- position+=direction*velocity*timeSeg;
+ float time=ofGetElapsedTimef();
+ float timeSeg=time-lastTime;
+ lastTime=time;
+ position+=direction*velocity*timeSeg;
}
void bird::draw(){
- glEnable(GL_DEPTH_TEST);
- ofPushMatrix();
- ofTranslate(position);
- //ofRotate(direction);
- ofRotate(90,0,0,1);
- ofRotate(90,-1,0,0);
- //ofRotate(180,1,0,0);
- bindTexture(texture);
- model.draw();
- unbindTexture(texture);
- ofPopMatrix();
- glDisable(GL_DEPTH_TEST);
+ glEnable(GL_DEPTH_TEST);
+ ofPushMatrix();
+ ofTranslate(position);
+ //ofRotate(direction);
+ ofRotate(90,0,0,1);
+ ofRotate(90,-1,0,0);
+ ofScale(.15,.15,.15);
+ bindTexture(texture);
+ model.drawAnimated();
+ unbindTexture(texture);
+ ofPopMatrix();
+ glDisable(GL_DEPTH_TEST);
}