2 * NyARSingleDetectMarkerにOpenGL向け関数を追加したもの
\r
3 * (c)2008 A虎@nyatla.jp
\r
4 * airmail(at)ebony.plala.or.jp
\r
7 package jp.nyatla.nyartoolkit.jogl.utils;
\r
9 import jp.nyatla.nyartoolkit.NyARException;
\r
10 import jp.nyatla.nyartoolkit.core.NyARCode;
\r
11 import jp.nyatla.nyartoolkit.core.NyARParam;
\r
12 import jp.nyatla.nyartoolkit.core.NyARTransMatResult;
\r
13 import jp.nyatla.nyartoolkit.detector.*;
\r
15 public class GLNyARSingleDetectMarker extends NyARSingleDetectMarker {
\r
16 private NyARTransMatResult trans_mat_result = new NyARTransMatResult();
\r
17 private double view_scale_factor = 0.025;// #define VIEW_SCALEFACTOR
\r
19 // 0.025 // 1.0 ARToolKit unit
\r
20 // becomes 0.025 of my OpenGL
\r
23 public GLNyARSingleDetectMarker(NyARParam i_param, NyARCode i_code,
\r
24 double i_marker_width) throws NyARException {
\r
25 super(i_param, i_code, i_marker_width);
\r
28 public void setScaleFactor(double i_new_value) {
\r
29 view_scale_factor = i_new_value;
\r
32 // public static void arglCameraViewRH(const double para[3][4], GLdouble
\r
33 // m_modelview[16], const double scale)
\r
34 public double[] getCameraViewRH() throws NyARException {
\r
35 double[] result = new double[16];
\r
36 getCameraViewRH(result);
\r
43 * 結果値を格納する配列を指定してください。double[16]以上が必要です。
\r
44 * @throws NyARException
\r
46 public void getCameraViewRH(double[] o_result) throws NyARException {
\r
48 this.getTransmationMatrix(this.trans_mat_result);
\r
50 double[][] para = this.trans_mat_result.getArray();
\r
51 o_result[0 + 0 * 4] = para[0][0]; // R1C1
\r
52 o_result[0 + 1 * 4] = para[0][1]; // R1C2
\r
53 o_result[0 + 2 * 4] = para[0][2];
\r
54 o_result[0 + 3 * 4] = para[0][3];
\r
55 o_result[1 + 0 * 4] = -para[1][0]; // R2
\r
56 o_result[1 + 1 * 4] = -para[1][1];
\r
57 o_result[1 + 2 * 4] = -para[1][2];
\r
58 o_result[1 + 3 * 4] = -para[1][3];
\r
59 o_result[2 + 0 * 4] = -para[2][0]; // R3
\r
60 o_result[2 + 1 * 4] = -para[2][1];
\r
61 o_result[2 + 2 * 4] = -para[2][2];
\r
62 o_result[2 + 3 * 4] = -para[2][3];
\r
63 o_result[3 + 0 * 4] = 0.0;
\r
64 o_result[3 + 1 * 4] = 0.0;
\r
65 o_result[3 + 2 * 4] = 0.0;
\r
66 o_result[3 + 3 * 4] = 1.0;
\r
67 if (view_scale_factor != 0.0) {
\r
68 o_result[12] *= view_scale_factor;
\r
69 o_result[13] *= view_scale_factor;
\r
70 o_result[14] *= view_scale_factor;
\r
78 * 結果値を格納する配列を指定してください。double[16]以上が必要です。
\r
79 * @throws NyARException
\r
81 public void getCameraViewRH(float[] o_result) throws NyARException {
\r
83 this.getTransmationMatrix(this.trans_mat_result);
\r
85 double[][] para = this.trans_mat_result.getArray();
\r
86 o_result[0 + 0 * 4] = (float) para[0][0]; // R1C1
\r
87 o_result[0 + 1 * 4] = (float) para[0][1]; // R1C2
\r
88 o_result[0 + 2 * 4] = (float) para[0][2];
\r
89 o_result[0 + 3 * 4] = (float) para[0][3];
\r
90 o_result[1 + 0 * 4] = (float) -para[1][0]; // R2
\r
91 o_result[1 + 1 * 4] = (float) -para[1][1];
\r
92 o_result[1 + 2 * 4] = (float) -para[1][2];
\r
93 o_result[1 + 3 * 4] = (float) -para[1][3];
\r
94 o_result[2 + 0 * 4] = (float) -para[2][0]; // R3
\r
95 o_result[2 + 1 * 4] = (float) -para[2][1];
\r
96 o_result[2 + 2 * 4] = (float) -para[2][2];
\r
97 o_result[2 + 3 * 4] = (float) -para[2][3];
\r
98 o_result[3 + 0 * 4] = (float) 0.0;
\r
99 o_result[3 + 1 * 4] = (float) 0.0;
\r
100 o_result[3 + 2 * 4] = (float) 0.0;
\r
101 o_result[3 + 3 * 4] = (float) 1.0;
\r
102 if (view_scale_factor != 0.0) {
\r
103 o_result[12] *= view_scale_factor;
\r
104 o_result[13] *= view_scale_factor;
\r
105 o_result[14] *= view_scale_factor;
\r