summaryrefslogtreecommitdiff
path: root/tshirtmapping/src
diff options
context:
space:
mode:
Diffstat (limited to 'tshirtmapping/src')
-rwxr-xr-xtshirtmapping/src/testApp.cpp52
-rwxr-xr-xtshirtmapping/src/testApp.h5
2 files changed, 47 insertions, 10 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;
};