We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
how do i change the spheres into 3d models?
I have an example that works but when I copy the files and lines it doesn't work in my project.
this is where I am at the moment -->
. . . . . .
// we want to use the gsvideo camera support stack
import codeanticode.gsvideo.*;
// multiple marker tracking
import jp.nyatla.nyar4psg.*;
// only necessary if you're using the OPENGL renderer (see the size() call in setup())
import processing.opengl.*;
// import obj
import saito.objloader.*;
import javax.media.opengl.*;
//activeerd GSCapture
GSCapture cam;
//activeerd ar
NyARMultiBoard nya;
//importeerd het model
OBJModel model ;
float rot = 0.0;
// importeerd 2 soorten fonts.
PFont font, font2d;
//fullscreen shizzle
import fullscreen.*;
FullScreen fs;
void setup() {
// our display is 640x480
size(640,480,P3D);
// the same size as the display, which should be 640x480
// Dit is alleen voor p3d. want hij gaat nu naar fullscreen mode
fs = new FullScreen(this);
// enter fullscreen mode
fs.enter();
//maakt de fonts aan.
colorMode(RGB, 100);
background(20);
font=createFont("FFScala", 32);
font2d = createFont("FFScala", 10);
//start de webcam
cam=new GSCapture(this,width,height);
cam.start();
//PATRONEN:
// array of pattern file names, these have to be in the data subdir of this sketch
// patt.hiro =string0 patt.kanji=string1 etc etc.
String[] patts = {"patt.hiro", "patt.kanji"};
// array of corresponding widths in mm
double[] widths = {80,80};
// initialise the NyARMultiBoard
// the camera parameter file is also in the data subdir
nya=new NyARMultiBoard(this,width,height,"camera_para.dat",patts,widths);
print(nya.VERSION);
// marker detection algorithm parameter
nya.gsThreshold=110;//(0<n<255) default=110
// a marker has to be detected with a confidence greater than
// this threshold for it to be considered a true detection
nya.cfThreshold=0.2;//(0.0<n<1.0) default=0.4
}
// draw marker corners and also position in text
void drawMarkerPos(int[][] pos2d)
{
textFont(font,10.0);
stroke(100,0,0);
fill(100,0,0);
// draw ellipses at outside corners of marker
for(int i=0;i<4;i++){
ellipse(pos2d[i][0], pos2d[i][1],5,5);
}
fill(0,0,0);
for(int i=0;i<4;i++){
text("("+pos2d[i][0]+","+pos2d[i][1]+")",pos2d[i][0],pos2d[i][1]);
}
}
// standard processing event handler that's called for display updates
void draw() {
// we only do something when the camera input is avail able
if (cam.available() !=true) {
return;
}
// get an image from the camera
cam.read();
// need to put camera image on screen, so temporarily disable depth testing
hint(DISABLE_DEPTH_TEST);
// put webcam image on screen
image(cam,0,0);
hint(ENABLE_DEPTH_TEST);
// if *any* markers have been detected this will be true
if (nya.detect(cam))
{
// going to be doing 2D drawing (drawMarkerPos) so temporarily disable depth testing
hint(DISABLE_DEPTH_TEST);
// for all detected markers, draw corner points
for (int i=0; i < nya.markers.length; i++)
{
if (nya.markers[i].detected)
{
drawMarkerPos(nya.markers[i].pos2d);
}
}
// depth test back on, we're going to draw 3D YEAH!!
hint(ENABLE_DEPTH_TEST);
// for all detected markers:
for (int i=0; i < nya.markers.length; i++)
{
if (nya.markers[i].detected)
{
// set the model-view transform to that of the marker
// this will adapt automatically to P3D or OPENGL renderers
nya.markers[i].beginTransform();
translate(5,5,0);
// 5 pixels naar rechts en 5 pixels naar boven. dit bepaald de locatie.
// van ALLE afbeeldingen.
// ALs het eem hiro marker is(want case is 0), draw a 3D sphere van 40
switch(i) {
case 0:
stroke(255,100,0);
sphere(40);
break;
// als het een kanji marker is (want case is 1) draw a sphere van 10
case 1:
stroke(5,200,255);
sphere(10);
break;
default:
println("maak een case aan");
break;
}
// after drawing marker-relative 3D geometry, we
// HAVE to end the transform (so now we're back in
// world space)
nya.markers[i].endTransform();
}
}
} else { //geen markers gevonden. } }
Answers
and this is the example. this uses the singlemarker and i want to use the multi marker.