2 * PROJECT: NyARToolkit JOGL utilities.
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java edition ARToolKit class library.
\r
11 * Copyright (C)2008-2009 Ryo Iizuka
\r
13 * This program is free software: you can redistribute it and/or modify
\r
14 * it under the terms of the GNU General Public License as published by
\r
15 * the Free Software Foundation, either version 3 of the License, or
\r
16 * (at your option) any later version.
\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
23 * You should have received a copy of the GNU General Public License
\r
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
26 * For further information please contact.
\r
27 * http://nyatla.jp/nyatoolkit/
\r
28 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
31 package jp.nyatla.nyartoolkit.jogl.utils;
\r
33 import jp.nyatla.nyartoolkit.core.param.NyARParam;
\r
34 import jp.nyatla.nyartoolkit.core.param.NyARPerspectiveProjectionMatrix;
\r
35 import jp.nyatla.nyartoolkit.core.types.*;
\r
36 import jp.nyatla.nyartoolkit.core.types.matrix.*;
\r
38 * OpenGL向けの形式変換変換関数を提供します。
\r
39 * 描画系関数は{@link NyARGLDrawUtil}を参照してください。
\r
41 public class NyARGLUtil
\r
44 * NyARToolKit 2.53以前のコードと互換性を持たせるためのスケール値。{@link #toCameraFrustumRH}のi_scaleに設定することで、
\r
45 * 以前のバージョンの数値系と互換性を保ちます。
\r
47 public final static double SCALE_FACTOR_toCameraFrustumRH_NYAR2=1.0;
\r
49 * NyARToolKit 2.53以前のコードと互換性を持たせるためのスケール値。{@link #toCameraViewRH}のi_scaleに設定することで、
\r
50 * 以前のバージョンの数値系と互換性を保ちます。
\r
52 public final static double SCALE_FACTOR_toCameraViewRH_NYAR2=1/0.025;
\r
54 private NyARGLUtil()
\r
60 * ARToolKitスタイルのカメラパラメータから、 CameraFrustamを計算します。
\r
63 * スケール値を指定します。1=1mmです。10ならば1=1cm,1000ならば1=1mです。
\r
64 * 2.53以前のNyARToolkitと互換性を持たせるときは、{@link #SCALE_FACTOR_toCameraFrustumRH_NYAR2}を指定してください。
\r
66 * 視錐体のnearPointを指定します。単位は、i_scaleに設定した値で決まります。
\r
68 * 視錐体のfarPointを指定します。単位は、i_scaleに設定した値で決まります。
\r
69 * @param o_gl_projection
\r
71 public static void toCameraFrustumRH(NyARParam i_arparam,double i_scale,double i_near,double i_far,double[] o_gl_projection)
\r
73 toCameraFrustumRH(i_arparam.getPerspectiveProjectionMatrix(),i_arparam.getScreenSize(),i_scale,i_near,i_far,o_gl_projection);
\r
77 * ARToolKitスタイルのProjectionMatrixから、 CameraFrustamを計算します。
\r
82 * {@link #toCameraFrustumRH(NyARParam i_arparam,double i_scale,double i_near,double i_far,double[] o_gl_projection)}を参照。
\r
84 * {@link #toCameraFrustumRH(NyARParam i_arparam,double i_scale,double i_near,double i_far,double[] o_gl_projection)}を参照。
\r
86 * {@link #toCameraFrustumRH(NyARParam i_arparam,double i_scale,double i_near,double i_far,double[] o_gl_projection)}を参照。
\r
87 * @param o_gl_projection
\r
88 * {@link #toCameraFrustumRH(NyARParam i_arparam,double i_scale,double i_near,double i_far,double[] o_gl_projection)}を参照。
\r
90 public static void toCameraFrustumRH(NyARPerspectiveProjectionMatrix i_promat,NyARIntSize i_size,double i_scale,double i_near,double i_far,double[] o_gl_projection)
\r
92 NyARDoubleMatrix44 m=new NyARDoubleMatrix44();
\r
93 i_promat.makeCameraFrustumRH(i_size.w,i_size.h,i_near*i_scale,i_far*i_scale,m);
\r
94 m.getValueT(o_gl_projection);
\r
98 * NyARTransMatResultをOpenGLの行列へ変換します。
\r
102 * 座標系のスケール値を指定します。1=1mmです。10ならば1=1cm,1000ならば1=1mです。
\r
103 * 2.53以前のNyARToolkitと互換性を持たせるときは、{@link #SCALE_FACTOR_toCameraViewRH_NYAR2}を指定してください。
\r
104 * @param o_gl_result
\r
106 public static void toCameraViewRH(NyARDoubleMatrix44 mat,double i_scale, double[] o_gl_result)
\r
108 o_gl_result[0 + 0 * 4] = mat.m00;
\r
109 o_gl_result[1 + 0 * 4] = -mat.m10;
\r
110 o_gl_result[2 + 0 * 4] = -mat.m20;
\r
111 o_gl_result[3 + 0 * 4] = 0.0;
\r
112 o_gl_result[0 + 1 * 4] = mat.m01;
\r
113 o_gl_result[1 + 1 * 4] = -mat.m11;
\r
114 o_gl_result[2 + 1 * 4] = -mat.m21;
\r
115 o_gl_result[3 + 1 * 4] = 0.0;
\r
116 o_gl_result[0 + 2 * 4] = mat.m02;
\r
117 o_gl_result[1 + 2 * 4] = -mat.m12;
\r
118 o_gl_result[2 + 2 * 4] = -mat.m22;
\r
119 o_gl_result[3 + 2 * 4] = 0.0;
\r
121 double scale=1/i_scale;
\r
122 o_gl_result[0 + 3 * 4] = mat.m03*scale;
\r
123 o_gl_result[1 + 3 * 4] = -mat.m13*scale;
\r
124 o_gl_result[2 + 3 * 4] = -mat.m23*scale;
\r
125 o_gl_result[3 + 3 * 4] = 1.0;
\r