summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-03-21 20:48:21 +0000
committerTim Redfern <tim@eclectronics.org>2012-03-21 20:48:21 +0000
commit3d5588a7ead64f3b11ef132f21469b9471819850 (patch)
tree292c98a38e4979b662d217d5325e11112a57a161
parentbba06c387bb44c46bf035bf6b68558dd34833879 (diff)
misc
-rw-r--r--bin/data/settings.xml36
-rw-r--r--src/mapUtils.cpp29
-rw-r--r--src/mapUtils.h2
-rw-r--r--src/testApp.cpp40
-rw-r--r--src/testApp.h13
5 files changed, 102 insertions, 18 deletions
diff --git a/bin/data/settings.xml b/bin/data/settings.xml
index b475f2d..893a793 100644
--- a/bin/data/settings.xml
+++ b/bin/data/settings.xml
@@ -1,27 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<map4 model="bottle-strongbow-lid.3DS" x="0" y="117" z="0">
<view>
- <settings x="0.000000" y="0.000000" w="0.500000" h="1.000000" distort="0.000000" fov="17.250000" roll="90.000000" targX="0.000000" targY="112.000000" targZ="0.000000" lat="24.353056" lng="-52.803280" dolly="737.189148" />
+ <settings x="0.000000" y="0.000000" w="0.500000" h="1.000000" distort="0.000000" fov="17.25" roll="90.0" targX="0" targY="100.0" targZ="0.0" lat="6.219387" lng="-74.018013" dolly="600.0" />
</view>
<view>
- <settings x="0.500000" y="0.000000" w="0.500000" h="1.000000" distort="0.000000" fov="17.250000" roll="90.000000" targX="0.000000" targY="112.000000" targZ="0.000000" lat="30.002064" lng="47.074490" dolly="723.159424" />
+ <settings x="0.500000" y="0.000000" w="0.500000" h="1.000000" distort="0.000000" fov="17.25" roll="90.0" targX="0" targY="100.0" targZ="0.0" lat="10.471071" lng="32.265820" dolly="600.0" />
</view>
<clip>
- <settings file="strongbow/texture_lit.mov" />
+ <settings file="strongbow/Still_image.mov" />
</clip>
- <clip>
+ <clip>
<settings file="strongbow/archer_bottle.mov" />
</clip>
-<clip>
- <settings file="strongbow/gold_bars.mov" />
+ <clip>
+ <settings file="strongbow/ad_inside_bottle.mov" />
</clip>
-<clip>
- <settings file="strongbow/gold_squares.mov" />
+ <clip>
+ <settings file="strongbow/golden_lights_inside_bottle.mov" />
</clip>
-<clip>
- <settings file="strongbow/logo_rotate_shatter.mov" />
+ <clip>
+ <settings file="strongbow/gold_blocks_inside_bottle.mov" />
</clip>
-<clip>
- <settings file="strongbow/balls_in_a_can_loop.mov" />
+ <clip>
+ <settings file="strongbow/timelapse_inside_bottle.mov" />
+ </clip>
+ <clip>
+ <settings file="strongbow/bars_inside_bottle.mov" />
+ </clip>
+ <clip>
+ <settings file="strongbow/balls_inside_bottle.mov" />
+ </clip>
+ <clip>
+ <settings file="strongbow/archer final.mov" />
+ </clip>
+ <clip>
+ <settings file="strongbow/logo_rotate_new.mov" />
</clip>
</map4>
diff --git a/src/mapUtils.cpp b/src/mapUtils.cpp
index 3787bf4..3dd3d7c 100644
--- a/src/mapUtils.cpp
+++ b/src/mapUtils.cpp
@@ -33,6 +33,29 @@ void unbindTexture(ofBaseHasTexture &t) {
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}
+void bindTex(ofTexture &tex) {
+ tex.bind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+
+ ofTextureData texData = tex.getTextureData();
+ if(texData.textureTarget == GL_TEXTURE_RECTANGLE_ARB) {
+ glScalef(tex.getWidth(), tex.getHeight(), 1.0f);
+ } else {
+ glScalef(tex.getWidth() / texData.tex_w, tex.getHeight() / texData.tex_h, 1.0f);
+ }
+
+ glMatrixMode(GL_MODELVIEW);
+}
+void unbindTex(ofTexture &tex) {
+ tex.unbind();
+
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+}
ofPoint distort(ofPoint pt,float d){
//normalised coords -1..1, d
float r=pow(pow(pow(pt.x,2.0f)+pow(pt.y,2.0f),0.5f),1.0f+d);
@@ -89,17 +112,17 @@ void drawBoard(float x,float y,float z) {
glVertex3f(cx+8, 0, cz+8);
glVertex3f(cx+4, 0, cz+4);
glVertex3f(cx+4, 0, cz-4);
-
+
glVertex3f(cx+4, 0, cz+4);
glVertex3f(cx+8, 0, cz+8);
glVertex3f(cx-8, 0, cz+8);
glVertex3f(cx-4, 0, cz+4);
-
+
glVertex3f(cx-4, 0, cz-4);
glVertex3f(cx-4, 0, cz+4);
glVertex3f(cx-8, 0, cz+8);
glVertex3f(cx-8, 0, cz-8);
-
+
glVertex3f(cx+8, 0, cz-8);
glVertex3f(cx+4, 0, cz-4);
glVertex3f(cx-4, 0, cz-4);
diff --git a/src/mapUtils.h b/src/mapUtils.h
index 97af934..4c56b2d 100644
--- a/src/mapUtils.h
+++ b/src/mapUtils.h
@@ -11,6 +11,8 @@
void bindTexture(ofBaseHasTexture &t);
void unbindTexture(ofBaseHasTexture &t);
+void bindTex(ofTexture &tex);
+void unbindTex(ofTexture &tex);
ofPoint distort(ofPoint pt,float d);
void drawBox(float size);
void drawBoard(float x,float y,float z);
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 0e6e0d5..81b77e2 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -41,11 +41,41 @@ void testApp::setup(){
light=true;
+ camWidth = 320; // try to grab at this size.
+ camHeight = 240;
+
+ vidGrabber.setVerbose(true);
+ vidGrabber.listDevices();
+
+
+ vidGrabber.setDeviceID(0);
+ vidGrabber.initGrabber(camWidth,camHeight);
+ //printf("asked for 320 by 240 - actual size is %i by %i\n", vidGrabber.width, vidGrabber.height);
+
+ videoInverted = new unsigned char[camWidth*camHeight*3];
+ videoTexture.allocate(camWidth,camHeight, GL_RGB);
+
}
//--------------------------------------------------------------
void testApp::update(){
texture.idleMovie();
+
+ if (mode==GRAB) {
+ vidGrabber.grabFrame();
+
+ if (vidGrabber.isFrameNew()){
+ int totalPixels = camWidth*camHeight*3;
+ unsigned char * pixels = vidGrabber.getPixels();
+ for (int i = 0; i < totalPixels; i+=3){
+ unsigned int bright= (pixels[i]>>2)+ (pixels[i+1]>>1)+(pixels[i+1]>>2); //(0.2126*R) + (0.7152*G) + (0.0722*B)
+ videoInverted[i] = (unsigned char)((226*bright)>>8);
+ videoInverted[i+1] = (unsigned char)((200*bright)>>8);
+ videoInverted[i+2] = (unsigned char)((20*bright)>>8);
+ }
+ videoTexture.loadData(videoInverted, camWidth,camHeight, GL_RGB);
+ }
+ }
}
//--------------------------------------------------------------
@@ -75,6 +105,14 @@ void testApp::draw(){
ofPopMatrix();
unbindTexture(texture);
break;
+ case GRAB:
+ bindTex(videoTexture);
+ ofPushMatrix();
+ ofRotate(90,0,1,0);
+ model.draw();
+ ofPopMatrix();
+ unbindTex(videoTexture);
+ break;
case NOTHING:
bindTexture(texture);
glPushMatrix();
@@ -103,7 +141,7 @@ void testApp::keyPressed(int key){
mode=DISPLAY;
break;
case '0':
- mode=NOTHING;
+ mode=GRAB;
break;
case '1':
activeView=-1;
diff --git a/src/testApp.h b/src/testApp.h
index 24bcbe9..32dae89 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -22,7 +22,9 @@ have to track how many frames each key has been pressed for
#define CALIBRATE 1
#define DISPLAY 2
-#define NOTHING 3
+#define GRAB 3
+#define NOTHING 4
+
#include "ofMain.h"
#include "ofxXmlSettings.h"
@@ -72,5 +74,12 @@ class testApp : public ofBaseApp{
ofxXmlSettings XML;
bool light;
-
+
+ ofVideoGrabber vidGrabber;
+
+ unsigned char * videoInverted;
+ ofTexture videoTexture;
+ int camWidth;
+ int camHeight;
+
};