OSDN Git Service

[バックアップ]NyARToolkit
[nyartoolkit-and/nyartoolkit-and.git] / sample / jogl / jp / nyatla / nyartoolkit / jogl / sample / x2 / GLNyARSingleDetectMarker_X2.java
1 /* \r
2  * PROJECT: NyARToolkit JOGL utilities.\r
3  * --------------------------------------------------------------------------------\r
4  * This work is based on the original ARToolKit developed by\r
5  *   Hirokazu Kato\r
6  *   Mark Billinghurst\r
7  *   HITLab, University of Washington, Seattle\r
8  * http://www.hitl.washington.edu/artoolkit/\r
9  *\r
10  * The NyARToolkit is Java version ARToolkit class library.\r
11  * Copyright (C)2008 R.Iizuka\r
12  *\r
13  * This program is free software; you can redistribute it and/or\r
14  * modify it under the terms of the GNU General Public License\r
15  * as published by the Free Software Foundation; either version 2\r
16  * of the License, or (at your option) any later version.\r
17  * \r
18  * This program is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  * \r
23  * You should have received a copy of the GNU General Public License\r
24  * along with this framework; if not, write to the Free Software\r
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
26  * \r
27  * For further information please contact.\r
28  *      http://nyatla.jp/nyatoolkit/\r
29  *      <airmail(at)ebony.plala.or.jp>\r
30  * \r
31  */\r
32 package jp.nyatla.nyartoolkit.jogl.sample.x2;\r
33 \r
34 import jp.nyatla.nyartoolkit.NyARException;\r
35 import jp.nyatla.nyartoolkit.core.NyARCode;\r
36 import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
37 import jp.nyatla.nyartoolkit.core.transmat.NyARTransMatResult;\r
38 import jp.nyatla.nyartoolkit.nymodel.x2.*;\r
39 \r
40 \r
41 /**\r
42  * NyARSingleDetectMarkerにOpenGL向け関数を追加したもの\r
43  */\r
44 public class GLNyARSingleDetectMarker_X2 extends NyARSingleDetectMarker_X2\r
45 {\r
46         private NyARTransMatResult trans_mat_result = new NyARTransMatResult();\r
47 \r
48         private double view_scale_factor = 0.025;// #define VIEW_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units.\r
49 \r
50         public GLNyARSingleDetectMarker_X2(NyARParam i_param, NyARCode i_code, double i_marker_width) throws NyARException\r
51         {\r
52                 super(i_param, i_code, i_marker_width);\r
53         }\r
54 \r
55         public void setScaleFactor(double i_new_value)\r
56         {\r
57                 view_scale_factor = i_new_value;\r
58         }\r
59 \r
60         // public static void arglCameraViewRH(const double para[3][4], GLdouble m_modelview[16], const double scale)\r
61         public double[] getCameraViewRH() throws NyARException\r
62         {\r
63                 double[] result = new double[16];\r
64                 getCameraViewRH(result);\r
65                 return result;\r
66         }\r
67 \r
68         /**\r
69          * \r
70          * @param o_result\r
71          * 結果値を格納する配列を指定してください。double[16]以上が必要です。\r
72          * @throws NyARException\r
73          */\r
74         public void getCameraViewRH(double[] o_result) throws NyARException\r
75         {\r
76                 // 座標を計算\r
77                 this.getTransmationMatrix(this.trans_mat_result);\r
78                 // 行列変換\r
79                 final NyARTransMatResult mat = this.trans_mat_result;\r
80                 o_result[0 + 0 * 4] = mat.m00; // R1C1\r
81                 o_result[0 + 1 * 4] = mat.m01; // R1C2\r
82                 o_result[0 + 2 * 4] = mat.m02;\r
83                 o_result[0 + 3 * 4] = mat.m03;\r
84                 o_result[1 + 0 * 4] = -mat.m10; // R2\r
85                 o_result[1 + 1 * 4] = -mat.m11;\r
86                 o_result[1 + 2 * 4] = -mat.m12;\r
87                 o_result[1 + 3 * 4] = -mat.m13;\r
88                 o_result[2 + 0 * 4] = -mat.m20; // R3\r
89                 o_result[2 + 1 * 4] = -mat.m21;\r
90                 o_result[2 + 2 * 4] = -mat.m22;\r
91                 o_result[2 + 3 * 4] = -mat.m23;\r
92                 o_result[3 + 0 * 4] = 0.0;\r
93                 o_result[3 + 1 * 4] = 0.0;\r
94                 o_result[3 + 2 * 4] = 0.0;\r
95                 o_result[3 + 3 * 4] = 1.0;\r
96                 if (view_scale_factor != 0.0) {\r
97                         o_result[12] *= view_scale_factor;\r
98                         o_result[13] *= view_scale_factor;\r
99                         o_result[14] *= view_scale_factor;\r
100                 }\r
101                 return;\r
102         }\r
103 }\r