飞飞世界论坛
标题: 昼夜系统 [打印本页]
作者: admin 时间: 2016-1-10 03:46
标题: 昼夜系统
1.
4 l0 Z2 O7 J( Q6 c+ J! ]3 S' I+ _7 i P你走在 world.h% r x5 v+ d! C" e% _# ]7 m8 V. {
晚上搜索
Code:
public:
BOOL InitWorldEnvir(); // 24½Ã°£ Light ¼3ᤠ1×±aŸ èˉ°æ Ãê±aè*
#if __VER >= 15// __GUILD_HOUSE
void InProcessing(); // gmpbigsun : Çöàç¿ùμå·Î áøàԽà ÇÑ1ø è£Ãaμê
void OutProcessing(); // gmpibgsun : Çöàç¿ùμå¿¡¼* Åeàå½Ã ÇÑ1ø è£Ãaμê
#endif
// Render
void Projection(LPDIRECT3DDEVICE9 pd3dDevice, int nWidth, int nHeight );
void Render(LPDIRECT3DDEVICE9 pd3dDevice, CD3DFont* pFont = NULL );
void RenderBase(LPDIRECT3DDEVICE9 pd3dDevice, CD3DFont* pFont );
// Light, Camera and etc...
) q5 B( @* Y( t1 P3 X5 F- j% q
下面插入
Code:
bool IsNight();
FLOAT GetRealTime();
6 y( y3 `! Q2 ^# h0 o然后你进入
$ Z( s3 A6 k3 @6 @' \World3D.cpp
搜索
Code:
// Ä«¸T¶ó Ãæμ1üũ½Ã¿¡¸¸ ¾2′Âμí..
BOOLCWorld::CheckBound(D3DXVECTOR3* vPos,D3DXVECTOR3* vDest,D3DXVECTOR3* vOut,FLOAT* fLength )
{
D3DXVECTOR3 tempVec=(*(vPos)-*(vDest));///10.0f;
floatlength=D3DXVec3Length(&tempVec);
D3DXVec3Normalize(&tempVec,&tempVec);
tempVec/=10;
D3DXVECTOR3 tempVec2=*(vDest);
D3DXVECTOR3 vDist1, vDist2;
float tempheight;
BOOL b1,b2;
b1 = FALSE; b2 = FALSE;
tempVec2 += (tempVec * 10); // Ä«¸T¶ó°¡ àú2ù áöÇü¿¡ 2¸μé¾î°¡¼* á»»°′ù.
BOOL bWaterChkDn = FALSE;
BOOL bWaterChkUp = FALSE;
FLOAT fWaterHeight = 0.0f;
LPWATERHEIGHT pWaterHeight =GetWaterHeight( *vDest );
if( pWaterHeight &&
( pWaterHeight->byWaterTexture& (byte)(~MASK_WATERFRAME)) == WTYPE_WATER )
{
fWaterHeight =(FLOAT)pWaterHeight->byWaterHeight;
//vDest->y += 0.5f;
if( fWaterHeight < vDest->y)
{
bWaterChkDn = TRUE;
}
else
{
bWaterChkUp = TRUE;
}
}
for( int i = 0; i < int( length * 10 );i++ )
{
tempVec2+=tempVec;
tempheight=GetLandHeight(tempVec2.x, tempVec2.z );
#if __VER >= 11 //__FIX_PICKING
// Ä«¸T¶ó¸| ¾à°£ ′õ μé¾îáÖ±aà§Çؼ* ¼öᤠ- 07.10.24 - micky
if(tempVec2.y<tempheight+0.6f)
#else
if(tempVec2.y<tempheight+0.3f)
#endif
{
b1 = TRUE;
vDist1 = tempVec2 -*vDest; // »ç¶÷¿¡¼* ±3Â÷ᡱîáöàÇ1æÇao¤Åí
// *(vOut)=tempVec2;
// vOut->y+=1.1f;
// return TRUE;
break;
}
// Äé¸ˉÅí°¡ 1°à§¿¡ àÖ°í, àá±aáö¾ê¾ò′ù¸é ¼ö¸é Ãæμ1üũÇÏ¿© Ä«¸T¶ó°¡ 1°¼óืΠ¾èμé¾î°¡°Ô Ã3¸®ÇÔ.
D3DXVECTOR3 vWaterVec = tempVec2;
//vWaterVec.y+=0.5f;
if( bWaterChkDn )
{
if(vWaterVec.y<fWaterHeight+0.3f)
{
b1 = TRUE;
vDist1 =vWaterVec - *vDest;
break;
}
}
#if __VER < 10
else
// Äé¸ˉÅí°¡ 1°à§¿¡ àÖ°í, àá°å′ù¸é¼ö¸é Ãæμ1üũÇÏ¿© Ä«¸T¶ó°¡ 1°1ÛืΠ¸ø3a°¡°Ô Ã3¸®ÇÔ
if( bWaterChkUp )
{
if(vWaterVec.y>fWaterHeight-0.3f)
{
b1 = TRUE;
vDist1 =vWaterVec - *vDest;
break;
}
}
#endif
}
D3DXVECTOR3 vIntersect;
BOOL bRet = IntersectObjLine2(&vIntersect, *vDest, *vPos, TRUE );
if( bRet )
{
b2 = TRUE;
vDist2 = vIntersect - *vDest; // »ç¶÷¿¡¼* ±3Â÷ᡱîáöàÇ 1æÇao¤Åí
// *vOut = vIntersect;
}
FLOAT fDist1,fDist2;
if( b1 == TRUE && b2 == TRUE ) // áöÇüàì¶û ¿àoêá§Æ® ¸eμÎ ±3Â÷Çß′ù
{
fDist1 = D3DXVec3LengthSq(&vDist1 );
fDist2 = D3DXVec3LengthSq(&vDist2 );
if( fDist1 < fDist2 ) // ±×áß °¡±î¿î3eืΠ¾¸
{
*fLength =D3DXVec3Length( &vDist1 );
*vOut = tempVec2;
}
else
{
*fLength =D3DXVec3Length( &vDist2 );
*vOut= vIntersect;
}
return TRUE;
} else
if( b1 ) //áöÇü¿¡¸¸ oÎμúÇû′ù.
{
*fLength = D3DXVec3Length(&vDist1 );
*vOut = tempVec2;
return TRUE;
} else
if( b2 ) //¿àoêá§Æ®¿¡¸¸ oÎμúÇû′ù
{
*fLength = D3DXVec3Length(&vDist2 );
*vOut = vIntersect;
return TRUE;
}
// ¾Æ1«μ¥μμ oÎμúè÷áö ¾ê¾ò′ù.
*fLength = length;
return FALSE;
}
: m" F( ?" @& Z" n/ p
下面插入
Code:
#ifdef __CLIENT
boolCWorld::IsNight(){
return (g_GameTimer.m_nHour-1 <= 6 || g_GameTimer.m_nHour-1 >= 18 );
}
FLOATCWorld::GetRealTime()
{
FLOAT nRlTime = 0;
nRlTime =(FLOAT)(g_GameTimer.m_nHour-1)*2;
if(g_GameTimer.m_nMin < 30 )
--nRlTime;
if(g_GameTimer.m_nHour-1 == 23 && g_GameTimer.m_nMin > 45 )
nRlTime+=0.5F;
if( nRlTime >24 )
{
return((-1)*(nRlTime - 48 ));
}
return nRlTime;
}
#endif
8 y, a( P/ t+ G& R s$ A5 \
dadrunter set ihr
Code:
voidCWorld::SetLight( BOOL bLight )
4 r+ R) _8 m: \4 d在这个函数研究了
Code:
pLight->SetDir(m_v3LightDir.x, m_v3LightDir.y, m_v3LightDir.z );
pLight->Appear(m_pd3dDevice, TRUE );
DWORD dwR, dwG, dwB;
dwR = (DWORD)(pLight->Ambient.r * 255 );
dwG = (DWORD)(pLight->Ambient.g * 255 );
dwB = (DWORD)(pLight->Ambient.b * 255 );
dwAmbient =D3DCOLOR_ARGB( 255, dwR, dwG, dwB );
}
}
else
{
" f8 H+ K3 |. ?. j1 S; g) @5 |
后面添加
Code:
#ifdef __DAY_NIGHT
if( !m_bIsIndoor){
m_fFogStartValue =10.0F;
m_fFogEndValue = 70.0F + GetRealTime() * 30.0F;
m_fFogDensity = 0.0F;
m_v3LightDir.x = 0.0F;
m_v3LightDir.y = -1.0F;
m_v3LightDir.z = 0.0F;
}
#endif //__DAY_NIGHT
; p" _" Z% X# s4 h现在你搜索
Code:
if( m_bIsIndoor )
{
if( pLight )
{
// ཿμ oˉè*
pLight->Diffuse.r =((m_dwDiffuse>>16) & 0xff) / 255.f;
pLight->Diffuse.g =((m_dwDiffuse>>8) & 0xff) /255.f;
pLight->Diffuse.b =((m_dwDiffuse) & 0xff) / 255.f;
6 ]& `* W( `$ S' F5 A
后面补充
Code:
if( m_bIsIndoor
#ifdef __DAY_NIGHT
|| IsNight()
#endif //__DAY_NIGHT
)
{
if( pLight )
{
// ཿμ oˉè*
pLight->Diffuse.r =((m_dwDiffuse>>16) & 0xff) / 255.f;
pLight->Diffuse.g =((m_dwDiffuse>>8) & 0xff) /255.f;
pLight->Diffuse.b =((m_dwDiffuse) & 0xff) / 255.f;
# m% a1 a: x6 V( [- v% y9 ]1 l然后在
neuz/versioncommon.h- o" C2 p- Y* l; h) E9 U
添加定义:
Code:
#define__DAY_NIGHT
2 O1 w# y4 I. P: p8 v& J8 rFertig. {* @% I P2 o, J8 ^4 w- O
8 ]5 Y1 V7 ?+ u4 F
+ H+ t6 v# h) R* H& [" b! F
欢迎光临 飞飞世界论坛 (http://ffwold.com/) |
Powered by Discuz! X3.2 |