Augmented Reality Animal Parade

vimeo.com/39186613

-Tak

 

 

import processing.video.*;
import jp.nyatla.nyar4psg.*;
import saito.objloader.*;

PVector[] test;

OBJModel RingModel;
OBJModel Whalemodel;
OBJModel Duckmodel;
OBJModel ElephantModel;
OBJModel Sharkmodel;
OBJModel Guerillamodel;
OBJModel Penguinmodel;

Capture nativeCam;
Capture PSeyeCam;
MultiMarker nya;

float rotX;
float rotY;
float rotZ;
float spin;

void setup() {
size(640,480,P3D);
colorMode(RGB, 100);
//nativeCam=new Capture(this,640,480);
PSeyeCam=new Capture(this,640,480, "Sony HD Eye for PS3 (SLEH 00201)", 30);
nya=new MultiMarker(this,width,height,"camera_para.dat",NyAR4PsgConfig.CONFIG_PSG);
nya.addARMarker("patt.hiro",80);//id=0
nya.addARMarker("patt.kanji",80);//id=1
nya.addNyIdMarker(0,80);//id=2
nya.addNyIdMarker(1,80);//id=3

RingModel = new OBJModel(this);
Whalemodel = new OBJModel(this);
Duckmodel = new OBJModel(this);
ElephantModel = new OBJModel(this);
Sharkmodel = new OBJModel(this);
Guerillamodel = new OBJModel(this);
Penguinmodel = new OBJModel(this);

RingModel.enableDebug();
Whalemodel.enableDebug();
Duckmodel.enableDebug();
ElephantModel.enableDebug();
Sharkmodel.enableDebug();
Guerillamodel.enableDebug();
Penguinmodel.enableDebug();

RingModel.load("StoneRing.obj");
Whalemodel.load("Whale.obj");
Duckmodel.load("Duck.obj");
ElephantModel.load("elephant.obj");
Sharkmodel.load("shark.obj");
Guerillamodel.load("guerilla2.obj");
Penguinmodel.load("penguin.obj");

}

void draw() {
//*****Augmented Reality*****//
if (PSeyeCam.available() !=true) {
return;
}
PSeyeCam.read();
nya.detect(PSeyeCam);
background(0);
noFill();
lights();
noStroke();
nya.drawBackground(PSeyeCam);//frustumを考慮した背景描画
PMatrix3D ARX = new PMatrix3D();
for(int i=0;i<4;i++){
if((!nya.isExistMarker(i))){
continue;
}
if(i == 0) {
/*
ARX=nya.getMarkerMatrix(i);
test = new PVector[4];
test = nya.getMarkerVertex2D(i);
println(test);
*/

nya.beginTransform(i);
//fill(100*(((i+1)/4)%2),100*(((i+1)/2)%2),100*(((i+1))%2));
translate(-30,0,20);

scale(40.0);

rotateX(rotY+degrees(0.08125));
rotateY (rotX+degrees(spin));

//RingModel.draw();
//Whalemodel.draw();
//ElephantModel.draw();
Sharkmodel.draw();
// box(1);

//println(x.nya);
nya.endTransform();
}

if(i ==1){
nya.beginTransform(i);
//fill(100*(((i+1)/4)%2),100*(((i+1)/2)%2),100*(((i+1))%2));
translate(-30,0,20);
scale(60.0);
spin = spin + 0.0005;
rotateX(rotY+degrees(0.08125));
rotateY(rotX+degrees(0));

//Duckmodel.draw();
//Guerillamodel.draw();
Penguinmodel.draw();

//box(1);
nya.endTransform();
}

//^^^^^Augmented Reality^^^^^//

}
}

void mouseDragged()
{
rotX += (mouseX - pmouseX) * 0.01;
rotY -= (mouseY - pmouseY) * 0.01;
}

Comments are closed.