Develop and Download Open Source Software

Browse Subversion Repository

Contents of /nyar4psg/trunk/examples/withPicking/withPicking.pde

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1158 - (show annotations) (download)
Tue Jan 6 07:38:11 2015 UTC (9 years, 4 months ago) by nyatla
File size: 1659 byte(s)
パッケージ構成をProcessing2.0向けに更新

1 /**
2 NyARToolkit for proce55ing/1.0.0
3 (c)2008-2011 nyatla
4 airmail(at)ebony.plala.or.jp
5
6 Pickingと一緒に使うサンプルです。
7 Picking Libraryはこちらからダウンロードしてください。
8 http://code.google.com/p/processing-picking-library/
9 Picking Libraryは version 0.1.5で動作を確認しています。
10 0.1.6ではうまく動作しません。
11 ----
12 This sample program is sample with picking library.
13 The cube can be clicked.
14 The marker file is "patt.hiro".
15 Download picking library from http://code.google.com/p/processing-picking-library/
16 Should use version 0.1.5. Version 0.1.6 may does not work.
17
18 */
19 import processing.video.*;
20 import jp.nyatla.nyar4psg.*;
21 import processing.opengl.*;
22 import picking.*;
23
24 Capture cam;
25 MultiMarker nya;
26 int cr,cg,cb;
27 Picker picker;
28
29 void setup() {
30 println(MultiMarker.VERSION);
31 size(640,480,P3D);
32 colorMode(RGB, 100);
33 nya=new MultiMarker(this,width,height,"camera_para.dat",NyAR4PsgConfig.CONFIG_PSG);
34 nya.addARMarker("patt.hiro",80);//id=0
35 picker = new Picker(this);
36 cam=new Capture(this,640,480);
37 cr=cg=cb=100;
38 cam.start();
39 }
40
41 int c=0;
42 void draw()
43 {
44 c++;
45 if (cam.available() !=true) {
46 return;
47 }
48 cam.read();
49 nya.detect(cam);
50 hint(DISABLE_DEPTH_TEST);
51 image(cam,0,0);
52 hint(ENABLE_DEPTH_TEST);
53 if(!nya.isExistMarker(0)){
54 return;
55 }
56 picker.start(0);
57 nya.beginTransform(0);
58 fill(cr,cg,cb);
59 translate(0,0,20);
60 box(40);
61 nya.endTransform();
62 }
63
64 void mouseClicked() {
65 int id = picker.get(mouseX, mouseY);
66 if (id ==0) {
67 cr=int(random(0,100));
68 cg=int(random(0,100));
69 cb=int(random(0,100));
70 }
71 }
72
73

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26