X operations(XOPS)に非常に近いFPSゲームを制作・リメイクし、成果物をオープンソースとして公開することを目的としたプロジェクトです。
| Revision | 230 (tree) |
|---|---|
| Time | 2020-01-04 12:27:23 |
| Author | |
コンソールのコマンドを1個追加(fog)
| @@ -53,6 +53,7 @@ | ||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | StartRenderFlag = false; |
| 56 | + EnableFogFlag = false; | |
| 56 | 57 | |
| 57 | 58 | //ptextsprite = NULL; |
| 58 | 59 | pxmsfont = NULL; |
| @@ -295,16 +296,6 @@ | ||
| 295 | 296 | pd3dDevice->LightEnable(0, FALSE); |
| 296 | 297 | pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); |
| 297 | 298 | |
| 298 | - //フォグ | |
| 299 | - float fog_st = 100; | |
| 300 | - float fog_end = 800; | |
| 301 | - pd3dDevice->SetRenderState(D3DRS_FOGENABLE, TRUE); | |
| 302 | - pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_RGBA(0, 0, 0, 0)); | |
| 303 | - pd3dDevice->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); | |
| 304 | - pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_NONE); | |
| 305 | - pd3dDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&fog_st)); | |
| 306 | - pd3dDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&fog_end)); | |
| 307 | - | |
| 308 | 299 | // テクスチャフィルタを使う |
| 309 | 300 | pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); |
| 310 | 301 | pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); |
| @@ -351,6 +342,10 @@ | ||
| 351 | 342 | |
| 352 | 343 | //テクスチャフォント用画像を取得 |
| 353 | 344 | TextureFont = LoadTexture(TextureFontFname, true, false); |
| 345 | + | |
| 346 | + //フォグは再度初期化 | |
| 347 | + EnableFogFlag = false; | |
| 348 | + | |
| 354 | 349 | return 0; |
| 355 | 350 | } |
| 356 | 351 |
| @@ -1027,23 +1022,44 @@ | ||
| 1027 | 1022 | } |
| 1028 | 1023 | |
| 1029 | 1024 | //! @brief フォグを設定 |
| 1025 | +//! @param enablefog フォグ有効化 | |
| 1030 | 1026 | //! @param skynumber 空の番号 |
| 1031 | -void D3DGraphics::SetFog(int skynumber) | |
| 1027 | +void D3DGraphics::SetFog(bool enablefog, int skynumber) | |
| 1032 | 1028 | { |
| 1033 | - D3DCOLOR skycolor; | |
| 1029 | + if( enablefog == true ){ | |
| 1030 | + if( EnableFogFlag == false ){ | |
| 1031 | + //フォグ | |
| 1032 | + float fog_st = 100; | |
| 1033 | + float fog_end = 800; | |
| 1034 | + pd3dDevice->SetRenderState(D3DRS_FOGENABLE, TRUE); | |
| 1035 | + pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_RGBA(0, 0, 0, 0)); | |
| 1036 | + pd3dDevice->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); | |
| 1037 | + pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_NONE); | |
| 1038 | + pd3dDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&fog_st)); | |
| 1039 | + pd3dDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&fog_end)); | |
| 1040 | + } | |
| 1034 | 1041 | |
| 1035 | - //空の番号により色を決定 | |
| 1036 | - switch(skynumber){ | |
| 1037 | - case 1: skycolor = D3DCOLOR_RGBA(64, 64+16, 64, 0); break; | |
| 1038 | - case 2: skycolor = D3DCOLOR_RGBA(16, 16, 16, 0); break; | |
| 1039 | - case 3: skycolor = D3DCOLOR_RGBA(0, 16, 32, 0); break; | |
| 1040 | - case 4: skycolor = D3DCOLOR_RGBA(32, 16, 16, 0); break; | |
| 1041 | - case 5: skycolor = D3DCOLOR_RGBA(64, 32, 32, 0); break; | |
| 1042 | - default: skycolor = D3DCOLOR_RGBA(0, 0, 0, 0); break; | |
| 1042 | + D3DCOLOR skycolor; | |
| 1043 | + | |
| 1044 | + //空の番号により色を決定 | |
| 1045 | + switch(skynumber){ | |
| 1046 | + case 1: skycolor = D3DCOLOR_RGBA(64, 64+16, 64, 0); break; | |
| 1047 | + case 2: skycolor = D3DCOLOR_RGBA(16, 16, 16, 0); break; | |
| 1048 | + case 3: skycolor = D3DCOLOR_RGBA(0, 16, 32, 0); break; | |
| 1049 | + case 4: skycolor = D3DCOLOR_RGBA(32, 16, 16, 0); break; | |
| 1050 | + case 5: skycolor = D3DCOLOR_RGBA(64, 32, 32, 0); break; | |
| 1051 | + default: skycolor = D3DCOLOR_RGBA(0, 0, 0, 0); break; | |
| 1052 | + } | |
| 1053 | + | |
| 1054 | + //フォグを設定 | |
| 1055 | + pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, skycolor); | |
| 1056 | + | |
| 1057 | + EnableFogFlag = true; | |
| 1043 | 1058 | } |
| 1044 | - | |
| 1045 | - //フォグを設定 | |
| 1046 | - pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, skycolor); | |
| 1059 | + else{ | |
| 1060 | + pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); | |
| 1061 | + EnableFogFlag = false; | |
| 1062 | + } | |
| 1047 | 1063 | } |
| 1048 | 1064 | |
| 1049 | 1065 | //! @brief カメラ(視点)を設定 |
| @@ -1890,30 +1890,36 @@ | ||
| 1890 | 1890 | } |
| 1891 | 1891 | |
| 1892 | 1892 | //! @brief フォグを設定 |
| 1893 | +//! @param enablefog フォグ有効化 | |
| 1893 | 1894 | //! @param skynumber 空の番号 |
| 1894 | -void D3DGraphics::SetFog(int skynumber) | |
| 1895 | +void D3DGraphics::SetFog(bool enablefog, int skynumber) | |
| 1895 | 1896 | { |
| 1896 | - float fogColor[4]; | |
| 1897 | + if( enablefog == true ){ | |
| 1898 | + float fogColor[4]; | |
| 1897 | 1899 | |
| 1898 | - //空の番号により色を決定 | |
| 1899 | - switch(skynumber){ | |
| 1900 | - case 1: fogColor[0] = 0.25f; fogColor[1] = 0.25f+0.0625; fogColor[2] = 0.25f; fogColor[3] = 1.0f; break; | |
| 1901 | - case 2: fogColor[0] = 0.0625; fogColor[1] = 0.0625; fogColor[2] = 0.0625; fogColor[3] = 1.0f; break; | |
| 1902 | - case 3: fogColor[0] = 0.0f; fogColor[1] = 0.0625; fogColor[2] = 0.125; fogColor[3] = 1.0f; break; | |
| 1903 | - case 4: fogColor[0] = 0.125; fogColor[1] = 0.0625; fogColor[2] = 0.0625; fogColor[3] = 1.0f; break; | |
| 1904 | - case 5: fogColor[0] = 0.25f; fogColor[1] = 0.125; fogColor[2] = 0.125; fogColor[3] = 1.0f; break; | |
| 1905 | - default: fogColor[0] = 0.0f; fogColor[1] = 0.0f; fogColor[2] = 0.0f; fogColor[3] = 1.0f; break; | |
| 1906 | - } | |
| 1900 | + //空の番号により色を決定 | |
| 1901 | + switch(skynumber){ | |
| 1902 | + case 1: fogColor[0] = 0.25f; fogColor[1] = 0.25f+0.0625; fogColor[2] = 0.25f; fogColor[3] = 1.0f; break; | |
| 1903 | + case 2: fogColor[0] = 0.0625; fogColor[1] = 0.0625; fogColor[2] = 0.0625; fogColor[3] = 1.0f; break; | |
| 1904 | + case 3: fogColor[0] = 0.0f; fogColor[1] = 0.0625; fogColor[2] = 0.125; fogColor[3] = 1.0f; break; | |
| 1905 | + case 4: fogColor[0] = 0.125; fogColor[1] = 0.0625; fogColor[2] = 0.0625; fogColor[3] = 1.0f; break; | |
| 1906 | + case 5: fogColor[0] = 0.25f; fogColor[1] = 0.125; fogColor[2] = 0.125; fogColor[3] = 1.0f; break; | |
| 1907 | + default: fogColor[0] = 0.0f; fogColor[1] = 0.0f; fogColor[2] = 0.0f; fogColor[3] = 1.0f; break; | |
| 1908 | + } | |
| 1907 | 1909 | |
| 1908 | - float fog_st = 100; | |
| 1909 | - float fog_end = 800; | |
| 1910 | - glFogi(GL_FOG_MODE, GL_LINEAR); | |
| 1911 | - glFogfv(GL_FOG_COLOR, fogColor); | |
| 1912 | - glHint(GL_FOG_HINT, GL_NICEST); | |
| 1913 | - glFogf(GL_FOG_START, fog_st); | |
| 1914 | - glFogf(GL_FOG_END, fog_end); | |
| 1910 | + float fog_st = 100; | |
| 1911 | + float fog_end = 800; | |
| 1912 | + glFogi(GL_FOG_MODE, GL_LINEAR); | |
| 1913 | + glFogfv(GL_FOG_COLOR, fogColor); | |
| 1914 | + glHint(GL_FOG_HINT, GL_NICEST); | |
| 1915 | + glFogf(GL_FOG_START, fog_st); | |
| 1916 | + glFogf(GL_FOG_END, fog_end); | |
| 1915 | 1917 | |
| 1916 | - glEnable(GL_FOG); | |
| 1918 | + glEnable(GL_FOG); | |
| 1919 | + } | |
| 1920 | + else{ | |
| 1921 | + glDisable(GL_FOG); | |
| 1922 | + } | |
| 1917 | 1923 | } |
| 1918 | 1924 | |
| 1919 | 1925 | //! @brief カメラ(視点)を設定 |
| @@ -181,11 +181,12 @@ | ||
| 181 | 181 | float HUD_myweapon_z[TOTAL_HAVEWEAPON]; //!< HUDの武器描画 Z座標 |
| 182 | 182 | |
| 183 | 183 | bool StartRenderFlag; //!< StartRender()関数 実行中を表すフラグ |
| 184 | + bool EnableFogFlag; //!< フォグ使用中を表すフラグ | |
| 184 | 185 | |
| 185 | - LPD3DXSPRITE ptextsprite; //!< 2Dテクスチャスプライト | |
| 186 | - LPD3DXFONT pxmsfont; //!< システムフォント | |
| 186 | + LPD3DXSPRITE ptextsprite; //!< 2Dテクスチャスプライト | |
| 187 | + LPD3DXFONT pxmsfont; //!< システムフォント | |
| 187 | 188 | char TextureFontFname[_MAX_PATH]; //!< テクスチャフォントのファイル名 |
| 188 | - int TextureFont; //!< テクスチャフォントのテクスチャID | |
| 189 | + int TextureFont; //!< テクスチャフォントのテクスチャID | |
| 189 | 190 | |
| 190 | 191 | int InitSubset(); |
| 191 | 192 | void CleanupD3Dresource(); |
| @@ -287,7 +288,7 @@ | ||
| 287 | 288 | void SetWorldTransformHumanWeapon(float x, float y, float z, float mx, float my, float mz, float rx, float ry, float size); |
| 288 | 289 | void SetWorldTransformPlayerWeapon(bool rotation, float camera_rx, float camera_ry, float rx, float size); |
| 289 | 290 | void GetWorldTransformPos(float *x, float *y, float *z); |
| 290 | - void SetFog(int skynumber); | |
| 291 | + void SetFog(bool enablefog, int skynumber); | |
| 291 | 292 | void SetCamera(float camera_x, float camera_y, float camera_z, float camera_rx, float camera_ry, float viewangle); |
| 292 | 293 | void LoadMapdata(class BlockDataInterface* in_blockdata, char *directory); |
| 293 | 294 | void RenderMapdata(bool wireframe); |
| @@ -339,7 +339,7 @@ | ||
| 339 | 339 | int skymodel, skytexture; |
| 340 | 340 | |
| 341 | 341 | //フォグとカメラを設定 |
| 342 | - d3dg->SetFog(1); | |
| 342 | + d3dg->SetFog(true, 1); | |
| 343 | 343 | d3dg->SetCamera(camera_x, camera_y, camera_z, camera_rx, camera_ry, VIEWANGLE_NORMAL); |
| 344 | 344 | |
| 345 | 345 | //カメラ座標に背景空を描画 |
| @@ -751,7 +751,7 @@ | ||
| 751 | 751 | void mainmenu::Render3D() |
| 752 | 752 | { |
| 753 | 753 | //フォグとカメラを設定 |
| 754 | - d3dg->SetFog(0); | |
| 754 | + d3dg->SetFog(true, 0); | |
| 755 | 755 | d3dg->SetCamera(camera_x, camera_y, camera_z, camera_rx, camera_ry, VIEWANGLE_NORMAL); |
| 756 | 756 | |
| 757 | 757 | //Zバッファを初期化 |
| @@ -1692,6 +1692,7 @@ | ||
| 1692 | 1692 | //プレイヤーの向きを取得 |
| 1693 | 1693 | ObjMgr.GetPlayerHumanObject()->GetRxRy(&mouse_rx, &mouse_ry); |
| 1694 | 1694 | |
| 1695 | + FogFlag = true; | |
| 1695 | 1696 | view_rx = 0.0f; |
| 1696 | 1697 | view_ry = 0.0f; |
| 1697 | 1698 | add_camera_rx = 0.0f; |
| @@ -2547,7 +2548,7 @@ | ||
| 2547 | 2548 | human *myHuman = ObjMgr.GetPlayerHumanObject(); |
| 2548 | 2549 | |
| 2549 | 2550 | //フォグとカメラを設定 |
| 2550 | - d3dg->SetFog(SkyNumber); | |
| 2551 | + d3dg->SetFog(FogFlag, SkyNumber); | |
| 2551 | 2552 | if( (Camera_F1mode == false)&&(Camera_Debugmode == false) ){ |
| 2552 | 2553 | int scopemode = myHuman->GetScopeMode(); |
| 2553 | 2554 |
| @@ -3394,7 +3395,7 @@ | ||
| 3394 | 3395 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "help human result event ver"); |
| 3395 | 3396 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "config mif bd1 pd1 resinfo"); |
| 3396 | 3397 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "info view center map aiinfo <NUM>"); |
| 3397 | - AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "tag radar inmap sky <NUM> dark"); | |
| 3398 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "tag radar inmap sky <NUM> dark fog"); | |
| 3398 | 3399 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "ff revive kill <NUM> treat <NUM> nodamage <NUM>"); |
| 3399 | 3400 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "newobj <NUM> break <NUM> delhuman <NUM> delweapon <NUM> delobj <NUL>"); |
| 3400 | 3401 | AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "nofight caution ailevel <NUM> bot stop estop"); |
| @@ -3957,6 +3958,19 @@ | ||
| 3957 | 3958 | d3dg->LoadMapdata(&BlockData, path); |
| 3958 | 3959 | } |
| 3959 | 3960 | |
| 3961 | + //フォグ切り替え | |
| 3962 | + if( strcmp(NewCommand, "fog") == 0 ){ | |
| 3963 | + //フラグ切り替え | |
| 3964 | + if( FogFlag == false ){ | |
| 3965 | + FogFlag = true; | |
| 3966 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "Enable Fog Flag."); | |
| 3967 | + } | |
| 3968 | + else{ | |
| 3969 | + FogFlag = false; | |
| 3970 | + AddInfoConsole(d3dg->GetColorCode(1.0f,1.0f,1.0f,1.0f), "Disable Fog Flag."); | |
| 3971 | + } | |
| 3972 | + } | |
| 3973 | + | |
| 3960 | 3974 | //全ての死者を蘇生する |
| 3961 | 3975 | if( strcmp(NewCommand, "revive") == 0 ){ |
| 3962 | 3976 | for(int i=0; i<MAX_HUMAN; i++){ |
| @@ -217,6 +217,7 @@ | ||
| 217 | 217 | //class EventControl Event[TOTAL_EVENTLINE]; //!< イベント制御クラス |
| 218 | 218 | int SkyNumber; //!< 背景空番号 |
| 219 | 219 | bool DarkScreenFlag; //!< 画面を暗く |
| 220 | + bool FogFlag; //!< フォグ有効 | |
| 220 | 221 | float mouse_rx; //!< マウスによる水平軸角度 |
| 221 | 222 | float mouse_ry; //!< マウスによる垂直軸角度 |
| 222 | 223 | float view_rx; //!< マウス角度とカメラ角度の差(水平軸) |