diff options
| author | Tim Redfern <tim@gray.(none)> | 2012-11-11 00:07:35 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@gray.(none)> | 2012-11-11 00:07:35 +0000 |
| commit | 61fc4a4da64b82fad53f7080ee47181ab2272221 (patch) | |
| tree | bdf373109ddb090987217c25cfa70370d482c73b /tshirtmapping | |
| parent | caace54e8adb8f0ad13303f6f387f3f62e429579 (diff) | |
adding kinect 3d cameras
Diffstat (limited to 'tshirtmapping')
| -rwxr-xr-x | tshirtmapping/src/testApp.cpp | 52 | ||||
| -rwxr-xr-x | tshirtmapping/src/testApp.h | 5 | ||||
| -rwxr-xr-x | tshirtmapping/tshirtmapping.layout | 14 |
3 files changed, 54 insertions, 17 deletions
diff --git a/tshirtmapping/src/testApp.cpp b/tshirtmapping/src/testApp.cpp index 0172617..dd00b8f 100755 --- a/tshirtmapping/src/testApp.cpp +++ b/tshirtmapping/src/testApp.cpp @@ -73,8 +73,8 @@ void testApp::setup(){ recordUser.setUseCloudPoints(draw3D); recordUser.setMaxNumberOfUsers(2); - target.setUseTexture(true); - target.loadImage("target.png"); + texture.setUseTexture(true); + texture.loadImage("target.png"); camRotationY=0; @@ -90,16 +90,48 @@ void testApp::update(){ recordUser.update(); } +void testApp::setCam(){ + + ofNode c=ofNode(); + ofNode t=ofNode(); + t.setParent(c); + t.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal()); + //make target controls relative to rotation + c.rotate(vars[5].getVal(), ofVec3f(0, 1, 0)); + + target.setPosition(t.getGlobalPosition()); + //camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target); + camera.setFov(vars[0].getVal()); + if (vertigo) { + //distance=width/(2 tan (fov *0.5) + //multiply distance by ratio of tans of fov before and after + vars[7].setVal((tan((vars[0].readVal()-vars[0].inc)*PI*0.0027777)*vars[7].readVal())/tan(vars[0].readVal()*PI*0.0027777)); + } + + + + ofVec3f p(0, 0, vars[7].getVal()); + //p.rotate(ofClamp(vars[2].getVal(), -89, 89), ofVec3f(1, 0, 0)); + p.rotate(vars[4].getVal(), ofVec3f(1, 0, 0)); + p.rotate(vars[5].getVal(), ofVec3f(0, 1, 0)); + p += target.getPosition(); + camera.setPosition(p); + + camera.lookAt(target,ofVec3f(0,1,0).rotate(vars[6].getVal(),ofVec3f(0,0,1)).rotate(vars[5].getVal(),ofVec3f(0,1,0))); + light.setPosition(camera.getGlobalPosition()); + +} + //-------------------------------------------------------------- void testApp::draw(){ ofSetColor(255, 255, 255); - if(draw3D) { + if(!draw3D) { //recordDepth.draw(0,0,ofGetWidth(),ofGetHeight()); recordUser.draw(ofGetWidth(),ofGetHeight()); ofSetColor(255,255,255); ofSetLineWidth(5); - bindTexture(target); + bindTexture(texture); ofEnableAlphaBlending(); glPushMatrix(); glScalef(ofGetWidth()/640.0f,ofGetHeight()/480.0f, 1); @@ -150,16 +182,17 @@ void testApp::draw(){ } } glPopMatrix(); - unbindTexture(target); + unbindTexture(texture); } - else { //3D - glPushMatrix(); + else { //3D -- works! + glPushMatrix(); int w = recordUser.getWidth(); int h = recordUser.getHeight(); glTranslatef(w, h/2, -500); ofRotateY(camRotationY); + //camera.begin(); glBegin(GL_POINTS); @@ -180,7 +213,7 @@ void testApp::draw(){ glColor3f(1.0f, 1.0f, 1.0f); - bindTexture(target); + bindTexture(texture); ofEnableAlphaBlending(); glPushMatrix(); //glScalef(ofGetWidth()/640.0f,ofGetHeight()/480.0f, 1); @@ -236,8 +269,9 @@ void testApp::draw(){ } } glPopMatrix(); - unbindTexture(target); + unbindTexture(texture); + //camera.end(); glPopMatrix(); diff --git a/tshirtmapping/src/testApp.h b/tshirtmapping/src/testApp.h index c18b950..9af276a 100755 --- a/tshirtmapping/src/testApp.h +++ b/tshirtmapping/src/testApp.h @@ -37,9 +37,12 @@ class testApp : public ofBaseApp{ int mode; - ofImage target; + ofImage texture; bool draw3D; float camRotationY; + + ofCamera camera; + ofNode target; }; diff --git a/tshirtmapping/tshirtmapping.layout b/tshirtmapping/tshirtmapping.layout index ffdc99c..fa3b053 100755 --- a/tshirtmapping/tshirtmapping.layout +++ b/tshirtmapping/tshirtmapping.layout @@ -4,19 +4,19 @@ <File name="../../openFrameworks/addons/ofxOpenNI/src/ofxUserGenerator.h" open="0" top="0" tabpos="0"> <Cursor position="2398" topLine="66" /> </File> - <File name="Makefile" open="1" top="0" tabpos="4"> + <File name="Makefile" open="0" top="0" tabpos="4"> <Cursor position="20" topLine="0" /> </File> - <File name="addons.make" open="1" top="0" tabpos="5"> + <File name="addons.make" open="0" top="0" tabpos="5"> <Cursor position="0" topLine="0" /> </File> - <File name="config.make" open="1" top="0" tabpos="1"> + <File name="config.make" open="0" top="0" tabpos="1"> <Cursor position="185" topLine="0" /> </File> - <File name="src/testApp.cpp" open="1" top="1" tabpos="3"> - <Cursor position="8925" topLine="80" /> + <File name="src/testApp.cpp" open="1" top="1" tabpos="2"> + <Cursor position="2252" topLine="84" /> </File> - <File name="src/testApp.h" open="1" top="0" tabpos="2"> - <Cursor position="987" topLine="11" /> + <File name="src/testApp.h" open="1" top="0" tabpos="1"> + <Cursor position="987" topLine="7" /> </File> </CodeBlocks_layout_file> |
