diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-04-06 00:00:16 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-04-06 00:00:16 +0100 |
| commit | adc1fe0182495151eba174f7ab5b99a900e10b5e (patch) | |
| tree | 2b7baf06b652f8191d999ce10c1a1fb1ac1137c4 /gaunt01/src | |
| parent | 13efc34b839db4f16fcfb4ea0aa3f768f144cd65 (diff) | |
changed morphmesh to use associative keys for targets
Diffstat (limited to 'gaunt01/src')
| -rw-r--r-- | gaunt01/src/bird.cpp | 5 | ||||
| -rw-r--r-- | gaunt01/src/morphmesh.cpp | 12 | ||||
| -rw-r--r-- | gaunt01/src/morphmesh.h | 20 |
3 files changed, 29 insertions, 8 deletions
diff --git a/gaunt01/src/bird.cpp b/gaunt01/src/bird.cpp index 204bf6e..388d7af 100644 --- a/gaunt01/src/bird.cpp +++ b/gaunt01/src/bird.cpp @@ -29,14 +29,17 @@ void bird::update(const vector<ofVec3f>& players){ position+=direction*velocity*timeSeg; } void bird::draw(){ + glEnable(GL_DEPTH_TEST); ofPushMatrix(); ofTranslate(position); //ofRotate(direction); - ofRotate(90,0,-1,0); + 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); } diff --git a/gaunt01/src/morphmesh.cpp b/gaunt01/src/morphmesh.cpp index 475f93b..5fc7182 100644 --- a/gaunt01/src/morphmesh.cpp +++ b/gaunt01/src/morphmesh.cpp @@ -24,10 +24,12 @@ void morphmesh::draw() { } void morphmesh::draw(int target){ clearVertices(); - addVertices(morphs[target]); + map<string,vector<ofVec3f> >::iterator it=morphs.begin(); + for ( int i=0;i<target;i++ ) it++; + addVertices(it->second); ofMesh::draw(); } -void morphmesh::draw(const vector<int>& targets, const vector<float>& weights){ +void morphmesh::draw(const vector<string>& targets, const vector<float>& weights){ clearVertices(); //normalise weights int targetsNum=min(targets.size(),morphs.size()); @@ -35,7 +37,7 @@ void morphmesh::draw(const vector<int>& targets, const vector<float>& weights){ for (int i=0;i<targetsNum;i++) totalWeights+=weights[i]; float weightFactor=1.0/totalWeights; float bx,by,bz; - for (int j=0;j<morphs[0].size();j++) { + for (int j=0;j<morphs[targets[0]].size();j++) { bx=by=bz=0; for (int i=0;i<targetsNum;i++) { bx+=morphs[targets[i]][j].x*weights[i]; @@ -56,6 +58,8 @@ bool morphmesh::loadMesh(string filename){ if(XML.pushTag("Oak3DModelDocument")) { if(XML.pushTag("MeshList")) { int numMeshes=XML.getNumTags("Mesh"); + vector<string> meshnames; + for (int i=0;i<numMeshes;i++) meshnames.push_back(XML.getAttribute("Mesh","Name","none",i)); for (int i=0;i<numMeshes;i++) { XML.pushTag("Mesh",i); if (XML.pushTag("AttributeList")) { @@ -69,7 +73,7 @@ bool morphmesh::loadMesh(string filename){ for (int j=0;j<vstrings.size();j+=3) { verts.push_back(ofVec3f(ofToFloat(vstrings[j]),ofToFloat(vstrings[j+1]),ofToFloat(vstrings[j+2]))); } - morphs.push_back(verts); + morphs[meshnames[i]]=verts; if (i==0) { addVertices(verts); diff --git a/gaunt01/src/morphmesh.h b/gaunt01/src/morphmesh.h index 76a6063..ca1231c 100644 --- a/gaunt01/src/morphmesh.h +++ b/gaunt01/src/morphmesh.h @@ -18,6 +18,21 @@ Multiple meshes are loaded as morph targets Coords are absolute + +--managing movement sequences +--cycles can refer to targets by name +--high level controller objects can refer to animation sequences by name +--this makes it impossible for a re-odering to banjax everything + +cycles have a start time, and they either loop or act as a transition + +Working out the morphs is a question of: +-working out which cycles are active based on behaviours +-adding their morph targets into the current vector of targets + +behaviours are triggered by things like spotting people or avoiding the wall. +These could be parameterised on top of the rest? + */ @@ -31,7 +46,6 @@ class sequence }; - class morphmesh : public ofMesh { public: @@ -42,11 +56,11 @@ class morphmesh : public ofMesh bool isLoaded(); void draw(); void draw(int target); - void draw(const vector<int>& targets, const vector<float>& weights); + void draw(const vector<string>& targets, const vector<float>& weights); int getNumTargets(); protected: private: - vector< vector<ofVec3f> > morphs; + map< string,vector<ofVec3f> > morphs; bool loaded; }; |
