浓毛老太交欧美老妇热爱乱,蜜臀性色av免费,妺妺窝人体色www看美女,久久久久久久久久久大尺度免费视频,麻豆人妻无码性色av专区

位置:51電子網(wǎng) » 技術(shù)資料 » 其它綜合

JSR184規(guī)范封裝照相機(jī)的lookat方法

發(fā)布時(shí)間:2008/6/5 0:00:00 訪問次數(shù):334

jsr-184與mascot capsule v3主要的不同就是關(guān)于照相機(jī)的實(shí)現(xiàn)。jsr-184支持照相機(jī)結(jié)合矩陣堆棧處理,例如,我們經(jīng)常使用transform對(duì)象移動(dòng)照相機(jī)。而mascot capsule v3依靠”look-at”方法,這是在某些3d api里的通用方法。look-at方法從一個(gè)position,一個(gè) look-at direction和一個(gè)up vector創(chuàng)建一個(gè)照相機(jī)轉(zhuǎn)換矩陣,為了方便mascot capsule v3與jsr-184之間的轉(zhuǎn)換,digital chocolate采納了mascot capsule v3照相機(jī)設(shè)計(jì)方法,并寫了一個(gè)支持jsr-184的包。

  在jsr-184 api規(guī)范里,nodetransform類指定了一系列方法。這些方法有利于在jsr-184實(shí)現(xiàn)look-at方法。然而,它被認(rèn)為與jsr-184執(zhí)行說明規(guī)范有所不同,有時(shí)甚至?xí)雎赃@一系列方法。

  自己實(shí)現(xiàn)look-at方法其實(shí)并不復(fù)雜。下面的代碼例子是digital chocolate公司如何處理照相機(jī)的封裝設(shè)計(jì)。請(qǐng)注意digital chocolate公司在mascot capsule v3中使用整數(shù)來處理,而在設(shè)計(jì)更高層的游戲類設(shè)計(jì)中使用浮點(diǎn)數(shù)來處理。

/**
* wrapper method for setting look at camera.
*
* the method requires that look and up vectors normalized.
*/
public static final void setlookat(float a_posx, float a_posy, float a_posz,
float a_lookx, float a_looky, float a_lookz,
float a_upx, float a_upy, float a_upz)
{
 // jsr-184 version
 if (use_m3g)
 {
  // cross product to get side vector
  float sidex = (a_looky * a_upz) - (a_lookz * a_upy);
  float sidey = (a_lookz * a_upx) - (a_lookx * a_upz);
  float sidez = (a_lookx * a_upy) - (a_looky * a_upx);

  float inv_len = 1.0f / (float) java.lang.math.sqrt(sidex * sidex + sidey * sidey + sidez * sidez);
  sidex *= inv_len;
  sidey *= inv_len;
  sidez *= inv_len;

  // make up vector perpendicular
  a_upx = (sidey * a_lookz) - (sidez * a_looky);
  a_upy = (sidez * a_lookx) - (sidex * a_lookz);
  a_upz = (sidex * a_looky) - (sidey * a_lookx);
  // footnote: up is unit size because side and look are perpendicular

  sm_mtx[0] = sidex;
  sm_mtx[1] = a_upx;
  sm_mtx[2] = -a_lookx;
  sm_mtx[3] = a_posx;
  sm_mtx[4] = sidey;
  sm_mtx[5] = a_upy;
  sm_mtx[6] = -a_looky;
  sm_mtx[7] = a_posy;
  sm_mtx[8] = sidez;
  sm_mtx[9] = a_upz;
  sm_mtx[10] = -a_lookz;
  sm_mtx[11] = a_posz;
  sm_mtx[12] = 0.0f;
  sm_mtx[13] = 0.0f;
  sm_mtx[14] = 0.0f;
  sm_mtx[15] = 1.0f;

  sm_m3gtransform.set(sm_mtx);
 }
 // mascot version
 if (use_mascot)
 {
  sm_mascottmpvectora.set((int)a_posx, (int)a_posy, (int)a_posz);
  sm_mascottmpvectorb.set((int)(a_lookx * mascot_one),(int)(a_looky * mascot_one),(int)(a_lookz * mascot_one));
  sm_mascottmpvectorc.set(0, dajmgraphics.mascot_one, 0);
  sm_mascotaffinetrans.lookat(sm_mascottmpvectora, sm_mascottmpvectorb,sm_mascottmpvectorc);
 }
}


jsr-184與mascot capsule v3主要的不同就是關(guān)于照相機(jī)的實(shí)現(xiàn)。jsr-184支持照相機(jī)結(jié)合矩陣堆棧處理,例如,我們經(jīng)常使用transform對(duì)象移動(dòng)照相機(jī)。而mascot capsule v3依靠”look-at”方法,這是在某些3d api里的通用方法。look-at方法從一個(gè)position,一個(gè) look-at direction和一個(gè)up vector創(chuàng)建一個(gè)照相機(jī)轉(zhuǎn)換矩陣,為了方便mascot capsule v3與jsr-184之間的轉(zhuǎn)換,digital chocolate采納了mascot capsule v3照相機(jī)設(shè)計(jì)方法,并寫了一個(gè)支持jsr-184的包。

  在jsr-184 api規(guī)范里,nodetransform類指定了一系列方法。這些方法有利于在jsr-184實(shí)現(xiàn)look-at方法。然而,它被認(rèn)為與jsr-184執(zhí)行說明規(guī)范有所不同,有時(shí)甚至?xí)雎赃@一系列方法。

  自己實(shí)現(xiàn)look-at方法其實(shí)并不復(fù)雜。下面的代碼例子是digital chocolate公司如何處理照相機(jī)的封裝設(shè)計(jì)。請(qǐng)注意digital chocolate公司在mascot capsule v3中使用整數(shù)來處理,而在設(shè)計(jì)更高層的游戲類設(shè)計(jì)中使用浮點(diǎn)數(shù)來處理。

/**
* wrapper method for setting look at camera.
*
* the method requires that look and up vectors normalized.
*/
public static final void setlookat(float a_posx, float a_posy, float a_posz,
float a_lookx, float a_looky, float a_lookz,
float a_u, float a_upy, float a_upz)
{
 // jsr-184 version
 if (use_m3g)
 {
  // cross product to get side vector
  float sidex = (a_looky * a_upz) - (a_lookz * a_upy);
  float sidey = (a_lookz * a_u) - (a_lookx * a_upz);
  float sidez = (a_lookx * a_upy) - (a_looky * a_u);

  float inv_len = 1.0f / (float) java.lang.math.sqrt(sidex * sidex + sidey * sidey + sidez * sidez);
  sidex *= inv_len;
  sidey *= inv_len;
  sidez *= inv_len;

  // make up vector perpendicular
  a_u = (sidey * a_lookz) - (sidez * a_looky);
  a_upy = (sidez * a_lookx) - (sidex * a_lookz);
  a_upz = (sidex * a_looky) - (sidey * a_lookx);
  // footnote: up is unit size because side and look are perpendicular

  sm_mtx[0] = sidex;
  sm_mtx[1] = a_u;
  sm_mtx[2] = -a_lookx;
  sm_mtx[3] = a_posx;
  sm_mtx[4] = sidey;
  sm_mtx[5] = a_upy;
  sm_mtx[6] = -a_looky;
  sm_mtx[7] = a_posy;
  sm_mtx[8] = sidez;
  sm_mtx[9] = a_upz;
  sm_mtx[10] = -a_lookz;
  sm_mtx[11] = a_posz;
  sm_mtx[12] = 0.0f;
  sm_mtx[13] = 0.0f;
  sm_mtx[14] = 0.0f;
  sm_mtx[15] = 1.0f;

  sm_m3gtransform.set(sm_mtx);
 }
 // mascot version
 if (use_mascot)
 {
  sm_mascottmpvectora.set((int)a_posx, (int)a_posy, (int)a_posz);
  sm_mascottmpvectorb.set((int)(a_lookx * mascot_one),(int)(a_looky * mascot_one),(int)(a_lookz * mascot_one));
  sm_mascottmpvectorc.set(0, dajmgraphics.mascot_one, 0);
  sm_mascotaffinetrans.lookat(sm_mascottmpvectora, sm_mascottmpvectorb,sm_mascottmpvectorc);
 }
}


相關(guān)IC型號(hào)

熱門點(diǎn)擊

 

推薦技術(shù)資料

羅盤誤差及補(bǔ)償
    造成羅盤誤差的主要因素有傳感器誤差、其他磁材料干擾等。... [詳細(xì)]
版權(quán)所有:51dzw.COM
深圳服務(wù)熱線:13692101218  13751165337
粵ICP備09112631號(hào)-6(miitbeian.gov.cn)
公網(wǎng)安備44030402000607
深圳市碧威特網(wǎng)絡(luò)技術(shù)有限公司
付款方式


 復(fù)制成功!