| 60 |
* バージョン文字列です。 |
* バージョン文字列です。 |
| 61 |
* NyAR4psgのバージョン情報を示します。 |
* NyAR4psgのバージョン情報を示します。 |
| 62 |
*/ |
*/ |
| 63 |
public final static String VERSION = "NyAR4psg/1.1.0;NyARToolkit for java/3.0.0+;ARToolKit/2.72.1"; |
public final static String VERSION = "NyAR4psg/1.1.4;NyARToolkit for java/3.0.0+;ARToolKit/2.72.1"; |
| 64 |
/** 参照するAppletのインスタンスです。*/ |
/** 参照するAppletのインスタンスです。*/ |
| 65 |
protected PApplet _ref_papplet; |
protected PApplet _ref_papplet; |
| 66 |
/** ProcessingスタイルのProjectionMatrixです。*/ |
/** ProcessingスタイルのProjectionMatrixです。*/ |
| 67 |
protected final PMatrix3D _ps_projection=new PMatrix3D(); |
protected final PMatrix3D _ps_projection=new PMatrix3D(); |
| 68 |
|
/** バックグラウンド用のModelviewMatrixです。*/ |
| 69 |
|
protected final PMatrix3D _ps_background_mv=new PMatrix3D(); |
| 70 |
|
|
| 71 |
/** ARToolkitパラメータのインスタンスです。*/ |
/** ARToolkitパラメータのインスタンスです。*/ |
| 72 |
protected final NyARParam _ar_param=new NyARParam(); |
protected final NyARParam _ar_param=new NyARParam(); |
| 73 |
protected final NyARFrustum _frustum=new NyARFrustum();; |
protected final NyARFrustum _frustum=new NyARFrustum();; |
| 105 |
return; |
return; |
| 106 |
} |
} |
| 107 |
/** |
/** |
| 108 |
* この関数は、PImageをバックグラウンドへ描画します。PImageはfarclip面に描画されます。 |
* この関数は、PImageをバックグラウンドへ描画します。PImageはfarclip面+1の部分に描画します。 |
| 109 |
* <div>この関数は、次のコードと等価です。</div> |
* <div>この関数は、次のコードと等価です。</div> |
| 110 |
* <hr/> |
* <hr/> |
| 111 |
* :<br/> |
* :<br/> |
| 112 |
* PMatrix3D om=new PMatrix3D(((PGraphics3D)g).projection);<br/> |
* PMatrix3D om=new PMatrix3D(((PGraphics3D)g).projection);<br/> |
| 113 |
* ortho(-width/2, width/2,-height/2,height/2,near,far);<br/> |
* setBackgroundOrtho(img.width,img.height)<br/> |
| 114 |
* pushMatrix();<br/> |
* pushMatrix();<br/> |
| 115 |
* translate(0,0,far);<br/> |
* resetMatrix();<br/> |
| 116 |
|
* translate(0,0,-(far*0.99f));<br/> |
| 117 |
* image(img,-width/2,-height/2);<br/> |
* image(img,-width/2,-height/2);<br/> |
| 118 |
* popMatrix();<br/> |
* popMatrix();<br/> |
| 119 |
* setPerspective(om);<br/> |
* setPerspective(om);<br/> |
| 128 |
{ |
{ |
| 129 |
PApplet pa=this._ref_papplet; |
PApplet pa=this._ref_papplet; |
| 130 |
PMatrix3D om=new PMatrix3D(((PGraphics3D)pa.g).projection); |
PMatrix3D om=new PMatrix3D(((PGraphics3D)pa.g).projection); |
| 131 |
this.setAROrtho(i_img.width,i_img.height); |
this.setBackgroundOrtho(i_img.width,i_img.height); |
| 132 |
pa.pushMatrix(); |
pa.pushMatrix(); |
| 133 |
pa.resetMatrix(); |
pa.setMatrix(this._ps_background_mv); |
|
pa.translate(0,0,this._clip_far); |
|
| 134 |
pa.image(i_img,-i_img.width/2,-i_img.height/2); |
pa.image(i_img,-i_img.width/2,-i_img.height/2); |
| 135 |
pa.popMatrix(); |
pa.popMatrix(); |
| 136 |
//行列の復帰 |
//行列の復帰 |
| 149 |
{ |
{ |
| 150 |
this._clip_far=i_far; |
this._clip_far=i_far; |
| 151 |
this._clip_near=i_near; |
this._clip_near=i_near; |
| 152 |
arPerspectiveMat2Projection(this._ar_param,i_near,i_far,this._ps_projection,this._frustum); |
arPerspectiveMat2Projection(this._ar_param,i_near,i_far,this._ps_projection,this._frustum); |
| 153 |
|
this._ps_background_mv.reset(); |
| 154 |
|
this._ps_background_mv.translate(0,0,-i_far); |
| 155 |
} |
} |
| 156 |
/** |
/** |
| 157 |
* この関数は、正射影行列をProcessingへセットします。 |
* この関数は、正射影行列をProcessingへセットします。 |
| 158 |
* 画面の中心が0,0にセットされます。near,farクリップは、{@link #setARClipping}でセットしたクリップ面をそのまま指定します。 |
* 画面の中心が0,0にセットされます。 |
| 159 |
|
* nearクリップには、{@link #setARClipping}でセットしたクリップ面を指定します。 |
| 160 |
|
* farクリップには、{@link #setARClipping}でセットしたクリップ面+1を指定します。 |
| 161 |
* <div>この関数は、次のコードと等価です。</div> |
* <div>この関数は、次のコードと等価です。</div> |
| 162 |
* <hr/> |
* <hr/> |
| 163 |
* :<br/> |
* :<br/> |
| 164 |
* ortho(-i_width/2, i_width/2,-i_height/2,i_height/2,near,far);<br/> |
* ortho(-i_width/2, i_width/2,-i_height/2,i_height/2,near,far+1);<br/> |
| 165 |
* :<br/> |
* :<br/> |
| 166 |
* <hr/> |
* <hr/> |
| 167 |
* @param i_width |
* @param i_width |
| 169 |
* @param i_height |
* @param i_height |
| 170 |
* 高さを指定します。 |
* 高さを指定します。 |
| 171 |
*/ |
*/ |
| 172 |
public void setAROrtho(int i_width,int i_height) |
public void setBackgroundOrtho(int i_width,int i_height) |
| 173 |
{ |
{ |
| 174 |
float half_w=i_width/2; |
float half_w=i_width/2; |
| 175 |
float half_h=i_height/2; |
float half_h=i_height/2; |
| 176 |
this._ref_papplet.ortho(-half_w, half_w,-half_h,half_h,this._clip_near,this._clip_far); |
this._ref_papplet.ortho(-half_w, half_w,-half_h,half_h,this._clip_near,this._clip_far+1); |
| 177 |
} |
} |
| 178 |
/** |
/** |
| 179 |
* この関数は、ARToolKit準拠のProjectionMatrixをProcessingにセットします。 |
* この関数は、ARToolKit準拠のProjectionMatrixをProcessingにセットします。 |
| 180 |
* 関数を実行すると、ProcessingのProjectionMatrixがARToolKitのカメラパラメータのものに変わり、映像にマッチした描画ができるようになります。 |
* 関数を実行すると、ProcessingのProjectionMatrixがARToolKitのカメラパラメータのものに変わり、映像にマッチした描画ができるようになります。 |
| 181 |
* ProcessingのデフォルトFrustumに戻すときは、{@link PGraphics3D#perspective()}を使います。 |
* ProcessingのデフォルトFrustumに戻すときは、{@link PGraphics3D#perspective()}を使います。 |
| 182 |
* Frustumの有効期間は、次に{@link PGraphics3D#perspective()}か{@link PGraphics3D#perspective()}をコールするまでです。 |
* Frustumの有効期間は、次に{@link PGraphics3D#perspective()}か{@link PGraphics3D#perspective()}をコールするまでです。 |
| 183 |
|
* <p> |
| 184 |
|
* Version 1.1.0より、古いprojection matrixを返さなくなりました。古いprojection matrixが必要な時は、{@link PGraphics3D#projection}を複製して保存して下さい。 |
| 185 |
|
* </p> |
| 186 |
*/ |
*/ |
| 187 |
public void setARPerspective() |
public void setARPerspective() |
| 188 |
{ |
{ |
| 192 |
* この関数は、ProjectionMatrixをProcessingにセットします。 |
* この関数は、ProjectionMatrixをProcessingにセットします。 |
| 193 |
* @param i_projection |
* @param i_projection |
| 194 |
* 設定するProjectionMatrixを指定します。 |
* 設定するProjectionMatrixを指定します。 |
|
* |
|
| 195 |
* <p> |
* <p> |
| 196 |
* Processing/1.3になったら、{@link PApplet#matrixMode}使ってきちんと使えるようになると思う。 |
* Processing/1.3になったら、{@link PApplet#matrixMode}使ってきちんと使えるようになると思う。 |
| 197 |
* 今は無理なので、frustum経由 |
* 今は無理なので、frustum経由 |
| 198 |
* </p> |
* </p> |
| 199 |
|
* <p> |
| 200 |
|
* Version 1.1.0より、古いprojection matrixを返さなくなりました。古いprojection matrixが必要な時は、{@link PGraphics3D#projection}を複製して保存して下さい。 |
| 201 |
|
* </p> |
| 202 |
*/ |
*/ |
| 203 |
public void setPerspective(PMatrix3D i_projection) |
public void setPerspective(PMatrix3D i_projection) |
| 204 |
{ |
{ |