NyARToolkitV4 for Android pre-release version.
Android2.2(API8)向けに構成してあります。簡易スケッチを搭載しているので、以前より容易にプログラムを作ることが出来ます。
既知の不具合として、Stopを伴わないResumeイベントが発生した場合に、プログラムが強制終了します。
リビジョン | f4e4b66048b14101effd4a3e5b8e9f225c9a5e48 (tree) |
---|---|
日時 | 2012-05-27 02:10:55 |
作者 | nyatla <nyatla@user...> |
コミッター | nyatla |
add Markerplane.
@@ -14,6 +14,12 @@ import android.hardware.Camera; | ||
14 | 14 | import android.view.ViewGroup.LayoutParams; |
15 | 15 | import android.widget.FrameLayout; |
16 | 16 | |
17 | +/** | |
18 | + * Hiroマーカ平面から画像を取得します。 | |
19 | + * 画像取得APIは低速です。解像度の高いものは避けてください。 | |
20 | + * 撮影画面全体のキャプチャをするときは、CameraPreviewから直接画像を得た方が良いです。 | |
21 | + * | |
22 | + */ | |
17 | 23 | public class ImagePickupActivity extends AndSketch implements AndGLView.IGLFunctionEvent |
18 | 24 | { |
19 | 25 | CameraPreview _camera_preview; |
@@ -8,12 +8,18 @@ import jp.androidgroup.nyartoolkit.markersystem.NyARAndSensor; | ||
8 | 8 | import jp.androidgroup.nyartoolkit.sketch.AndSketch; |
9 | 9 | import jp.androidgroup.nyartoolkit.utils.camera.CameraPreview; |
10 | 10 | import jp.androidgroup.nyartoolkit.utils.gl.*; |
11 | +import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint3d; | |
11 | 12 | import jp.nyatla.nyartoolkit.markersystem.NyARMarkerSystemConfig; |
12 | 13 | import android.content.res.AssetManager; |
13 | 14 | import android.hardware.Camera; |
15 | +import android.view.MotionEvent; | |
14 | 16 | import android.view.ViewGroup.LayoutParams; |
15 | 17 | import android.widget.FrameLayout; |
16 | 18 | |
19 | +/** | |
20 | + * Hiroマーカの表面を移動する立方体を表示します。 | |
21 | + * マーカを撮影しながら画面をタッチして下さい。 | |
22 | + */ | |
17 | 23 | public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunctionEvent |
18 | 24 | { |
19 | 25 | CameraPreview _camera_preview; |
@@ -47,7 +53,7 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct | ||
47 | 53 | NyARAndMarkerSystem _ms; |
48 | 54 | private int _mid; |
49 | 55 | AndGLFpsLabel fps; |
50 | - AndGLBitmapSprite _bmp; | |
56 | + AndGLBox box; | |
51 | 57 | AndGLDebugDump _debug=null; |
52 | 58 | AndGLTextLabel text; |
53 | 59 | public void setupGL(GL10 gl) |
@@ -66,9 +72,9 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct | ||
66 | 72 | gl.glLoadMatrixf(this._ms.getGlProjectionMatrix(),0); |
67 | 73 | this.fps=new AndGLFpsLabel(this._glv,"MarkerPlaneActivity"); |
68 | 74 | this.fps.prefix=this._cap_size.width+"x"+this._cap_size.height+":"; |
69 | - this._bmp=new AndGLBitmapSprite(this._glv,64,64); | |
70 | 75 | this._debug=new AndGLDebugDump(this._glv); |
71 | 76 | this.text=new AndGLTextLabel(this._glv); |
77 | + this.box=new AndGLBox(this._glv,40); | |
72 | 78 | |
73 | 79 | } catch (Exception e) { |
74 | 80 | // TODO Auto-generated catch block |
@@ -96,9 +102,11 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct | ||
96 | 102 | this._ms.update(this._ss); |
97 | 103 | if(this._ms.isExistMarker(this._mid)){ |
98 | 104 | this.text.draw("found"+this._ms.getConfidence(this._mid),0,16); |
99 | - this._ms.getMarkerPlaneImage(this._mid,this._ss,-40,-40,80,80,this._bmp.lockBitmap()); | |
100 | - this._bmp.unlockBitmap(); | |
101 | - this._bmp.draw(0,50); | |
105 | + NyARDoublePoint3d p=new NyARDoublePoint3d(); | |
106 | + this._ms.getMarkerPlanePos(this._mid,tx,ty,p); | |
107 | + gl.glMatrixMode(GL10.GL_MODELVIEW); | |
108 | + gl.glLoadMatrixf(this._ms.getGlMarkerMatrix(this._mid),0); | |
109 | + this.box.draw((float)p.x,(float)p.y,(float)p.z+20); | |
102 | 110 | } |
103 | 111 | } |
104 | 112 | }catch(Exception e) |
@@ -106,5 +114,17 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct | ||
106 | 114 | ex=e; |
107 | 115 | } |
108 | 116 | } |
117 | + private int tx=0; | |
118 | + private int ty=0; | |
119 | + public boolean onTouchEvent(MotionEvent event) | |
120 | + { | |
121 | + //画面サイズ→OpenGLサイズへの変換 | |
122 | + int h = this.getWindowManager().getDefaultDisplay().getHeight(); | |
123 | + int w = this.getWindowManager().getDefaultDisplay().getWidth(); | |
124 | + | |
125 | + tx = (int)(event.getX()*this._cap_size.width/w); | |
126 | + ty = (int)(event.getY()*this._cap_size.height/h); | |
127 | + return true; | |
128 | + } | |
109 | 129 | Exception ex=null; |
110 | 130 | } |
@@ -14,6 +14,11 @@ import android.hardware.Camera; | ||
14 | 14 | import android.view.ViewGroup.LayoutParams; |
15 | 15 | import android.widget.FrameLayout; |
16 | 16 | |
17 | +/** | |
18 | + * Hiroマーカの上にカラーキューブを表示します。 | |
19 | + * 定番のサンプルです。 | |
20 | + * | |
21 | + */ | |
17 | 22 | public class SimpleLiteActivity extends AndSketch implements AndGLView.IGLFunctionEvent |
18 | 23 | { |
19 | 24 | CameraPreview _camera_preview; |