• R/O
  • HTTP
  • SSH
  • HTTPS

NyARTK4.nyatla: コミット

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.

変更サマリ

差分

--- a/sample/ImagePickup/src/jp/nyatla/nyartoolkit/and/ImagePickupActivity.java
+++ b/sample/ImagePickup/src/jp/nyatla/nyartoolkit/and/ImagePickupActivity.java
@@ -14,6 +14,12 @@ import android.hardware.Camera;
1414 import android.view.ViewGroup.LayoutParams;
1515 import android.widget.FrameLayout;
1616
17+/**
18+ * Hiroマーカ平面から画像を取得します。
19+ * 画像取得APIは低速です。解像度の高いものは避けてください。
20+ * 撮影画面全体のキャプチャをするときは、CameraPreviewから直接画像を得た方が良いです。
21+ *
22+ */
1723 public class ImagePickupActivity extends AndSketch implements AndGLView.IGLFunctionEvent
1824 {
1925 CameraPreview _camera_preview;
--- a/sample/MarkerPlane/src/jp/nyatla/nyartoolkit/and/MarkerPlaneActivity.java
+++ b/sample/MarkerPlane/src/jp/nyatla/nyartoolkit/and/MarkerPlaneActivity.java
@@ -8,12 +8,18 @@ import jp.androidgroup.nyartoolkit.markersystem.NyARAndSensor;
88 import jp.androidgroup.nyartoolkit.sketch.AndSketch;
99 import jp.androidgroup.nyartoolkit.utils.camera.CameraPreview;
1010 import jp.androidgroup.nyartoolkit.utils.gl.*;
11+import jp.nyatla.nyartoolkit.core.types.NyARDoublePoint3d;
1112 import jp.nyatla.nyartoolkit.markersystem.NyARMarkerSystemConfig;
1213 import android.content.res.AssetManager;
1314 import android.hardware.Camera;
15+import android.view.MotionEvent;
1416 import android.view.ViewGroup.LayoutParams;
1517 import android.widget.FrameLayout;
1618
19+/**
20+ * Hiroマーカの表面を移動する立方体を表示します。
21+ * マーカを撮影しながら画面をタッチして下さい。
22+ */
1723 public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunctionEvent
1824 {
1925 CameraPreview _camera_preview;
@@ -47,7 +53,7 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct
4753 NyARAndMarkerSystem _ms;
4854 private int _mid;
4955 AndGLFpsLabel fps;
50- AndGLBitmapSprite _bmp;
56+ AndGLBox box;
5157 AndGLDebugDump _debug=null;
5258 AndGLTextLabel text;
5359 public void setupGL(GL10 gl)
@@ -66,9 +72,9 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct
6672 gl.glLoadMatrixf(this._ms.getGlProjectionMatrix(),0);
6773 this.fps=new AndGLFpsLabel(this._glv,"MarkerPlaneActivity");
6874 this.fps.prefix=this._cap_size.width+"x"+this._cap_size.height+":";
69- this._bmp=new AndGLBitmapSprite(this._glv,64,64);
7075 this._debug=new AndGLDebugDump(this._glv);
7176 this.text=new AndGLTextLabel(this._glv);
77+ this.box=new AndGLBox(this._glv,40);
7278
7379 } catch (Exception e) {
7480 // TODO Auto-generated catch block
@@ -96,9 +102,11 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct
96102 this._ms.update(this._ss);
97103 if(this._ms.isExistMarker(this._mid)){
98104 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);
102110 }
103111 }
104112 }catch(Exception e)
@@ -106,5 +114,17 @@ public class MarkerPlaneActivity extends AndSketch implements AndGLView.IGLFunct
106114 ex=e;
107115 }
108116 }
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+ }
109129 Exception ex=null;
110130 }
--- a/sample/SimpleLite/src/jp/nyatla/nyartoolkit/and/SimpleLiteActivity.java
+++ b/sample/SimpleLite/src/jp/nyatla/nyartoolkit/and/SimpleLiteActivity.java
@@ -14,6 +14,11 @@ import android.hardware.Camera;
1414 import android.view.ViewGroup.LayoutParams;
1515 import android.widget.FrameLayout;
1616
17+/**
18+ * Hiroマーカの上にカラーキューブを表示します。
19+ * 定番のサンプルです。
20+ *
21+ */
1722 public class SimpleLiteActivity extends AndSketch implements AndGLView.IGLFunctionEvent
1823 {
1924 CameraPreview _camera_preview;
旧リポジトリブラウザで表示