Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /nyar4psg/trunk/examples/rotation/rotation.pde

Parent Directory Parent Directory | Revision Log Revision Log


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

1 nyatla 1158 /**
2     NyARToolkit for proce55ing/1.0.0
3     (c)2008-2011 nyatla
4     airmail(at)ebony.plala.or.jp
5    
6     人マーカの上に右手系、Hiroマーカの上に左手系の立方体を表示します。
7    
8     This sample program shows rotation of 2 coordinate system.(left and right).
9     The marker is "patt.hiro" and "patt.kanji"
10     */
11    
12     import processing.video.*;
13     import jp.nyatla.nyar4psg.*;
14    
15     Capture cam;
16     MultiMarker nya_r;
17     MultiMarker nya_l;
18     PFont font=createFont("FFScala", 32);
19    
20     void setup() {
21     size(640,480,P3D);
22     colorMode(RGB, 100);
23     println(MultiMarker.VERSION);
24    
25     //キャプチャを作成
26     cam=new Capture(this,640,480);
27     nya_l=new MultiMarker(this,width,height,"camera_para.dat",new NyAR4PsgConfig(NyAR4PsgConfig.CS_LEFT_HAND,NyAR4PsgConfig.TM_NYARTK));
28     nya_l.addARMarker("patt.hiro",80);
29    
30     nya_r=new MultiMarker(this,width,height,"camera_para.dat",new NyAR4PsgConfig(NyAR4PsgConfig.CS_RIGHT_HAND,NyAR4PsgConfig.TM_NYARTK));
31     nya_r.addARMarker("patt.kanji",80);
32     cam.start();
33     }
34    
35     int c=0;
36     void drawgrid()
37     {
38     pushMatrix();
39     stroke(0);
40     strokeWeight(2);
41     line(0,0,0,100,0,0);
42     textFont(font,20.0); text("X",100,0,0);
43     line(0,0,0,0,100,0);
44     textFont(font,20.0); text("Y",0,100,0);
45     line(0,0,0,0,0,100);
46     textFont(font,20.0); text("Z",0,0,100);
47     popMatrix();
48     }
49     void draw()
50     {
51     c++;
52     if (cam.available() !=true) {
53     return;
54     }
55     cam.read();
56     nya_r.detect(cam);
57     nya_l.detect(cam);
58     background(0);
59     nya_r.drawBackground(cam);//frustumを考慮した背景描画
60    
61     //right
62     if((nya_r.isExistMarker(0))){
63     nya_r.beginTransform(0);
64     fill(0,0,255);
65     drawgrid();
66     translate(0,0,20);
67     rotate((float)c/100);
68     box(40);
69     nya_r.endTransform();
70     }
71     //left
72     if((nya_l.isExistMarker(0))){
73     nya_l.beginTransform(0);
74     fill(0,255,0);
75     drawgrid();
76     translate(0,0,20);
77     rotate((float)c/100);
78     box(40);
79     nya_l.endTransform();
80     }
81     }
82    
83    
84    
85    

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