• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。


Commit MetaInfo

Revision155 (tree)
Time2016-11-07 02:03:29
Authorxops-mikan

Log Message

メイン画面でのプレイヤーが所持する武器描画を、可変解像度を考慮した設計に変更。

Change Summary

Incremental Difference

--- trunk/d3dgraphics-directx.cpp (revision 154)
+++ trunk/d3dgraphics-directx.cpp (revision 155)
@@ -148,28 +148,17 @@
148148 //ShowCursor(FALSE);
149149
150150
151- float aspecth, prx, pry, r;
152- aspecth = (float)SCREEN_WIDTH/SCREEN_HEIGHT;
151+ //HUD 現在持っている武器を描画する座標
152+ HUD_myweapon_x[0] = SCREEN_WIDTH - 140.0f;
153+ HUD_myweapon_y[0] = SCREEN_HEIGHT - 40.0f;
154+ HUD_myweapon_z[0] = 0.86f;
153155
154- //HUD_myweapon [奥行き, 縦, 横]
156+ //HUD 予備の武器を描画する座標
157+ HUD_myweapon_x[1] = SCREEN_WIDTH - 72.0f;
158+ HUD_myweapon_y[1] = SCREEN_HEIGHT - 25.0f;
159+ HUD_myweapon_z[1] = 0.93f;
155160
156- //HUD_A 現在持っている武器を描画する座標
157- prx = DegreeToRadian(-39) * aspecth /2;
158- pry = DegreeToRadian(-55) /2;
159- r = 7.5f;
160- HUD_myweapon_x[0] = cos(pry)*r;
161- HUD_myweapon_y[0] = sin(pry)*r;
162- HUD_myweapon_z[0] = sin(prx)*r;
163161
164- //HUD_A 予備の武器を描?画する座標
165- prx = DegreeToRadian(-52) * aspecth /2;
166- pry = DegreeToRadian(-60) /2;
167- r = 16.0f;
168- HUD_myweapon_x[1] = cos(pry)*r;
169- HUD_myweapon_y[1] = sin(pry)*r;
170- HUD_myweapon_z[1] = sin(prx)*r;
171-
172-
173162 #ifdef ENABLE_DEBUGCONSOLE
174163 InitDebugFontData();
175164 if( LoadDebugFontTexture() == false ){
@@ -944,9 +933,6 @@
944933
945934 //! @brief ワールド空間を所持している武器を描画する場所に設定
946935 //! @param rotation 武器を回転させる
947-//! @param camera_x カメラのX座標
948-//! @param camera_y カメラのY座標
949-//! @param camera_z カメラのZ座標
950936 //! @param camera_rx カメラの横軸角度
951937 //! @param camera_ry カメラの縦軸角度
952938 //! @param rx 武器のの縦軸角度
@@ -953,30 +939,51 @@
953939 //! @param size 描画サイズ
954940 //! @note rotation・・ true:現在持っている武器です。 false:予備の武器です。(rx は無視されます)
955941 //! @todo 位置やサイズの微調整
956-void D3DGraphics::SetWorldTransformPlayerWeapon(bool rotation, float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, float rx, float size)
942+void D3DGraphics::SetWorldTransformPlayerWeapon(bool rotation, float camera_rx, float camera_ry, float rx, float size)
957943 {
958944 D3DXMATRIX matWorld;
945+ D3DXMATRIX matWorldV;
946+ D3DXMATRIXA16 matProj;
947+ D3DVIEWPORT9 pViewport;
948+ D3DXVECTOR3 p1;
959949 D3DXMATRIX matWorld1, matWorld2, matWorld3, matWorld4, matWorld5, matWorld6;
960950
961- size = size * 0.3f;
951+ if( rotation == true ){
952+ p1 = D3DXVECTOR3(HUD_myweapon_x[0], HUD_myweapon_y[0], HUD_myweapon_z[0]);
953+ }
954+ else{
955+ p1 = D3DXVECTOR3(HUD_myweapon_x[1], HUD_myweapon_y[1], HUD_myweapon_z[1]);
956+ }
962957
963- //行列を作成
964- D3DXMatrixTranslation(&matWorld1, camera_x, camera_y, camera_z);
958+ pd3dDevice->GetViewport(&pViewport);
959+
960+ //カメラ座標
961+ pd3dDevice->GetTransform(D3DTS_VIEW, &matWorldV);
962+
963+ //カメラ設定(射影変換行列)viewangle
964+ pd3dDevice->GetTransform(D3DTS_PROJECTION, &matProj);
965+
966+ D3DXMatrixIdentity(&matWorld);
967+
968+ //スクリーン空間からオブジェクト空間にベクトルを射影
969+ D3DXVec3Unproject(&p1, &p1, &pViewport, &matProj, &matWorldV, &matWorld);
970+
971+ //size = size * 0.3f;
972+ size = size * (0.0004f*SCREEN_HEIGHT*SCREEN_HEIGHT - 0.92f*SCREEN_HEIGHT + 650.0f) / 1000.f;
973+
974+ //行列計算
975+ D3DXMatrixTranslation(&matWorld1, p1.x, p1.y, p1.z);
965976 D3DXMatrixRotationY(&matWorld2, camera_rx *-1);
966977 D3DXMatrixRotationZ(&matWorld3, camera_ry);
967- // matWorld4 = [奥行き, 縦, 横]
968978 if( rotation == true ){
969- D3DXMatrixTranslation(&matWorld4, HUD_myweapon_x[0], HUD_myweapon_y[0], HUD_myweapon_z[0]);
970979 D3DXMatrixRotationY(&matWorld5, rx);
971980 }
972981 else{
973- D3DXMatrixTranslation(&matWorld4, HUD_myweapon_x[1], HUD_myweapon_y[1], HUD_myweapon_z[1]);
974982 D3DXMatrixRotationY(&matWorld5, D3DX_PI);
975983 }
976984 D3DXMatrixScaling(&matWorld6, size, size, size);
977985
978- //計算
979- matWorld = matWorld6 * matWorld5 * matWorld4 * matWorld3 * matWorld2 * matWorld1;
986+ matWorld = matWorld6 * matWorld5 * matWorld3 * matWorld2 * matWorld1;
980987
981988 //適用
982989 pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
--- trunk/d3dgraphics-opengl.cpp (revision 154)
+++ trunk/d3dgraphics-opengl.cpp (revision 155)
@@ -182,27 +182,17 @@
182182 TextureFont = LoadTexture(TextureFontFname, true, false);
183183
184184
185- float aspecth, prx, pry, r;
186- aspecth = (float)SCREEN_WIDTH/SCREEN_HEIGHT;
185+ //HUD 現在持っている武器を描画する座標
186+ HUD_myweapon_x[0] = SCREEN_WIDTH - 140.0f;
187+ HUD_myweapon_y[0] = SCREEN_HEIGHT - 40.0f;
188+ HUD_myweapon_z[0] = 0.86f;
187189
188- //HUD_myweapon [奥行き, 縦, 横]
190+ //HUD 予備の武器を描画する座標
191+ HUD_myweapon_x[1] = SCREEN_WIDTH - 72.0f;
192+ HUD_myweapon_y[1] = SCREEN_HEIGHT - 25.0f;
193+ HUD_myweapon_z[1] = 0.93f;
189194
190- //HUD_A 現在持っている武器を描画する座標
191- prx = (float)M_PI/180*-39 * aspecth /2;
192- pry = (float)M_PI/180*-55 /2;
193- r = 7.5f;
194- HUD_myweapon_x[0] = cos(pry)*r;
195- HUD_myweapon_y[0] = sin(pry)*r;
196- HUD_myweapon_z[0] = sin(prx)*r;
197195
198- //HUD_A 予備の武器を描画する座標
199- prx = (float)M_PI/180*-52 * aspecth /2;
200- pry = (float)M_PI/180*-60 /2;
201- r = 16.0f;
202- HUD_myweapon_x[1] = cos(pry)*r;
203- HUD_myweapon_y[1] = sin(pry)*r;
204- HUD_myweapon_z[1] = sin(prx)*r;
205-
206196 #ifdef ENABLE_DEBUGCONSOLE
207197 InitDebugFontData();
208198 if( LoadDebugFontTexture() == false ){
@@ -674,6 +664,9 @@
674664 //! @return 成功:テクスチャ認識番号(0以上) 失敗:-1
675665 int D3DGraphics::LoadTexture(char* filename, bool texturefont, bool BlackTransparent)
676666 {
667+ //未使用引数対策
668+ UNREFERENCED_PARAMETER(texturefont);
669+
677670 int id = -1;
678671 int format = 0;
679672
@@ -1606,9 +1599,6 @@
16061599
16071600 //! @brief ワールド空間を所持している武器を描画する場所に設定
16081601 //! @param rotation 武器を回転させる
1609-//! @param camera_x カメラのX座標
1610-//! @param camera_y カメラのY座標
1611-//! @param camera_z カメラのZ座標
16121602 //! @param camera_rx カメラの横軸角度
16131603 //! @param camera_ry カメラの縦軸角度
16141604 //! @param rx 武器のの縦軸角度
@@ -1615,24 +1605,48 @@
16151605 //! @param size 描画サイズ
16161606 //! @note rotation・・ true:現在持っている武器です。 false:予備の武器です。(rx は無視されます)
16171607 //! @todo 位置やサイズの微調整
1618-void D3DGraphics::SetWorldTransformPlayerWeapon(bool rotation, float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, float rx, float size)
1608+void D3DGraphics::SetWorldTransformPlayerWeapon(bool rotation, float camera_rx, float camera_ry, float rx, float size)
16191609 {
1620- size = size * 0.3f;
1610+ float screenX, screenY, screenZ;
1611+ double modelview[16];
1612+ double projection[16];
1613+ int viewport[4];
1614+ double objX, objY, objZ;
16211615
1616+ if( rotation == true ){
1617+ screenX = HUD_myweapon_x[0];
1618+ screenY = SCREEN_HEIGHT - HUD_myweapon_y[0];
1619+ screenZ = HUD_myweapon_z[0];
1620+ }
1621+ else{
1622+ screenX = HUD_myweapon_x[1];
1623+ screenY = SCREEN_HEIGHT - HUD_myweapon_y[1];
1624+ screenZ = HUD_myweapon_z[1];
1625+ }
1626+
16221627 ResetWorldTransform();
16231628
16241629 glMatrixMode(GL_MODELVIEW);
16251630
1626- glTranslatef(camera_x*-1, camera_y, camera_z);
1631+ //モデルビュー行列・透視投影行列・ビューポートを取得
1632+ glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
1633+ glGetDoublev(GL_PROJECTION_MATRIX, projection);
1634+ glGetIntegerv(GL_VIEWPORT, viewport);
1635+
1636+ //スクリーン座標からオブジェクト座標を求める
1637+ gluUnProject(screenX, screenY, screenZ, modelview, projection, viewport, &objX, &objY, &objZ);
1638+
1639+ //size = size * 0.3f;
1640+ size = size * (0.0004f*SCREEN_HEIGHT*SCREEN_HEIGHT - 0.92f*SCREEN_HEIGHT + 650.0f) / 1000.f;
1641+
1642+ //行列計算
1643+ glTranslated(objX, objY, objZ);
16271644 glRotatef(camera_rx*(180.0f/(float)M_PI), 0.0f, 1.0f, 0.0f);
16281645 glRotatef(camera_ry*-1*(180.0f/(float)M_PI), 0.0f, 0.0f, 1.0f);
1629-
16301646 if( rotation == true ){
1631- glTranslatef(HUD_myweapon_x[0]*-1, HUD_myweapon_y[0], HUD_myweapon_z[0]);
16321647 glRotatef(rx*-1*(180.0f/(float)M_PI), 0.0f, 1.0f, 0.0f);
16331648 }
16341649 else{
1635- glTranslatef(HUD_myweapon_x[1]*-1, HUD_myweapon_y[1], HUD_myweapon_z[1]);
16361650 glRotatef(180, 0.0f, 1.0f, 0.0f);
16371651 }
16381652 glScalef(size, size, size);
@@ -2159,7 +2173,10 @@
21592173 //! @param color 色
21602174 void D3DGraphics::Draw2DMSFontTextCenter(int x, int y, int w, int h, char *str, int color)
21612175 {
2162- Draw2DMSFontText(x + (SCREEN_WIDTH/2 - (StrMaxLineLen(str)*9/2)), y, str, color);
2176+ //未使用引数対策
2177+ UNREFERENCED_PARAMETER(h);
2178+
2179+ Draw2DMSFontText(x + (w/2 - (StrMaxLineLen(str)*9/2)), y, str, color);
21632180 }
21642181
21652182 //! @brief 2D描画用設定
--- trunk/d3dgraphics.h (revision 154)
+++ trunk/d3dgraphics.h (revision 155)
@@ -176,9 +176,9 @@
176176 VERTEXTXTA g_pVertices[MAX_BLOCKS][6][4]; //!< 頂点情報(CPU管理)
177177 #endif
178178
179- float HUD_myweapon_x[TOTAL_HAVEWEAPON]; //!< HUD_Aの武器描画 X座標
180- float HUD_myweapon_y[TOTAL_HAVEWEAPON]; //!< HUD_Aの武器描画 Y座標
181- float HUD_myweapon_z[TOTAL_HAVEWEAPON]; //!< HUD_Aの武器描画 Z座標
179+ float HUD_myweapon_x[TOTAL_HAVEWEAPON]; //!< HUDの武器描画 X座標
180+ float HUD_myweapon_y[TOTAL_HAVEWEAPON]; //!< HUDの武器描画 Y座標
181+ float HUD_myweapon_z[TOTAL_HAVEWEAPON]; //!< HUDの武器描画 Z座標
182182
183183 bool StartRenderFlag; //!< StartRender()関数 実行中を表すフラグ
184184
@@ -279,7 +279,7 @@
279279 void SetWorldTransform(float x, float y, float z, float rx, float ry1, float ry2, float size);
280280 void SetWorldTransformEffect(float x, float y, float z, float rx, float ry, float rt, float size);
281281 void SetWorldTransformHumanWeapon(float x, float y, float z, float mx, float my, float mz, float rx, float ry, float size);
282- void SetWorldTransformPlayerWeapon(bool rotation, float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, float rx, float size);
282+ void SetWorldTransformPlayerWeapon(bool rotation, float camera_rx, float camera_ry, float rx, float size);
283283 void GetWorldTransformPos(float *x, float *y, float *z);
284284 void SetFog(int skynumber);
285285 void SetCamera(float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, float viewangle);
--- trunk/gamemain.cpp (revision 154)
+++ trunk/gamemain.cpp (revision 155)
@@ -2362,13 +2362,13 @@
23622362 //(3D描画)所持している武器モデルの描画・メイン武器
23632363 GameParamInfo.GetWeapon(weapon_paramid[selectweapon], &weapon_paramdata);
23642364 Resource.GetWeaponModelTexture(weapon_paramid[selectweapon], &weaponmodel, &weapontexture);
2365- d3dg->SetWorldTransformPlayerWeapon(true, camera_x, camera_y, camera_z, camera_rx, camera_ry, DegreeToRadian(framecnt*2), weapon_paramdata.size);
2365+ d3dg->SetWorldTransformPlayerWeapon(true, camera_rx, camera_ry, DegreeToRadian(framecnt*2), weapon_paramdata.size);
23662366 d3dg->RenderModel(weaponmodel, weapontexture);
23672367
23682368 //(3D描画)所持している武器モデルの描画・サブ武器
23692369 GameParamInfo.GetWeapon(weapon_paramid[notselectweapon], &weapon_paramdata);
23702370 Resource.GetWeaponModelTexture(weapon_paramid[notselectweapon], &weaponmodel, &weapontexture);
2371- d3dg->SetWorldTransformPlayerWeapon(false, camera_x, camera_y, camera_z, camera_rx, camera_ry, 0.0f, weapon_paramdata.size);
2371+ d3dg->SetWorldTransformPlayerWeapon(false, camera_rx, camera_ry, 0.0f, weapon_paramdata.size);
23722372 d3dg->RenderModel(weaponmodel, weapontexture);
23732373 }
23742374
--- trunk/gamemain.h (revision 154)
+++ trunk/gamemain.h (revision 155)
@@ -32,9 +32,9 @@
3232 #ifndef GAMEMAIN_H
3333 #define GAMEMAIN_H
3434
35-#define MAINMENU_X 280 //!< メニューの表示 X座標(左上基準)
36-#define MAINMENU_Y 140 //!< メニューの表示 Y座標(〃)
37-#define TOTAL_MENUITEMS 8 //!< メニュー1画面に表示するミッション数
35+#define MAINMENU_X (SCREEN_WIDTH - 360) //!< メニューの表示 X座標(左上基準)
36+#define MAINMENU_Y (SCREEN_HEIGHT - 340) //!< メニューの表示 Y座標(〃)
37+#define TOTAL_MENUITEMS 8 //!< メニュー1画面に表示するミッション数
3838 #define MAINMENU_H (TOTAL_MENUITEMS+2)*30 + 25 //!< メニューの表示サイズ・高さ
3939
4040 #define HUDA_WEAPON_POSX (SCREEN_WIDTH - 255) //!< 武器情報を描画する領域・X座標