当前位置: 首页>>代码示例>>C++>>正文


C++ Input::MouseMovement方法代码示例

本文整理汇总了C++中Input::MouseMovement方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::MouseMovement方法的具体用法?C++ Input::MouseMovement怎么用?C++ Input::MouseMovement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Input的用法示例。


在下文中一共展示了Input::MouseMovement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	//World matrices
	D3DXMATRIX view, proj;		// camera
	D3DXMATRIX lView, lProj;	// light

	mLight.power		= 1.0f;
	mLight.pos			= D3DXVECTOR3(-1000.0f, 1000.0f, -1000.0f);
	mLight.ambient		= D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	mLight.diffuse		= D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	mLight.specular		= D3DXCOLOR(0.1f, 0.1f, 0.1f, 0.0f);
	mLight.dir			= D3DXVECTOR3(0.0f, 0.0f, 0.0f);

	D3DXMatrixOrthoLH(&lProj, 500.0f, 500.0f, 1.0f, 50.0f);

	DX10App*	gfx		= myNew DX10App("Albanien 2142", 800, 600, false);
	GUI*		gui		= myNew GUI(gfx->getDevice());
	Camera*		camera	= myNew Camera(D3DXVECTOR3(100.0f, 500.0f, 50.0f), D3DXVECTOR3(0.0f, 0.0f, 0.0f), D3DXVECTOR3(0.0f, 1.0f, 0.0f));
	Input*		input	= myNew Input(gfx->getHINSTANCE(), gfx->getHWND());
	GameTimer*	timer	= myNew GameTimer();
	Terrain*	terrain = myNew Terrain(gfx->getDevice(), 256, 256, 1, 1.3f);
	Cube*		cube	= myNew Cube(10, 5, gfx->getDevice(), D3DXVECTOR3(0.0f, 0.0f, 0.0f));
	Texture2D*	shadow	= myNew Texture2D(1024, 1024, false);
	Quad*		quad	= myNew Quad(gfx->getDevice());
	
	shadow	->setDevice(gfx->getDevice());
	shadow	->createDepthTexture();
	quad	->bindTexture(shadow->mpDepthBufferRV);

	timer->start();
	bool	move;
	float	time = 0.0f;
	while(gfx->Run() != WM_QUIT)
	{
		timer->tick();

		camera->GetVP(view, proj);

		move = false;
		D3DXVECTOR3 dir(0.0f, 0.0f, 0.0f);
		if(GetAsyncKeyState('W') & 0x8000)
		{
			dir.z	= 1.0f;
			move	= true;
		}
		if(GetAsyncKeyState('S') & 0x8000)
		{
			dir.z	= -1.0f;
			move	= true;
		}
		if(GetAsyncKeyState('A') & 0x8000)
		{
			dir.x	= -1.0f;
			move	= true;
		}
		if(GetAsyncKeyState('D') & 0x8000)
		{
			dir.x	= 1.0f;
			move	= true;
		}
		if(GetAsyncKeyState('Q') & 0x8000)
		{
		}
		if(GetAsyncKeyState('R') & 0x8000)
		{
		}
		if(GetAsyncKeyState('T') & 0x8000)
		{
			mLight.pos = D3DXVECTOR3(100,100,100); 
			mLight.pos = camera->getEyePos();
			mLight.dir = D3DXVECTOR3(0.0f,0.0f,0.0f);
			
			//camera->GetVP(lView, lProj);
		}
		if(GetAsyncKeyState('G') & 0x8000)
		{
		}

		if(move)
		{
			dir *= timer->getDeltaTime();
			camera->Move(dir);
		}
		
		float dx = 0, dy = 0, pitch = 0, yAngle = 0;
		if(input->MouseMovement(dx, dy))
		{
			pitch	= 4 * dy * timer->getDeltaTime();
			yAngle	= 4 * dx * timer->getDeltaTime();
			
			camera->RotateX(pitch);
			camera->RotateY(yAngle);
		}

		D3DXVECTOR3 lightPos;
		lightPos.x = 30.0f*cosf(0.25f*timer->getGameTime());
		lightPos.y = 20.0f;
		lightPos.z = 30.0f*sinf(0.25f*timer->getGameTime());

		// Update light matrix
//.........这里部分代码省略.........
开发者ID:GustavPersson,项目名称:miniature-dubstep,代码行数:101,代码来源:main.cpp


注:本文中的Input::MouseMovement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。