int CWndWorld::ControlFlying( DWORD dwMessage, CPoint point ) { static float fTurnAngle = 0.0f; static BOOL s_bTraceKeyed = 0, s_bSelectKeyed = 0, s_bTurbo2 = 0; // static BOOL s_bFastTurn; int nMsg = 0; // BOOL bFlyKey; BOOL bUp, bDown, bLeft, bRight; BOOL bAcc = FALSE; BOOL bTurbo; // BOOL bFastTurn = FALSE; BYTE nFrame = MAX_CORR_SIZE_150; CMover* pMover = CMover::GetActiveMover(); bUp = g_bKeyTable[g_Neuz.Key.chUp]; bDown = g_bKeyTable['S']; // 좌/우 회전 bLeft = g_bKeyTable[g_Neuz.Key.chLeft]; bRight = g_bKeyTable['D']; // 급선회. // bFastTurn = g_bKeyTable[ VK_SHIFT ]; // CMover* pMoverTarget = (CMover*)g_WorldMng.Get()->GetObjFocus() ; // 가속 상태면 전진 명령 계속 보냄 bool fMoved = false; bool fBehavior = false; if( pMover->m_pActMover->IsStateFlag( OBJSTAF_ACC ) ) { if( pMover->SendActMsg( OBJMSG_FORWARD ) == 1 ) { fMoved = true; } } else { if( pMover->SendActMsg( OBJMSG_STAND ) == 1 ) { fMoved = true; } } // bAcc = g_bKeyTable[VK_SPACE]; if( bAcc && !s_bAccKeyed ) // 키 누른순간에만 토글시킴. { if( pMover->m_pActMover->IsStateFlag( OBJSTAF_ACC ) ) // 가속중이었다면 { pMover->SendActMsg( OBJMSG_ACC_STOP ); // 가속 멈춤 if( pMover->m_pActMover->IsActTurn() ) { fMoved = true; } } else { // 가속중이 아니었다면 가속 시킴. if( pMover->SendActMsg( OBJMSG_ACC_START ) == 0 ) g_WndMng.PutString( prj.GetText( TID_GAME_AIRFUELEMPTY ) ); else { if( pMover->SendActMsg( OBJMSG_FORWARD ) == 1 ) fMoved = true; } } } s_bAccKeyed = bAcc; bTurbo = g_bKeyTable[g_Neuz.Key.chWalk]; if( bTurbo && !s_bTurbo2 ) // 토글 방식. { if( pMover->m_pActMover->IsStateFlag( OBJSTAF_TURBO ) ) { if( pMover->SendActMsg( OBJMSG_MODE_TURBO_OFF ) == 1 ) fMoved = true; } else { if( pMover->SendActMsg( OBJMSG_MODE_TURBO_ON ) == 1 ) fMoved = true; } } s_bTurbo2 = bTurbo; if( pMover->m_pActMover->IsFly() ) { if( g_bKeyTable[g_Neuz.Key.chTrace] && !s_bTraceKeyed ) { CCtrl* pFocusObj = (CCtrl*)(pMover->GetWorld()->GetObjFocus()); if( pFocusObj && pFocusObj->GetType() == OT_MOVER ) { CMover* pFocusMover = (CMover*)pFocusObj; if( pMover->m_dwFlag & MVRF_TRACKING ) // 이미 실행중이면 해제. { pMover->m_dwFlag &= (~MVRF_TRACKING); // 추적모드해제. pMover->m_idTracking = NULL_ID; } else { // 비행중 추적모드. pMover->m_dwFlag |= MVRF_TRACKING; // 추적모드. pMover->m_idTracking = pFocusMover->GetId(); } } else { // 타겟이 없을때 Z키를 누르면 자동추적이 풀린다. pMover->m_dwFlag &= (~MVRF_TRACKING); // 추적모드해제. pMover->m_idTracking = NULL_ID; } } s_bTraceKeyed = g_bKeyTable[g_Neuz.Key.chTrace]; // 타겟선택 키 if( g_bKeyTable[VK_TAB] && !s_bSelectKeyed ) { if( m_aFlyTarget.GetSize() > 0 ) // 선택된 타겟있을때. { if( m_nSelect >= m_aFlyTarget.GetSize() ) m_nSelect = 0; OBJID idSelect = m_aFlyTarget.GetAt( m_nSelect++ ); CMover *pSelectMover = prj.GetMover( idSelect ); if( IsValidObj(pSelectMover) ) { CWorld *pWorld = pMover->GetWorld(); if( pWorld ) { pWorld->SetObjFocus( pSelectMover ); // 이놈을 타겟으로 설정함. pMover->m_idTracking = pSelectMover->GetId(); // 탭으로 타겟을 바꾸면 자동추적타겟도 그놈으로 바뀐다. } } } } s_bSelectKeyed = g_bKeyTable[VK_TAB]; } if( /*m_bFlyMove &&*/ m_bLButtonDown || g_bKeyTable[VK_INSERT] ) // 192 = ` { CObj *pObj = pMover->GetWorld()->GetObjFocus(); // 타겟잡힌놈이 있을때만 휘두를수 있다. if( pObj && pObj->GetType() == OT_MOVER ) { if( pMover->IsAttackAble( pObj ) ) // 공격 가능한지 검사. { OBJID idTarget = ((CMover *)pObj)->GetId(); ItemProp *pWeapon = pMover->GetActiveHandItemProp(); if( pWeapon ) { g_pPlayer->PlayCombatMusic(); if( pWeapon->dwItemKind3 == IK3_WAND ) { D3DXVECTOR3 vFront, vTarget; AngleToVector( &vFront, g_pPlayer->GetAngle(), -g_pPlayer->GetAngleX(), 1.0f ); vTarget = pObj->GetPos() - g_pPlayer->GetPos(); D3DXVec3Normalize( &vTarget, &vTarget ); // 타겟쪽으로의 벡터의 유닛벡터. FLOAT fDot = D3DXVec3Dot( &vFront, &vTarget ); if( fDot >= cosf(D3DXToRadian(60.0f)) ) // 타겟이 내가 보는 방향의 +-30도 안에 있으면 발사할수 있다. { if( pMover->IsRangeObj( pObj, 64.0f ) ) // 사정거리에 들어오면 발사. { pMover->DoAttackMagic( pObj, 0 ); } } } else { pMover->SendActMsg( OBJMSG_ATK1, idTarget ); } } } } } // fTurnAngle = 0.6f; ItemProp* pItemProp = prj.GetItemProp( g_pPlayer->GetRideItemIdx() ); if( pItemProp ) { fTurnAngle = pItemProp->fFlightLRAngle; } else { Error( "ControlFlying : 빗자루정보 읽기 실패 %d", g_pPlayer->GetRideItemIdx() ); fTurnAngle = 0.6f; } if( bUp ) { if( g_WorldMng.Get()->GetFullHeight( pMover->GetPos() ) < pMover->GetPos().y ) { if( pMover->SendActMsg( OBJMSG_LOOKDOWN ) == 1 ) { fMoved = true; } } } else if( bDown ) { if( pMover->SendActMsg( OBJMSG_LOOKUP ) == 1 ) { fMoved = true; } } else { if( pMover->SendActMsg( OBJMSG_STOP_LOOK ) == 1 ) { fMoved = true; } } if( bLeft ) { m_fRollAng -= 1.0f; if( m_fRollAng < -45.0f ) m_fRollAng = -45.0f; if( pMover->SendActMsg( OBJMSG_LTURN, (int)( fTurnAngle * 100.0f ) ) == 1 ) { fMoved = true; } } else if( bRight ) { m_fRollAng += 1.0f; if( m_fRollAng > 45.0f ) m_fRollAng = 45.0f; if( pMover->SendActMsg( OBJMSG_RTURN, (int)( fTurnAngle * 100.0f ) ) == 1 ) { fMoved = true; } } else { if( m_fRollAng < 0 ) { m_fRollAng += 2.0f; if( m_fRollAng > 0 ) m_fRollAng = 0; } else if( m_fRollAng > 0 ) { m_fRollAng -= 2.0f; if( m_fRollAng < 0 ) m_fRollAng = 0; } if( pMover->SendActMsg( OBJMSG_STOP_TURN ) == 1 ) { fMoved = true; // fBehavior = true; } } // 오른쪽 버튼 드래그는 빗자루 움직임 if( dwMessage == WM_MOUSEMOVE /*&& m_bRButtonDown*/ ) { float fAng = pMover->GetAngle(); float fAdd = (point.x - m_ptMouseOld.x) / 2.0f; fAng -= fAdd; pMover->SetAngle( fAng ); float fAngX = pMover->GetAngleX(); float fAddX = (point.y - m_ptMouseOld.y) / 4.0f; fAngX += fAddX; if( fAddX > 0 && fAngX > 45.0f ) fAngX = 45.0f; else if( fAddX < 0 && fAngX < -45.0f ) fAngX = -45.0f; pMover->SetAngleX( fAngX ); if( fAdd || fAddX ) g_DPlay.PostPlayerAngle( TRUE ); } BOOL bTempKey; if( bTempKey = g_bKeyTable[ '8' ] ) { if( !m_bTemp3ed ) { pMover->SendActMsg( OBJMSG_TEMP2 ); // __bTestLOD ^= 1; } } m_bTemp3ed = bTempKey; if( fMoved ) { g_DPlay.SendPlayerMoved2( nFrame ); } if( fBehavior ) { pMover->ClearDest(); g_DPlay.SendPlayerBehavior2(); } return nMsg; }
void CActionMover::ProcessFlyMove( void ) { #ifdef __CLIENT g_nDrift = 0; // 드리프트 플랙 클리어 #endif float fLenSq = D3DXVec3LengthSq( &m_vDelta ); if( fLenSq == 0.0f && (GetStateFlag() & OBJSTAF_ACC ) == 0 ) return; // 멈춤 상태면 리턴 CMover* pMover = m_pMover; FLOAT fAccPwr = m_fAccPower; #ifdef __CLIENT ProcessFlyTracking(); #endif // client // 터보모드 처리 if( (GetStateFlag() & OBJSTAF_TURBO) && (GetStateFlag() & OBJSTAF_ACC) ) // 터보모드 & 전진중 { #ifdef __WORLDSERVER pMover->m_tmAccFuel = (int)( pMover->m_tmAccFuel - (1000.0f / (float)FRAME_PER_SEC) ); // 1/60만큼 깎음 #endif if( pMover->m_tmAccFuel <= 0 ) // 가속연료가 다 떨어지면 { pMover->m_tmAccFuel = 0; SendActMsg( OBJMSG_MODE_TURBO_OFF ); // 터보모드 중지 #ifdef __WORLDSERVER g_UserMng.AddSendActMsg( pMover, OBJMSG_MODE_TURBO_OFF ); #endif } else fAccPwr *= 1.2f; // 가속연료가 남아있다면 터보모드 } #ifdef __CLIENT ProcessFlyParticle( fLenSq ); #endif // 관성처리 if( fAccPwr > 0.0f ) { // 힘벡터 생성 FLOAT fAngX = D3DXToRadian( pMover->GetAngleX() ); FLOAT fAng = D3DXToRadian( pMover->GetAngle() ); FLOAT fDist = cosf(fAngX) * fAccPwr; D3DXVECTOR3 vAcc; vAcc.x = sinf( fAng ) * fDist; vAcc.z = -cosf( fAng ) * fDist; vAcc.y = -sinf( fAngX ) * fAccPwr; // 관성벡터와 추진력벡터가 각도가 50도 이하면 급추진 if( fLenSq > 0.01f ) { D3DXVECTOR3 vDeltaNorm, vAccNorm; D3DXVec3Normalize( &vDeltaNorm, &m_vDelta ); D3DXVec3Normalize( &vAccNorm, &vAcc ); float fDot = D3DXVec3Dot( &vDeltaNorm, &vAccNorm ); if( fDot < 0.633319f ) // 이전코드: cosf(70.0f) 값으로는 대략 50도 { vAcc *= 2.0f; m_vDelta *= 0.985f; #ifdef __CLIENT g_nDrift = 1; if( ! ( pMover->IsMode( TRANSPARENT_MODE ) ) ) // 투명상태가 아닐때만 렌더. { if( (g_nProcessCnt & 3) == 0 ) CreateSfx( g_Neuz.m_pd3dDevice, XI_NAT_DUST_RUN, pMover->GetPos() ); } #endif } } fLenSq = D3DXVec3LengthSq( &m_vDelta ); // 1/60 sec 속도 float fMaxSpeed = 0.3f; if( GetStateFlag() & OBJSTAF_TURBO ) // 터보모드에선 MAX속도가 1.1배 fMaxSpeed *= 1.1f; if( fLenSq < (fMaxSpeed * fMaxSpeed) ) // 일정이상 속도를 넘지 않게 하자. m_vDelta += vAcc; // 관성벡터 += 추진력벡터 } m_vDelta *= (1.0f - FRIC_AIR); // 마찰력에 의한 감소 // raiders - 수치적 안정성을 위해서 적은 수치가 계산되는 것을 피한다. fLenSq = D3DXVec3LengthSq( &m_vDelta ); if( m_fAccPower == 0.0f && fLenSq < 0.0002f * 0.0002f ) { fLenSq = 0; m_vDelta = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); RemoveStateFlag( OBJSTAF_ACC ); // 가속상태 해제 } #ifdef __CLIENT if( pMover->IsActiveMover() ) { g_nFlySpeed = (int)( (sqrt(fLenSq) * 60.0f) * 60.0f * 60.0f ); g_nFlySpeed = (int)( g_nFlySpeed / 200.0f ); } #endif }
void CActionMover::PresupposePos2( D3DXVECTOR3* pv, D3DXVECTOR3* pvd, float* pf, float* pfAngleX, float* pfAccPower, u_long uTickCount ) { CMover* pMover = GetMover(); D3DXVECTOR3 v = pMover->GetPos(); float fAngle = pMover->GetAngle(); D3DXVECTOR3 vDelta = m_vDelta; if( prj.GetItemProp( pMover->m_dwRideItemIdx ) == NULL ) return; float fAcc = prj.GetItemProp( pMover->m_dwRideItemIdx )->fFlightSpeed; // 무버가 타고있는 아이템의 인덱스에서 추진력을 꺼내옴. fAcc *= 0.75f; float fTheta, fThetaX, d; DWORD dwMoveState = GetMoveState(); DWORD dwTurnState = GetTurnState(); DWORD dwLookState = GetLookState(); float fX = pMover->GetAngleX(); float fAccPower = m_fAccPower; float fTurnAngle; D3DXVECTOR3 vAcc; for( u_long i = 0; i < uTickCount; i++ ) { fTheta = D3DXToRadian( fAngle ); switch( dwMoveState ) { case OBJSTA_STAND: fAccPower = 0; break; case OBJSTA_FMOVE: fAccPower = fAcc; break; } switch( dwTurnState ) { case OBJSTA_LTURN: fTurnAngle = m_fTurnAngle; if( ( GetStateFlag() & OBJSTAF_ACC ) == 0 ) fTurnAngle *= 2.5f; fAngle += fTurnAngle; if( fAngle > 360.0f ) fAngle -= 360.0f; break; case OBJSTA_RTURN: fTurnAngle = m_fTurnAngle; if( ( GetStateFlag() & OBJSTAF_ACC ) == 0 ) fTurnAngle *= 2.5f; fAngle -= fTurnAngle; if( fAngle < 0.0f ) fAngle += 360.0f; break; } switch( dwLookState ) { case OBJSTA_LOOKUP: if( fX > -45.0f ) fX -= 1.0f; break; case OBJSTA_LOOKDOWN: if( fX < 45.0f ) fX += 1.0f; break; } fThetaX = D3DXToRadian( fX ); if( GetStateFlag() & OBJSTAF_TURBO ) fAccPower *= 1.5f; d = cosf( fThetaX ) * fAccPower; fTheta = D3DXToRadian( fAngle ); vAcc.x = sinf( fTheta ) * d; vAcc.z = -cosf( fTheta ) * d; vAcc.y = -sinf( fThetaX ) * fAccPower; float fLenSq = D3DXVec3LengthSq( &vDelta ); D3DXVECTOR3 vDeltaNorm, vAccNorm; D3DXVec3Normalize( &vDeltaNorm, &vDelta ); D3DXVec3Normalize( &vAccNorm, &vAcc ); float fDot = D3DXVec3Dot( &vDeltaNorm, &vAccNorm ); if( fAccPower > 0.0f ) { if( fLenSq > 0.01f ) { if( fDot < cosf( 70.0f ) ) { vAcc *= 2.0f; vDelta *= 0.985f; } } } fLenSq = D3DXVec3Length( &vDelta ); if( fLenSq < 0.3f ) { vDelta += vAcc; } vDelta *= ( 1.0f - FRIC_AIR ); v += vDelta; if( v.y > MAX_MOVE_HEIGHT ) v.y = MAX_MOVE_HEIGHT; CWorld* pWorld = GetWorld(); pWorld->ClipX( v.x ); pWorld->ClipZ( v.z ); } *pv = v; *pf = fAngle; *pvd = vDelta; *pfAngleX = fX; *pfAccPower = fAccPower; pMover->m_nCorr = (int)uTickCount; }
void CActionMover::ProcessFlyTracking() { CMover* pMover = m_pMover; // 자동 추적 모드. g_pPlayer만 실행된다. if( pMover->IsActiveMover() && (pMover->m_dwFlag & MVRF_TRACKING) ) { static float s_fTurnAcc = 0, s_fTurnAccH = 0; { CMover *pTarget = prj.GetMover( pMover->m_idTracking ); // 추적할 목표. if( pTarget ) { D3DXVECTOR3 vDist = pTarget->GetPos() - pMover->GetPos(); // 나를 원점으로 타겟까지의 벡터. FLOAT fAngXZ, fAngH; xGetDegree( &fAngXZ, &fAngH, vDist ); // 타겟과의 각도 구함. // 남쪽이 0도 기준. 시계방향 -180까지 시계반대방향 +180 // 3도 이하는 무시. FLOAT fMoverAng = pMover->GetAngle(); if( fMoverAng > 180.0f ) // 계산하기 좋게 좌표계를 +,- 로 바꿈. fMoverAng -= 360.0f; FLOAT fSubAng = fAngXZ - fMoverAng; if( fSubAng > 180.0f ) fSubAng -= 360.0f; else if( fSubAng < -180.0f ) fSubAng += 360.0f; #ifdef _DEBUG #ifdef __XUZHU extern float _g_fReg[]; _g_fReg[1] = fSubAng; _g_fReg[2] = fAngXZ; #endif #endif if( fSubAng < -3.0f ) // 오른쪽으로 돌아야 한다. s_fTurnAcc = -2.5f; else if( fSubAng > 3.0f ) // 왼쪽으로 돌아야 한다. s_fTurnAcc = 2.5f; else s_fTurnAcc = 0; FLOAT fMoverAngX = pMover->GetAngleX(); FLOAT fSubAngH = fAngH - fMoverAngX; if( fSubAngH > 180.0f ) fSubAngH -= 360.0f; else if( fSubAngH < -180.0f ) fSubAngH += 360.0f; if( fSubAngH < -3.0f ) s_fTurnAccH = -1.5f; else if( fSubAngH > 3.0f ) s_fTurnAccH = 1.5f; else s_fTurnAccH = 0; pMover->SetAngle( pMover->GetAngle() + s_fTurnAcc ); pMover->SetAngleX( pMover->GetAngleX() + s_fTurnAccH ); if( s_fTurnAcc || s_fTurnAccH ) // 값이 달라지면 전송함. g_DPlay.PostPlayerAngle( TRUE ); } } } }
void CActionMover::ProcessFlyParticle( float fLenSq ) { CMover *pMover = m_pMover; // 운영자 투명모드때는 파티클 안나옴. if( (pMover->IsMode( TRANSPARENT_MODE ) ) == 0 ) { ItemProp* pRideProp = prj.GetItemProp( m_pMover->m_dwRideItemIdx ); // 현재 타고있는 탈것의 프로퍼티. // 비행 파티클 처리. if( fLenSq > 0.01f ) { if( (pMover->IsActiveMover() && g_Neuz.m_camera.m_fZoom > 2.0f) || pMover->IsActiveMover() == FALSE ) // 일정속도 이상이 되면 꼬리에 파티클이 나오기 시작. { int nType = 0; if( pRideProp && pRideProp->dwID == II_RID_RID_BOR_RIDINGCLOUD ) nType = 1; CreateFlyParticle( pMover, pMover->GetAngleX(), nType ); } } if( fLenSq > 0.001f ) { if( (pMover->IsActiveMover() && g_Neuz.m_camera.m_fZoom > 1.0f) || pMover->IsActiveMover() == FALSE ) { if( pRideProp && pRideProp->dwItemKind3 == IK3_BOARD ) // 보드만 꼬리가 나온다. { if( m_pTail ) { if( pRideProp->dwID == II_RID_RID_BOR_RIDINGCLOUD ) // 근두운일때 { if( m_pTail->GetType() != 2 ) // 생성되었던 꼬리고 근두운용이 아니면 m_pTail->ChangeTexture( D3DDEVICE, "etc_Tail2.bmp", 2 ); } else { if( m_pTail->GetType() != 1 ) // 생성되었던 꼬리고 일반보드용이 아니면 m_pTail->ChangeTexture( D3DDEVICE, "etc_Tail1.bmp", 1 ); // 일반보드용으로 텍스쳐 교체. } } if( m_pTail == NULL ) // 아직 할당 안됐으면 할당하고. { if( pRideProp->dwID == II_RID_RID_BOR_RIDINGCLOUD ) // 근두운... { m_pTail = (CTailEffectBelt*)g_TailEffectMng.AddEffect( g_Neuz.m_pd3dDevice, "etc_Tail2.bmp", 2 ); } else { m_pTail = (CTailEffectBelt*)g_TailEffectMng.AddEffect( g_Neuz.m_pd3dDevice, "etc_Tail1.bmp", 1 ); } } D3DXVECTOR3 vPos1, vPos2; D3DXVECTOR3 vLocal; FLOAT fAngXZ = pMover->GetAngle(); FLOAT fAngH = pMover->GetAngleX(); AngleToVectorXZ( &vLocal, fAngXZ, -1.0f ); fAngXZ -= 90.0f; if( fAngXZ < 0 ) fAngXZ += 360.0f; AngleToVector( &vPos1, fAngXZ, -fAngH, 0.5f ); vPos1 += pMover->GetPos(); vPos1 += vLocal; fAngXZ = pMover->GetAngle(); fAngH = pMover->GetAngleX(); AngleToVectorXZ( &vLocal, fAngXZ, -1.0f ); fAngXZ += 90.0f; if( fAngXZ > 360.0f ) fAngXZ -= 360.0f; AngleToVector( &vPos2, fAngXZ, -fAngH, 0.5f ); vPos2 += pMover->GetPos(); vPos2 += vLocal; if( m_pTail ) m_pTail->CreateTail( vPos1, vPos2 ); } } } } // 투명모드가 아닐때 }
void CBackCamera::Process( LPDIRECT3DDEVICE9 pd3dDevice ,float fFactor ) { #ifdef __CLIENT CMover *pMover = CMover::GetActiveMover(); // 여기서 카메라 세팅!!!!! if( pMover == NULL ) return; CWorld* pWorld = pMover->GetWorld(); if( pWorld == NULL ) return; D3DXMATRIX matView, mat; FLOAT fAngle = 0, fAngleY = 0; D3DXVECTOR3 vPos = pMover->GetPos(); vPos.y += 0.9f; #if __VER >= 13 // __HOUSING if(m_nCamMode == CM_MYROOM) { if(m_fZoom <= 0.5f) m_fZoom = 0.5f; // if(m_fZoom >= 3.0f) m_fZoom = 3.0f; } #endif // __HOUSING CMover* pMoverTarget = (CMover*)g_WorldMng.Get()->GetObjFocus() ; D3DXVECTOR3 vTarget,vTemp; if( pMoverTarget && pMover->m_pActMover->IsFly() && (pMover->m_dwFlag & MVRF_TRACKING) ) { // 날고 있는 경우 타겟이 있다면 // 타겟쪽으로 카메라 방향을 수정한다. vTemp = vPos - pMoverTarget->GetPos(); if( vTemp.z > 0 ) { fAngle =- (float)( atan( vTemp.x / vTemp.z ) * 180 / 3.1415926f ); } else { fAngle =- (float)( atan( vTemp.x / vTemp.z ) * 180 / 3.1415926f ) + 180; } D3DXVECTOR3 vDistXZ = vTemp; vDistXZ.y = 0; float fDistSq = D3DXVec3Length( &vDistXZ ); // XZ평면에서의 길이 fAngleY = atan2( fDistSq, vTemp.y/* * vTemp.y*/ ); fAngleY = D3DXToDegree( fAngleY ); float fReg1 = vTemp.y / 40.0f; if( fReg1 > 0 ) { if( fReg1 >= 2.0f ) fReg1 = 2.0f; } else if( fReg1 < 0 ) { if( fReg1 <= -2.0f ) fReg1 = -2.0f; } m_fCurRoty = m_fRoty + m_fZoom * fReg1; if( m_bLock ) fAngle = 0; } else { fAngle = pMover->GetAngle(); if( m_bLock ) fAngle = 0; fAngleY = 90.0f; m_fCurRoty = m_fRoty + m_fZoom * 4; } m_vLookAt = vPos; #ifdef __Y_CAMERA_SLOW_8 if( !g_WndMng.m_pWndWorld->m_bRButtonDown && ( !g_bKeyTable[ VK_LEFT ] && !g_bKeyTable[ VK_RIGHT ] ) ) { static FLOAT fSpeed = 2.0f; BOOL bLeft = FALSE; BOOL bRight = FALSE; FLOAT fTemp = 0.0f; fTemp = m_fRotx; if( (GetAnglePie(fTemp) == 1 && GetAnglePie(m_fCurRotx) == 4) ) bRight = TRUE; if( (GetAnglePie(fTemp) == 4 && GetAnglePie(m_fCurRotx) == 1) ) bLeft = TRUE; if( bRight ) { m_fCurRotx += m_fRotx; if( m_fCurRotx < fTemp ) { m_fCurRotx += fSpeed; } m_fCurRotx -= m_fRotx; if( m_fCurRotx >= 0.0f ) { m_fCurRotx = -360.0f; } } if( bLeft ) { fTemp += -360.0f; if( m_fCurRotx > fTemp ) { m_fCurRotx += -fSpeed; if( m_fCurRotx < -360.0f ) m_fCurRotx = 0.0f; } fTemp -= -360.0f; } if( !bLeft && !bRight ) { FLOAT fGoal = fabs(m_fCurRotx - fTemp); if( m_fCurRotx < fTemp ) { if( fGoal > fSpeed ) m_fCurRotx += fSpeed; } else { if( fGoal > fSpeed ) m_fCurRotx -= fSpeed; } } } else { m_fCurRotx = m_fRotx; } #else //__Y_CAMERA_SLOW_8 m_fCurRotx = m_fRotx; #endif //__Y_CAMERA_SLOW_8 #ifdef __XUZHU _g_fReg[0] = fAngleY; #endif float fAdjAng = (1.0f - fAngleY / 90.0f) * 45.0f; m_fCurRoty += fAdjAng; m_fCurRoty += pMover->GetAngleX(); if( pMover->m_pActMover->IsFly() ) // 비행할땐 조금 들어주자 m_fCurRoty += 0.0f; if( m_fCurRoty > 80.0f ) m_fCurRoty = 80.0f; #if __VER >= 13 // __HOUSING if(m_nCamMode == CM_MYROOM) { if(m_fCurRoty <= 10.0f) { m_fCurRoty = 10.0f; if(m_fRoty > 0.0f) m_fRoty = 0.0f; if(m_fRoty < -30.0f) m_fRoty = -30.0f; } } #endif // __HOUSING fAngle = m_fCurRotx - fAngle + 180.0f; D3DXMATRIX matTemp; // zoom 상태에 따라 카메라 위치를 조정 extern float fDiv; if( fDiv == 2.0f ) //vTemp = D3DXVECTOR3( 0.0f, 0.0f, -0.0f - (m_fZoom / 2.0f) * 2.0f ); vTemp = D3DXVECTOR3( 0.0f, 0.0f, -0.0f - 2.0f ); else { if( g_pShip ) vTemp = D3DXVECTOR3( 0.0f, 0.0f, -4.0f - m_fZoom * 16.0f ); else //vTemp = D3DXVECTOR3( 0.0f, 0.0f, -50.0f ); vTemp = D3DXVECTOR3( 0.0f, 0.0f, -4.0f - m_fZoom * 2.0f ); } D3DXVECTOR3 vecOut; D3DXMatrixRotationX( &matTemp, D3DXToRadian( m_fCurRoty / 1.0f ) ); D3DXVec3TransformCoord( &vTemp, &vTemp, &matTemp ); D3DXMatrixRotationY( &matTemp, D3DXToRadian( fAngle ) ); D3DXVec3TransformCoord( &m_vOffsetDest, &vTemp, &matTemp ); D3DXVECTOR3 vecOffsetDelta = ( ( m_vOffsetDest - m_vOffset ) + m_vPosVal ) / fFactor; m_vOffset += vecOffsetDelta; m_vPosVal /= 2; m_vPos = vPos + m_vOffset; BOOL bCrash; FLOAT fLength; static D3DXVECTOR3 m_vLimitPos; D3DXVECTOR3 m_vOutPos = m_vPos; m_vLookAt.y += 0.4f; #if __VER >= 11 // __GUILD_COMBAT_1TO1 if( g_pPlayer && g_GuildCombat1to1Mng.IsPossibleMover( g_pPlayer ) ) bCrash = FALSE; else bCrash = pWorld->CheckBound( &m_vPos, &m_vLookAt, &m_vOutPos, &fLength ); #else //__GUILD_COMBAT_1TO1 bCrash = pWorld->CheckBound( &m_vPos, &m_vLookAt, &m_vOutPos, &fLength ); #endif //__GUILD_COMBAT_1TO1 // 충돌이있다면 마지막으로 충돌했던 거리를 저장 if( bCrash ) m_fLength2 = fLength; // 전프레임에 충돌, 현재는 충돌이 아닐때...즉, 서서히 뒤로 가게하는 시점.. if( m_bOld && bCrash == FALSE ) { m_fLength1 = fLength; m_bStart = TRUE; } if( m_bStart ) { D3DXVECTOR3 vCPos = vPos + m_vOffset; D3DXVECTOR3 vDir = vCPos - m_vLookAt; D3DXVec3Normalize(&vDir, &vDir); #if __VER >= 12 // __CAM_FAST_RECOVER m_fLength2 += 0.37f; #else m_fLength2 += 0.07f; #endif if( m_fLength2 > fLength ) m_bStart = FALSE; m_vOutPos = m_vLookAt + (vDir * m_fLength2); } else if( bCrash ) {/* if( fLength < 5.0f ) { D3DXVECTOR3 vCPos = vPos + m_vOffset; D3DXVECTOR3 vDir = vCPos - m_vLookAt; D3DXVec3Normalize(&vDir, &vDir); FLOAT fff = m_vOutPos.y; m_vOutPos = m_vLookAt + (vDir * 5.0f); m_vOutPos.y = fff; } */ } m_bOld = bCrash; g_ModelGlobal.SetCamera( m_vOutPos, m_vLookAt ); m_vPos = m_vOutPos; #endif // CLIENT }