Exemplo n.º 1
0
void MDrawContextR2::FillRectangleW(int x, int y, int cx, int cy)
{
	if( RGetIsWidthScreen() )
	{
		x = ( 800*x+80*RGetScreenWidth() )/960.f;//( x/float(RGetScreenWidth()) *800 + 80 )/960 * RGetScreenWidth();
		cx = int(cx*800.f/960.f);
	}

	FillRectangle( x,  y,  cx,  cy);
}
Exemplo n.º 2
0
void RFrame_Render()
{
	if (!RIsActive() && RIsFullScreen()) return;

	RRESULT isOK=RIsReadyToRender();
	if(isOK==R_NOTREADY)
		return;
	else
	if(isOK==R_RESTORED)
	{
		RMODEPARAMS ModeParams={ RGetScreenWidth(),RGetScreenHeight(),RIsFullScreen(),RGetPixelFormat() };
		RResetDevice(&ModeParams);
		cclog("devices Restored. \n");
	}

	if(timeGetTime() > g_last_mouse_move_time + RTOOLTIP_GAP)
		g_tool_tip = true;

	if(g_pFunctions[RF_RENDER])
		g_pFunctions[RF_RENDER](NULL);

	RGetDevice()->SetStreamSource(0,NULL,0,0);
	RGetDevice()->SetIndices(0);
	RGetDevice()->SetTexture(0,NULL);
	RGetDevice()->SetTexture(1,NULL);


//	Draw FPS

//	60fps 가 100점

	/*
	char buf[256];
	float fMs = 1000.f/g_fFPS;
	float fScore = 100-(fMs-(1000.f/60.f))*2;

	sprintf(buf, "FPS : %3.3f , %d triangles, %4.1f ms,score %4.1f 점",g_fFPS,gNumTrisRendered,fMs,fScore);
	RECT drawRect;
	SetRect(&drawRect, 0, 0, RGetScreenWidth(), RGetScreenHeight());
	g_lpFont->DrawText(buf, -1, &drawRect, DT_LEFT | DT_TOP, D3DCOLOR_RGBA(255, 255, 255, 255));
//
*/


/*
	for(int i=0;i<CCGetLogHistoryCount();i++)
	{
		drawRect.top=(i+1)*20;
		g_lpFont->DrawText(CCGetLogHistory(i), -1, &drawRect, DT_LEFT | DT_TOP, D3DCOLOR_RGBA(255, 255, 255, 255));
	}

*/
}
Exemplo n.º 3
0
void RFrame_ToggleFullScreen()
{
	RMODEPARAMS ModeParams={ RGetScreenWidth(),RGetScreenHeight(),RIsFullScreen(),RGetPixelFormat() };

	if(!ModeParams.bFullScreen)									// 윈도우 -> 풀스크린일때 저장하고..
		GetWindowRect(g_hWnd,&g_rcWindowBounds);

	ModeParams.bFullScreen=!ModeParams.bFullScreen;
	RResetDevice(&ModeParams);

	if(!ModeParams.bFullScreen)									// 풀스크린 -> 윈도우로 갈때 복구한다.
	{
		SetWindowPos( g_hWnd, HWND_NOTOPMOST,
			g_rcWindowBounds.left, g_rcWindowBounds.top,
			( g_rcWindowBounds.right - g_rcWindowBounds.left ),
			( g_rcWindowBounds.bottom - g_rcWindowBounds.top ),
			SWP_SHOWWINDOW );
	}
}
Exemplo n.º 4
0
void ZHelpScreen::DrawHelpScreen()
{
	if( !m_bDrawHelpScreen )
		return;

	// 필터링을 끄고..

	if(m_pHelpScreenBitmap==NULL) 
		return;

	if(m_pHelpScreenBitmap->m_pTexture==NULL)
		return;

	float mx = 0.f;
	float my = 0.f;
	float mw = (float)RGetScreenWidth();
	float mh = (float)RGetScreenHeight();

	float msx = 0.f;
	float msy = 0.f;
	float msw = 800.f;
	float msh = 600.f;

	float ftw = 800.f;//(float)m_pHelpScreenBitmap->m_pTexture->GetWidth();
	float fth = 600.f;//(float)m_pHelpScreenBitmap->m_pTexture->GetHeight();
	float msw2 = msw; 
	float msh2 = msh;

	D3DFORMAT d3dformat = m_pHelpScreenBitmap->m_pTexture->m_Info.Format;

	if( d3dformat==D3DFMT_DXT1 ||
		d3dformat==D3DFMT_DXT2 ||
		d3dformat==D3DFMT_DXT3 ||
		d3dformat==D3DFMT_DXT4 ||
		d3dformat==D3DFMT_DXT5 )
	{
		msw2 = (float)Floorer2PowerSize((int)msw);
		msh2 = (float)Floorer2PowerSize((int)msh);
	}

	RGetDevice()->SetRenderState( D3DRS_LIGHTING, FALSE);

	CUSTOMVERTEX Sprite[4] = 
	{
		{mx      - ADJUST_SIZE , my      - ADJUST_SIZE , 0, 1.0f, (msx)/ftw       , (msy)/fth },
		{mx + mw - ADJUST_SIZE2, my      - ADJUST_SIZE , 0, 1.0f, (msx + msw2)/ftw, (msy)/fth },
		{mx + mw - ADJUST_SIZE2, my + mh - ADJUST_SIZE2, 0, 1.0f, (msx + msw2)/ftw, (msy + msh2)/fth },
		{mx      - ADJUST_SIZE , my + mh - ADJUST_SIZE2, 0, 1.0f, (msx)/ftw       , (msy + msh2)/fth},
	};

//	RSetWBuffer(true);

	RGetDevice()->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
	RGetDevice()->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA );	
	RGetDevice()->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA );
	RGetDevice()->SetTextureStageState( 0, D3DTSS_COLORARG1 , D3DTA_TEXTURE );
	RGetDevice()->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
	RGetDevice()->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
	RGetDevice()->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );

	RGetDevice()->SetFVF(D3DFVF_CUSTOMVERTEX);
	RGetDevice()->SetTexture( 0, m_pHelpScreenBitmap->m_pTexture->GetTexture() );
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MAGFILTER , D3DTEXF_POINT );
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MINFILTER , D3DTEXF_POINT );
//	RGetDevice()->SetSamplerState( 0, D3DSAMP_MAGFILTER , D3DTEXF_NONE );
//	RGetDevice()->SetSamplerState( 0, D3DSAMP_MINFILTER , D3DTEXF_NONE );

	RGetDevice()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, Sprite, sizeof(CUSTOMVERTEX));

//	RGetDevice()->SetTextureStageState( 0, D3DTSS_MAGFILTER , D3DTEXF_LINEAR );
//	RGetDevice()->SetTextureStageState( 0, D3DTSS_MINFILTER , D3DTEXF_LINEAR );
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );

	// 굵은 폰트로 바인딩된 키그려주기...

	g_pDC->SetColor(MCOLOR(0xFF000000));

//	g_pDC->SetFont(MFontManager::Get("FONTc8b"));
//	g_pDC->SetFont(MFontManager::Get("FONTa12_O1Blr"));
	g_pDC->SetFont(MFontManager::Get("FONTb11b"));

	float aspect_x = RGetScreenWidth()/800.f;
	float aspect_y = RGetScreenHeight()/600.f;

	MFontR2* pFont = (MFontR2*)g_pDC->GetFont();
	pFont->m_fScale = 1.0f * aspect_x;

	int nHeight = 193 * aspect_y;

	// x y 중앙
	TextOutKeymap(ZACTION_MELEE_WEAPON    ,  90 * aspect_x, nHeight);
	TextOutKeymap(ZACTION_PRIMARY_WEAPON  , 148 * aspect_x, nHeight);
	TextOutKeymap(ZACTION_SECONDARY_WEAPON, 209 * aspect_x, nHeight);
	TextOutKeymap(ZACTION_ITEM1           , 265 * aspect_x, nHeight);
	TextOutKeymap(ZACTION_ITEM2           , 323 * aspect_x, nHeight);

	nHeight = 258 * aspect_y;

	TextOutKeymap(ZACTION_PREV_WEAPON  ,105*aspect_x,nHeight);
	TextOutKeymap(ZACTION_FORWARD      ,162*aspect_x,nHeight);
	TextOutKeymap(ZACTION_NEXT_WEAPON  ,222*aspect_x,nHeight);
	TextOutKeymap(ZACTION_RELOAD       ,280*aspect_x,nHeight);

	nHeight = 323 * aspect_y;

	TextOutKeymap(ZACTION_LEFT     ,120*aspect_x,nHeight);
	TextOutKeymap(ZACTION_BACK     ,178*aspect_x,nHeight);
	TextOutKeymap(ZACTION_RIGHT    ,239*aspect_x,nHeight);

	nHeight = 390 * aspect_y;

	TextOutKeymap(ZACTION_JUMP     ,196*aspect_x,nHeight);


	// TodoH(상) - Help 화면은 무엇인가효?

	pFont->m_fScale = 1.0f;

//	RSetWBuffer(true);

}
void ZInterfaceBackground::Draw(void)
{
#ifdef _FASTDEBUG
	MWidget* pWidget = (MWidget*)ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "CharSelection");
	if ( pWidget)
	{
		if ( ZApplication::GetGameInterface()->GetState() == GUNZ_CHARSELECTION)
			pWidget->Show( true);
	}

	MPicture* pPicture = (MPicture*)ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "CharSel_TopScreen");
	if ( pPicture)
		pPicture->SetOpacity( 0);

	return;
#endif

	// Set rendering state
	RSetViewport( 0, 0, RGetScreenWidth(), RGetScreenHeight());
	RGetDevice()->SetRenderState( D3DRS_CULLMODE  ,D3DCULL_CW);					// from rbs rendering
	RGetDevice()->SetRenderState( D3DRS_NORMALIZENORMALS , TRUE );
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MINFILTER , D3DTEXF_LINEAR);		// Texture filtering
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MAGFILTER , D3DTEXF_LINEAR);
	RGetDevice()->SetSamplerState( 0, D3DSAMP_MIPFILTER , D3DTEXF_LINEAR);

	// Set camera position and direction
    rvector vCamPos, vCamDir;
	float fForgDensity;

	switch ( m_nSceneNumber)
	{
		case  LOGIN_SCENE_FIXEDSKY :
		{
			// Fixed camera
			vCamPos = m_vCamPosSt;
			vCamDir = m_vCamDirSt;

			// Fixed fog -> black screen
			fForgDensity = 0.0f;

			break;
		}

		case  LOGIN_SCENE_FALLDOWN :
		{
			// Get current clock
			DWORD dwClock = ( timeGetTime() - m_dwClock);

			/*
			// Show maiet logo
			if ( !m_bShowMaietLogo)
			{
				m_bShowMaietLogo = true;
				ZGetScreenEffectManager()->AddScreenEffect( "maiet_logo");
			}
			*/

			// Set fog density
			fForgDensity = dwClock * 15.0f;

			// Set wait time
			if ( dwClock < 500)
				dwClock = 0;
			else
				dwClock -= 500;

			// Play BGM music
			//PenguinGuy
//			if ( dwClock > 2000)
//				ZApplication::GetSoundEngine()->PlayMusic( true);


			// End of scroll camera
			float fSeed = dwClock * 0.00035f;			// 카메라가 전부 다 내려오기 까지 걸리는 시간( dwClock에 곱해주는 값이
														// 작을수록 빨리 내려옴)
			if ( fSeed > 3.14)
			{
				m_nSceneNumber = LOGIN_SCENE_FIXEDCHAR;
//				m_bShowMaietLogo = false;
			}


			// Move camera position & direction
			float fGain = ( cos( fSeed) + 1.0f) / 2.0f;			// 0 < fGain < 1.0
			vCamPos = m_vCamPosEd + ( m_vCamPosSt - m_vCamPosEd) * fGain;
			vCamDir = m_vCamDirEd + ( m_vCamDirSt - m_vCamDirEd) * fGain;

			//if (m_bShowMaietLogo)
			//{
			//	ZGetScreenEffectManager()->UpdateEffects();
				ZGetScreenEffectManager()->DrawEffects();
			//}

			break;
		}

		case  LOGIN_SCENE_FIXEDCHAR :
		{
			// Show menu UI
			MWidget* pWidget = (MWidget*)ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "CharSelection");
			if ( pWidget)
			{
				if ( ZApplication::GetGameInterface()->GetState() == GUNZ_CHARSELECTION)
					pWidget->Show( true);
			}
			MPicture* pPicture = (MPicture*)ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "CharSel_TopScreen");
			if ( pPicture)
				pPicture->SetOpacity( 0);

			// Play BGM music
			//PenguinGuy
//			ZApplication::GetSoundEngine()->PlayMusic( true);

			// Fixed camera
			vCamPos = m_vCamPosEd;
			vCamDir = m_vCamDirEd;


			#define FADE_IN_TIME 500
			DWORD dwClock = ( timeGetTime() - m_dwClock);

			float fGain = ((float)dwClock / (float)FADE_IN_TIME);
			if (fGain > 1.0f)
				fGain = 1.0f;

			SetFogMulti(fGain);

			// Cleared fog
			fForgDensity = 50000.0f;
			break;
		}

		case  LOGIN_SCENE_SELECTCHAR :
		{
			// Get current clock
			DWORD dwClock = ( timeGetTime() - m_dwClock);
			float fGain = ( cos( dwClock * 0.0012f) + 1.0f) / 2.0f;
			//vCamPos = m_vCamPosEd + ( m_vCamPosSt - m_vCamPosEd) * fGain;
			//vCamDir = m_vCamDirEd + ( m_vCamDirSt - m_vCamDirEd) * fGain;
			vCamPos = m_vCamPosSt;
			vCamDir = m_vCamDirSt;

			MPicture* pPicture = (MPicture*)ZApplication::GetGameInterface()->GetIDLResource()->FindWidget( "CharSel_TopScreen");
			if ( pPicture)
			{
				// Set wait time
				if ( dwClock < 2000)
					dwClock = 0;
				else
					dwClock -= 2000;

				// Set opacity of black screen
				int nOpacity = (int)( dwClock / 3.0f);
				if ( nOpacity > 255)
					nOpacity = 255;

				pPicture->SetOpacity( nOpacity);
			}

			// Cleared fog
			fForgDensity = 50000.0f;
			break;
		}

		case  LOGIN_ROAMING :
		{
			#define ROAM_SPEED 10000
			DWORD dwClock = ( timeGetTime() - m_dwClock);

			/*if (GetAsyncKeyState(VK_NUMPAD2) & 0x8000)
				off.y -= 1.0f;
			if (GetAsyncKeyState(VK_NUMPAD8) & 0x8000)
				off.y += 1.0f;
			if (GetAsyncKeyState(VK_NUMPAD4) & 0x8000)
				off.x += 1.0f;
			if (GetAsyncKeyState(VK_NUMPAD6) & 0x8000)
				off.x -= 1.0f;
			if (GetAsyncKeyState(VK_NUMPAD7) & 0x8000)
				off.z -= 1.0f;
			if (GetAsyncKeyState(VK_NUMPAD9) & 0x8000)
				off.z += 1.0f;

			vCamPos = m_vCamPosEd + off;
			vCamDir = m_vCamDirEd;

			// Cleared fog
			fForgDensity = 50000.0f;*/

			float fGain = ((float)dwClock / (float)ROAM_SPEED);
			if (fGain > 1.0f)
				fGain = 1.0f;
			//vCamDir = mapVecs[mapIndex].second - mapVecs[mapIndex].first;
			vCamDir = m_vCamDirEd;
			vCamPos = mapVecs[mapIndex].first + ((mapVecs[mapIndex].second - mapVecs[mapIndex].first) * fGain) + D3DXVECTOR3(0.f,-100.f,0.f);

			if (dwClock > ROAM_SPEED) {
				m_dwClock = timeGetTime();				
				mapIndex = rand() % mapVecs.size();
			}

			//fForgDensity = 50000.0f; //Clear
			fForgDensity = ((-4 * fGain * fGain) + (4 * fGain)) * 20000.f;

			break;
		}
	}

	//Fog adjust
	fForgDensity *= m_fFogMulti;

	// Set camera
	RSetCamera( vCamPos, (vCamPos + vCamDir), rvector( 0, 0, 1));

	// Draw
	RSetProjection( D3DX_PI * 70 / 180, RGetScreenWidth() / (float)RGetScreenHeight(), 10.0f, 15000.0f);
	SetFogState( fForgDensity-10000.0f, fForgDensity, 0x00000000);
	D3DXMatrixTranslation( &m_matWorld, 0, 0, 0);
	RGetDevice()->SetTransform( D3DTS_WORLD, &m_matWorld);

	// Draw background
	if ( m_pLogin)
	{
		m_pLogin->Draw();
		m_pLogin->DrawObjects();
	}

	if ( m_pMapDesc)
		m_pMapDesc->DrawMapDesc();

	// Draw effects(smoke, cloud)
//	ZGetEffectManager()->Draw( timeGetTime());

	// Draw maiet logo effect
//	ZGetScreenEffectManager()->DrawEffects();
}
void ZShopEquipInterface::SelectEquipmentFrameList( const char* szName, bool bOpen)
{
	if (szName == NULL)
	{
		SelectEquipmentFrameList("Shop", bOpen);
		SelectEquipmentFrameList("Equip", bOpen);
		return;
	}

	char szTemp[256];

	ZIDLResource* pResource = GetIDLResource();


	// Frame open/close background image
	MPicture* pPicture;
	strcpy( szTemp, szName);
	strcat( szTemp, "_ArmorBGListFrameOpen");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( bOpen && GetArmorWeaponTabIndex() == 0 )  { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}

	strcpy( szTemp, szName);
	strcat( szTemp, "_ArmorBGListFrameClose");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( !bOpen && GetArmorWeaponTabIndex() == 0 ) { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}


	// Frame open/close background image
	strcpy( szTemp, szName);
	strcat( szTemp, "_WeaponBGListFrameOpen");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( bOpen && GetArmorWeaponTabIndex() == 1 )  { pPicture->Show(true); } 
		else										{ pPicture->Show(false);}		
	}

	strcpy( szTemp, szName);
	strcat( szTemp, "_WeaponBGListFrameClose");
	pPicture = (MPicture*)pResource->FindWidget( szTemp);
	if(pPicture != NULL) {
		if( !bOpen && GetArmorWeaponTabIndex() == 1 )  { pPicture->Show(true); } 
		else										 { pPicture->Show(false);}		
	}


	// Frame open/close image
	MButton* pButton;
	strcpy( szTemp, szName);
	strcat( szTemp, "_EquipListFrameCloseButton");
	pButton = (MButton*)pResource->FindWidget( szTemp);
	if ( pButton != NULL) pButton->Show( bOpen);

	strcpy( szTemp, szName);
	strcat( szTemp, "_EquipListFrameOpenButton");
	pButton = (MButton*)pResource->FindWidget( szTemp);
	if ( pButton != NULL) pButton->Show( !bOpen);

	// Resize item slot
	char szWidgetName[ 256];
	sprintf( szWidgetName, "%s_EquipmentSlot_Head", szName);
	MWidget* itemSlot = (MWidget*)pResource->FindWidget( szWidgetName);
	if (itemSlot) {
		MRECT rect = itemSlot->GetRect();

		int nWidth;
		if ( bOpen) nWidth = 220.0f * (float)RGetScreenWidth() / 800.0f;
		else		nWidth = min( rect.w, rect.h);

		for ( int i = 0;  i < MMCIP_END;  i++) {
			itemSlot = (MWidget*)pResource->FindWidget( GetItemSlotName( szName, i));

			if (itemSlot) {
				if(GetArmorWeaponTabIndex() == GetArmorWeaponTabIndexContainItemParts((MMatchCharItemParts)i)) {					
					rect = itemSlot->GetRect();

					itemSlot->SetBounds( rect.x, rect.y, nWidth, rect.h);
					itemSlot->Show(true);
				} 
				else {
					itemSlot->Show(false);
				}
			}
		}
	}

	// 상점과 장비창의 탭 버튼 눌림 상태를 동기화해주자 -_-;
	MBmButton* pTabBtn;
	if (GetArmorWeaponTabIndex() == 0)
	{
		pTabBtn = (MBmButton*)pResource->FindWidget("Shop_ArmorEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
		pTabBtn = (MBmButton*)pResource->FindWidget("Equip_ArmorEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
	}
	else if (GetArmorWeaponTabIndex() == 1)
	{
		pTabBtn = (MBmButton*)pResource->FindWidget("Shop_WeaponEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
		pTabBtn = (MBmButton*)pResource->FindWidget("Equip_WeaponEquipmentTab");
		if (pTabBtn) pTabBtn->SetCheck(true);
	}
}
Exemplo n.º 7
0
void ZGameInput::Update(float fElapsed)
{
	/*
	{
		static DWORD dwLastTime = timeGetTime();

		if(timeGetTime()-dwLastTime > 10 )
		{
			dwLastTime = timeGetTime();
			{
				MTextArea *pTextArea = (MTextArea*)ZGetGameInterface()->GetIDLResource()->FindWidget("CombatChatOutputTest");
				if(pTextArea)
				{
					char szbuffer[256];
					for(int i=0;i<100;i++)
					{
						szbuffer[i]=rand()%255+1;
					}
					szbuffer[100]=0;
					pTextArea->AddText(szbuffer);
					if(pTextArea->GetLineCount()>10) pTextArea->DeleteFirstLine();
				}

			}

			{
				MTextArea *pTextArea = (MTextArea*)ZGetGameInterface()->GetIDLResource()->FindWidget("CombatChatOutput");
				if(pTextArea)
				{
					char szbuffer[256];
					for(int i=0;i<100;i++)
					{
						szbuffer[i]=rand()%255+1;
					}
					szbuffer[100]=0;
					pTextArea->AddText(szbuffer);
					if(pTextArea->GetLineCount()>10) pTextArea->DeleteFirstLine();
				}
			}
		}
	}//*/

//	if(RIsActive() && !g_pGame->IsReplay())

	//jintriple3 메모리 프록시...비트 패킹..
	const ZCharaterStatusBitPacking &uStatus = ZGetGame()->m_pMyCharacter->m_dwStatusBitPackingValue.Ref();
	ZMyCharaterStatusBitPacking & zStatus = ZGetGame()->m_pMyCharacter->m_statusFlags.Ref();


	if(RIsActive())
	{
		ZCamera* pCamera = ZGetGameInterface()->GetCamera();
		ZMyCharacter* pMyCharacter = ZGetGame()->m_pMyCharacter;
		if ((!pMyCharacter) || (!pMyCharacter->GetInitialized())) return;

		// 커서가 없는 상태에서만 카메라및 게임입력을 받는다
		if(!ZGetGameInterface()->IsCursorEnable())
		{
			{
				float fRotateX = 0;
				float fRotateY = 0;

#ifdef _DONOTUSE_DINPUT_MOUSE
				// DINPUT 을 사용하지 않는경우
				int iDeltaX, iDeltaY;

				POINT pt;
				GetCursorPos(&pt);
				ScreenToClient(g_hWnd,&pt);
				iDeltaX = pt.x-RGetScreenWidth()/2;
				iDeltaY = pt.y-RGetScreenHeight()/2;

				float fRotateStep = 0.0005f * Z_MOUSE_SENSITIVITY*10.0f;
				fRotateX = (iDeltaX * fRotateStep);
				fRotateY = (iDeltaY * fRotateStep);

#else
				// 마우스 입력 dinput 처리

				ZGetInput()->GetRotation(&fRotateX,&fRotateY);
#endif

				bool bRotateEnable=false;
				// TODO : 칼로 벽에 꽂았을때 프리카메라로 바꾸자
				if( !zStatus.m_bSkill && !uStatus.m_bWallJump && !uStatus.m_bWallJump2 && !zStatus.m_bWallHang && 
					!uStatus.m_bTumble && !uStatus.m_bBlast && !uStatus.m_bBlastStand && !uStatus.m_bBlastDrop )
					bRotateEnable=true;
				if (pMyCharacter->IsDie()) bRotateEnable = true;

				if (RIsActive())
				{
					ZCamera *pCamera = ZGetGameInterface()->GetCamera();

					pCamera->m_fAngleX += fRotateY;
					pCamera->m_fAngleZ += fRotateX;

					if(pCamera->GetLookMode()==ZCAMERA_MINIMAP) {
						pCamera->m_fAngleX=max(pi/2+.1f,pCamera->m_fAngleX);
						pCamera->m_fAngleX=min(pi-0.1f,pCamera->m_fAngleX);
					}else {
						static float lastanglex,lastanglez;
						if(bRotateEnable)
						{
							// 정밀도 유지를 위해 0~2pi 로 유지
							pCamera->m_fAngleZ = fmod(pCamera->m_fAngleZ,2*PI);
							pCamera->m_fAngleX = fmod(pCamera->m_fAngleX,2*PI);

							pCamera->m_fAngleX=max(CAMERA_ANGLEX_MIN,pCamera->m_fAngleX);
							pCamera->m_fAngleX=min(CAMERA_ANGLEX_MAX,pCamera->m_fAngleX);

							lastanglex=pCamera->m_fAngleX;
							lastanglez=pCamera->m_fAngleZ;
						}else
						{
							// 각도제한이 필요하다
							pCamera->m_fAngleX=max(CAMERA_ANGLEX_MIN,pCamera->m_fAngleX);
							pCamera->m_fAngleX=min(CAMERA_ANGLEX_MAX,pCamera->m_fAngleX);

							pCamera->m_fAngleX=max(lastanglex-pi/4.f,pCamera->m_fAngleX);
							pCamera->m_fAngleX=min(lastanglex+pi/4.f,pCamera->m_fAngleX);

							pCamera->m_fAngleZ=max(lastanglez-pi/4.f,pCamera->m_fAngleZ);
							pCamera->m_fAngleZ=min(lastanglez+pi/4.f,pCamera->m_fAngleZ);

						}
					}

					ZCombatInterface* pCombatInterface = ZGetGameInterface()->GetCombatInterface();
					if (pCombatInterface && !pCombatInterface->IsChat() &&
						(pCamera->GetLookMode()==ZCAMERA_FREELOOK || pCamera->GetLookMode()==ZCAMERA_MINIMAP))
					{

						rvector right;
						rvector forward=RCameraDirection;
						CrossProduct(&right,rvector(0,0,1),forward);
						Normalize(right);
						const rvector up = rvector(0,0,1);

						rvector accel = rvector(0,0,0);

						if(ZIsActionKeyPressed(ZACTION_FORWARD)==true)	accel+=forward;
						if(ZIsActionKeyPressed(ZACTION_BACK)==true)		accel-=forward;
						if(ZIsActionKeyPressed(ZACTION_LEFT)==true)		accel-=right;
						if(ZIsActionKeyPressed(ZACTION_RIGHT)==true)	accel+=right;
						if(ZIsActionKeyPressed(ZACTION_JUMP)==true)		accel+=up;
						if(ZIsActionKeyPressed(ZACTION_USE_WEAPON)==true)			accel-=up;

						rvector cameraMove = 
							(pCamera->GetLookMode()==ZCAMERA_FREELOOK ? 1000.f : 10000.f )		// 미니맵모드는 빨리 움직임
							* fElapsed*accel;

						rvector targetPos = pCamera->GetPosition()+cameraMove;

						// 프리룩은 충돌체크를 한다
						if(pCamera->GetLookMode()==ZCAMERA_FREELOOK)
							ZGetGame()->GetWorld()->GetBsp()->CheckWall(pCamera->GetPosition(),targetPos,ZFREEOBSERVER_RADIUS,0.f,RCW_SPHERE);
						else
						// 미니맵은 범위내에 있는지 체크한다
						{
							rboundingbox *pbb = &ZGetGame()->GetWorld()->GetBsp()->GetRootNode()->bbTree;
							targetPos.x = max(min(targetPos.x,pbb->maxx),pbb->minx);
							targetPos.y = max(min(targetPos.y,pbb->maxy),pbb->miny);

							ZMiniMap *pMinimap = ZGetGameInterface()->GetMiniMap();
							if(pMinimap)
								targetPos.z = max(min(targetPos.z,pMinimap->GetHeightMax()),pMinimap->GetHeightMin());
							else
								targetPos.z = max(min(targetPos.z,7000),2000);

							
						}

						pCamera->SetPosition(targetPos);

					}
					else if ( !ZGetGame()->IsReplay())
					{
						pMyCharacter->ProcessInput( fElapsed);
					}
				}
			}
			POINT pt={RGetScreenWidth()/2,RGetScreenHeight()/2};
			ClientToScreen(g_hWnd,&pt);
			SetCursorPos(pt.x,pt.y);

			// 대쉬 키 입력 검사
			GameCheckSequenceKeyCommand();

		}else
			pMyCharacter->ReleaseButtonState();	// 메뉴가 나왔을때는 버튼이 눌리지 않은상태로 돌려놓는다
	}
}
RRESULT OnCreate(void *pParam)
{
	/*
	//	Walk through in debug to trace all routes
	*/
	g_App.PreCheckArguments();

	sprintf( cstrReleaseDate, "Version : %s", ZGetSVNRevision().c_str()); //Possibly
	cclog(cstrReleaseDate); cclog("\n");

	g_DInput.Create(g_hWnd, FALSE, FALSE);
	g_pInput = new ZInput(&g_DInput);
	RSetGammaRamp(Z_VIDEO_GAMMA_VALUE);
	RSetRenderFlags(RRENDER_CLEAR_BACKBUFFER);

	ZGetInitialLoading()->Initialize(  1, 0, 0, RGetScreenWidth(), RGetScreenHeight(), 0, 0, 1024, 768 );

	cclog("InitialLoading success.\n");

	struct _finddata_t c_file;
	intptr_t hFile;
	char szFileName[256];
	#define FONT_DIR	"Font/"
	#define FONT_EXT	"ttf"
	if( (hFile = _findfirst(FONT_DIR"*."FONT_EXT, &c_file )) != -1L ){
		do{
			strcpy(szFileName, FONT_DIR);
			strcat(szFileName, c_file.name);
			AddFontResource(szFileName);
		}while( _findnext( hFile, &c_file ) == 0 );
		_findclose(hFile);
	}

	g_pDefFont = new CCFontR2;

	if( !g_pDefFont->Create("Default", Z_LOCALE_DEFAULT_FONT, DEFAULT_FONT_HEIGHT, 1.0f) )	{
		cclog("Fail to Create default font : CCFontR2 / main.cpp.. onCreate\n" );
		g_pDefFont->Destroy();
		SAFE_DELETE( g_pDefFont );
		g_pDefFont	= NULL;
	}
	g_pDC = new CCDrawContextR2(RGetDevice());

	if( ZGetInitialLoading()->IsUseEnable() )
	{
		ZGetInitialLoading()->AddBitmap( 0, "Interface/Default/LOADING/loading_adult.jpg" );
		ZGetInitialLoading()->AddBitmapBar( "Interface/Default/LOADING/loading.bmp" );
		ZGetInitialLoading()->SetText( g_pDefFont, 5, 5, cstrReleaseDate );
		ZGetInitialLoading()->AddBitmapGrade( "Interface/Default/LOADING/loading_grade_fifteen.jpg" );
		ZGetInitialLoading()->SetPercentage( 0.0f );
		ZGetInitialLoading()->Draw( MODE_FADEIN, 0 , true );
	}


	g_Core.Initialize(800, 600, g_pDC, g_pDefFont);
	Core::GetInstance()->SetHWND(RealSpace2::g_hWnd);

	cclog("interface Initialize success\n");

	ZLoadingProgress appLoading("application");
	if(!g_App.OnCreate(&appLoading))
	{
		ZGetInitialLoading()->Release();
		return R_ERROR_LOADING;
	}

	ZGetSoundEngine()->SetEffectVolume(Z_AUDIO_EFFECT_VOLUME);
	ZGetSoundEngine()->SetMusicVolume(Z_AUDIO_BGM_VOLUME);
	ZGetSoundEngine()->SetEffectMute(Z_AUDIO_EFFECT_MUTE);
	ZGetSoundEngine()->SetMusicMute(Z_AUDIO_BGM_MUTE);

	g_Core.SetWorkspaceSize(g_ModeParams.nWidth, g_ModeParams.nHeight);
	g_Core.GetMainFrame()->SetSize(g_ModeParams.nWidth, g_ModeParams.nHeight);
	ZGetOptionInterface()->Resize(g_ModeParams.nWidth, g_ModeParams.nHeight);

	// Default Key
	for(int i=0; i<ZACTION_COUNT; i++){
		ZACTIONKEYDESCRIPTION& keyDesc = ZGetConfiguration()->GetKeyboard()->ActionKeys[i];
		g_pInput->RegisterActionKey(i, keyDesc.nVirtualKey);
		if(keyDesc.nVirtualKeyAlt!=-1)
			g_pInput->RegisterActionKey(i, keyDesc.nVirtualKeyAlt);
	}

	g_App.SetInitialState();

//	ParseParameter(g_szCmdLine);

//	ZGetFlashBangEffect()->SetDrawCopyScreen(true);

	static const char *szDone = "Done.";
	ZGetInitialLoading()->SetLoadingStr(szDone);
	if( ZGetInitialLoading()->IsUseEnable() )
	{
#ifndef _FASTDEBUG
		ZGetInitialLoading()->SetPercentage( 100.f );
		ZGetInitialLoading()->Draw( MODE_FADEOUT, 0 ,true  );
#endif
		ZGetInitialLoading()->Release();
	}

	cclog("main : OnCreate() done\n");

	SetFocus(g_hWnd);

	return R_OK;
}
Exemplo n.º 9
0
bool ZCamera::CheckCollisionWall(float &fRealDist, rvector& pos, rvector& dir)
{
	RBSPPICKINFO bpi;
	float fNearZ = DEFAULT_NEAR_Z;
	rvector pos2 = pos;							// camera pos
	rvector tarpos = pos2 + (dir * fNearZ);		// near pos

	rvector up2, right2;
	up2 = rvector(0.0f, 0.0f, 1.0f);
	right2 = Normalized(CrossProduct(dir, up2));

	up2 = Normalized(CrossProduct(right2, dir));
	right2 = Normalized(CrossProduct(dir, up2));

	float fov = GetFOV();
	float e = 1 / (tanf(fov / 2));
	float fAspect = (float)RGetScreenWidth() / (float)RGetScreenHeight();
	float fPV = (fAspect * fNearZ / e);
	float fPH = (fNearZ / e);

	bool bCollisionWall = false;

	pos2 = pos;
	rvector tar = tarpos + (up2 * fPV);
	rvector dir2;
	dir2 = tar - pos2;
	Normalize(dir2);
	// NOTE: This was using dir as at??? Figure out why
	auto matView = ViewMatrix(pos2, Normalized(dir - pos2), up2);

	if (ZGetGame()->GetWorld()->GetBsp()->Pick(pos2, dir2, &bpi))
	{
		if (Magnitude(tar - bpi.PickPos) < Magnitude(tar - pos2))
		{
			rvector v1, v2, v3;

			v1 = bpi.PickPos;
			v3 = tar;

			if (ZGetGame()->GetWorld()->GetBsp()->Pick(tarpos, up2, &bpi))
			{
				v2 = bpi.PickPos;

				float fD = Magnitude(tarpos - v2);
				if (fD < fPH)
				{
					rvector vv1 = v1 - v2, vv2 = v2 - v3;
					D3DXVECTOR4 rV4;
					vv1 = Transform(vv1, matView);
					v2 = Transform(vv2, matView);

					float fAng = GetAngleOfVectors(vv1, vv2);
					if (fAng < 0.0f) fAng = -fAng;

					if (fAng < PI_FLOAT)
					{
						bCollisionWall = true;

						float fX = fPV - fD;
						float fY = fX * tanf(fAng);

						float fMyRealDist = fRealDist - fY;
						fRealDist = min(fMyRealDist, fRealDist);
					}
				}
			}
		}
	}

	pos2 = pos;
	tar = tarpos + (right2 * fPH);
	dir2 = Normalized(tar - pos2);

	if (ZGetGame()->GetWorld()->GetBsp()->Pick(pos2, dir2, &bpi))
	{
		if (Magnitude(tar - bpi.PickPos) < Magnitude(tar - pos2))
		{
			rvector v1, v2, v3;

			v1 = bpi.PickPos;
			v3 = tar;

			if (ZGetGame()->GetWorld()->GetBsp()->Pick(tarpos, right2, &bpi))
			{
				v2 = bpi.PickPos;

				float fD = Magnitude(tarpos - v2);
				if (fD < fPH)
				{
					rvector vv1 = v1 - v2, vv2 = v2 - v3;
					float fAng = GetAngleOfVectors(vv1, vv2);
					if (fAng < 0.0f) fAng = -fAng;

					if (fAng < (PI_FLOAT / 2))
					{
						bCollisionWall = true;

						float fX = fPH - fD;
						float fY = fX * tanf(fAng);

						float fMyRealDist = fRealDist - fY;
						fRealDist = min(fMyRealDist, fRealDist);
					}
				}
			}
		}
	}

	pos2 = pos;
	tar = tarpos - (up2 * fPV);
	dir2 = Normalized(tar - pos2);
	matView = ViewMatrix(pos2, Normalized(dir2 - pos2), up2);

	if (ZGetGame()->GetWorld()->GetBsp()->Pick(pos2, dir2, &bpi))
	{
		if (Magnitude(tar - bpi.PickPos) < Magnitude(tar - pos2))
		{
			rvector v1, v2, v3;

			v1 = bpi.PickPos;
			v3 = tar;

			if (ZGetGame()->GetWorld()->GetBsp()->Pick(tarpos, -up2, &bpi))
			{
				v2 = bpi.PickPos;

				float fD = Magnitude(tarpos - v2);
				if (fD < fPH)
				{
					bCollisionWall = true;

					rvector vv1 = v1 - v2, vv2 = v2 - v3;
					vv1 = Transform(vv1, matView);
					vv2 = Transform(vv2, matView);

					float fAng = GetAngleOfVectors(vv1, vv2);
					if (fAng < 0.0f) fAng = -fAng;

					if (fAng < (PI_FLOAT / 2))
					{
						float fX = fPV - fD;
						float fY = fX * tanf(fAng);

						float fMyRealDist = fRealDist - fY;
						fRealDist = min(fMyRealDist, fRealDist);
					}
				}
			}
		}
	}

	pos2 = pos;
	tar = tarpos - (right2 * fPH);
	dir2 = Normalized(tar - pos2);

	if (ZGetGame()->GetWorld()->GetBsp()->Pick(pos2, dir2, &bpi))
	{
		if (Magnitude(tar - bpi.PickPos) < Magnitude(tar - pos2))
		{
			rvector v1, v2, v3;

			v1 = bpi.PickPos;
			v3 = tar;

			if (ZGetGame()->GetWorld()->GetBsp()->Pick(tarpos, -right2, &bpi))
			{
				v2 = bpi.PickPos;

				float fD = Magnitude(tarpos - v2);
				if (fD < fPH)
				{
					bCollisionWall = true;

					rvector vv1 = v1 - v2, vv2 = v2 - v3;
					float fAng = GetAngleOfVectors(vv1, vv2);
					if (fAng < 0.0f) fAng = -fAng;

					if (fAng < (PI_FLOAT / 2))
					{
						float fX = fPH - fD;
						float fY = fX * tanf(fAng);

						float fMyRealDist = fRealDist - fY;
						fRealDist = min(fMyRealDist, fRealDist);
					}
				}
			}
		}
	}

	if (fRealDist < 0) fRealDist = 0.0f;

	return bCollisionWall;
}
Exemplo n.º 10
0
//////////////////////////////////////////////////////////////////////////
//	Render
//	1. 광원과 중심과의 거리가 가까울수록 플레어의 크기가 커지고 알파값이 
//		커진다
//	2. 광원과 중심과의 거리를 구하고 그것을 엘레멘트의 수로 나누어 
//		엘레멘트간의 간격을 구하고 엘레멘트들을 그려준다.
//////////////////////////////////////////////////////////////////////////
bool RLenzFlare::Render( rvector& light_pos_, rvector& centre_, RBspObject* pbsp_  ) 
{
	rvector rDir	= light_pos_ - centre_;
	rvector cDir	= RCameraDirection;
	if( D3DXVec3Dot( &rDir, &cDir )  < 0 )
	{
		return false;
	}

	// 화면에서의 광원과 중심 위치
	// TODO : 만약 중심이 화면의 중앙이라면 연산을 쉽게 할수 있다...
	rmatrix view, proj;
	RGetDevice()->GetTransform( D3DTS_VIEW, &view );
	RGetDevice()->GetTransform( D3DTS_PROJECTION, &proj );
	
	rvector pos = ( light_pos_ * view * proj ) ;	// -1 ~ 1 사이 아니면 광원이 보이지 않는다
	pos.z = 0.0f;									// 화면에서 광원이 사라졌을 경우 렌즈 플레어가 보이지 않는다.

	if((pos.x < -1 || pos.x > 1) || (pos.y < -1 || pos.y > 1))
	{
        //return false;
	}

	float alpha = max(min(((1 - pos.x)*(1 + pos.x)+(1-pos.y)*(1+pos.y)-1.0f)*0.5f, 0.6f ), 0.0f);

	RBSPPICKINFO info;
	rvector	dir;
	float distance;
	dir = light_pos_ - RCameraPosition;
	distance	= D3DXVec3LengthSq( &dir );
	D3DXVec3Normalize( &dir, &dir );
	if( pbsp_->Pick( RCameraPosition, dir, &info,  RM_FLAG_ADDITIVE) )
	{
		if( distance > D3DXVec3LengthSq(&( RCameraPosition - info.PickPos )) )
		{
			return false;
		}
	}
	
	
    rvector centre = ( centre_ * view * proj );
	centre.z = 0.0f;

	//for test
	//카메라 위치로 했을 경우 아주 불안함..캐릭터의 머리 부분 정도가 되야 할것 같음
	{
		centre.x = 0;
		centre.y = 0;
	}
	//end for test

	float dist = D3DXVec3Length(&(pos - centre));
	float scale_factor = 1/dist;

	pos.x = (pos.x + 1) * 0.5 * RGetScreenWidth();			// 실제 화면에서의 광원 위치
	pos.y = (-pos.y + 1) * 0.5 * RGetScreenHeight();
	centre.x = (centre.x + 1) * 0.5 * RGetScreenWidth();	// 실제 화면에서의 중심 위치
	centre.y = (-centre.y + 1) * 0.5 * RGetScreenHeight();
	
	rvector temp = pos - centre;

	float dx = centre.x + (centre.x - pos.x);
	float dy = centre.y + (centre.y - pos.y);

	float xInc = (dx - pos.x) / miNumFlareElement;
	float yInc = (dy - pos.y) / miNumFlareElement;

	int index;
	for( int i = 0 ; i < miNumFlareElement; ++i )
	{
		index = miElementOrder[i];

		float width = msElements[index].width * scale_factor;
		if( width > MAX_FLARE_ELEMENT_WIDTH )
		{
			width = MAX_FLARE_ELEMENT_WIDTH;
		}
		float height = msElements[index].height * scale_factor;
		if( height > MAX_FLARE_ELEMENT_HEIGHT )
		{
			height = MAX_FLARE_ELEMENT_HEIGHT;
		}

		float px = pos.x + (xInc * i) - width* 0.5;
		float py = pos.y + (yInc * i) - height * 0.5;

		float alpha = scale_factor * 0.2;

		if( alpha > MAX_ALPHA )
		{
			alpha = MAX_ALPHA;
		}

		if( !draw( px, py, width, height, alpha, msElements[index].color, msElements[index].iTextureIndex ) )
		{
			cclog( "Fail to Draw %dth Flare Element!\n",i );
			return false;
		}
	}

	//화면 뿌옇게 만들기
	draw( 0, 0, RGetScreenWidth(), RGetScreenHeight(), alpha, 0xFFFFFFFF, -1 );

    return true;
}