All pastes #968508 Raw Edit

Something

public cpp v1 · immutable
·published 2008-04-03 02:12 UTC
rendered paste body
void DXinput::Update(Camera* cam, Grid* pGrid){	x+= .05;	g_lpDIDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);	if(device == key)	{		if (KEYDOWN(buffer, DIK_W))		{			D3DXVECTOR3 camDir; 			camDir = cam->camLook - cam->camPos; 			D3DXVec3Normalize(&camDir, &camDir); 			cam->camPos = cam->camPos + camDir; 			cam->camLook = cam->camLook + camDir; 			// adjust the y value for the change in terrain 			pGrid->GetGridPoint(&cam->camPos, cam->camPos.x, cam->camPos.z); 			cam->camPos.y += 30.0f; 			MovePoint(cam);		}		if (KEYDOWN(buffer, DIK_S))		{			D3DXVECTOR3 camDir; 			camDir = cam->camLook - cam->camPos; 			D3DXVec3Normalize(&camDir, &camDir); 			cam->camPos = cam->camPos - camDir; 			cam->camLook = cam->camLook - camDir; 			// adjust the y value for the change in terrain 			pGrid->GetGridPoint(&cam->camPos, cam->camPos.x, cam->camPos.z); 			cam->camPos.y += 30.0f; 			MovePoint(cam);		}		if (KEYDOWN(buffer, DIK_A))		{			D3DXMATRIX ry; 			D3DXVECTOR4 result; 			D3DXVECTOR3 camDir; 			camDir = cam->camLook - cam->camPos; 			D3DXMatrixRotationY(&ry, D3DXToRadian(-1)); 			D3DXVec3Transform(&result, &camDir, &ry); 			cam->camLook = cam->camPos + D3DXVECTOR3(result.x, result.y, result.z); 			// adjust the y value for the change in terrain 			pGrid->GetGridPoint(&cam->camPos, cam->camPos.x, cam->camPos.z); 			cam->camPos.y += 30.0f; 			MovePoint(cam);		}		if (KEYDOWN(buffer, DIK_D))		{			D3DXMATRIX ry; 			D3DXVECTOR4 result; 			D3DXVECTOR3 camDir; 			camDir = cam->camLook - cam->camPos; 			D3DXMatrixRotationY(&ry, D3DXToRadian(1)); 			D3DXVec3Transform(&result, &camDir, &ry); 			cam->camLook = cam->camPos + D3DXVECTOR3(result.x, result.y, result.z); 			// adjust the y value for the change in terrain 			pGrid->GetGridPoint(&cam->camPos, cam->camPos.x, cam->camPos.z); 			cam->camPos.y += 30.0f;			MovePoint(cam);		}	}	else if(device == mouse)	{			g_lpDIDevice->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID)&mouseState); 		radius = 30;		xRot += (float)mouseState.lY/700;		yRot -= (float)mouseState.lX/700;		MovePoint(cam);		//SetCursorPos(500, 500);	}}void DXinput::MovePoint(Camera *cam)	{		D3DXMATRIX temp1;		D3DXMatrixIdentity(&temp1);		D3DXMATRIX temp2;		D3DXMatrixIdentity(&temp2);		D3DXMatrixTranslation(&temp1, 0,0, radius);		D3DXMatrixRotationY(&temp2, yRot);		D3DXMatrixMultiply(&temp1, &temp1, &temp2);		D3DXMatrixRotationX(&temp2, xRot);		D3DXMatrixMultiply(&temp1, &temp1, &temp2);		D3DXMatrixTranslation(&temp2, cam->camPos.x, cam->camPos.y, cam->camPos.z);		D3DXMatrixMultiply(&temp1, &temp1, &temp2);		cam->camLook.x = temp1._41;		cam->camLook.y = temp1._42;		cam->camLook.z = temp1._43;	}