Beispiel #1
0
//
// WndProc
//
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch( msg )
	{
	case WM_DESTROY:
		::PostQuitMessage(0);
		break;
		
	case WM_KEYDOWN:
		if( wParam == VK_ESCAPE )
			::DestroyWindow(hwnd);

		break;
	case WM_LBUTTONDOWN:

		// compute the ray in view space given the clicked screen point
		d3d::Ray ray = CalcPickingRay(LOWORD(lParam), HIWORD(lParam));

		// transform the ray to world space
		D3DXMATRIX view;
		Device->GetTransform(D3DTS_VIEW, &view);

		D3DXMATRIX viewInverse;
		D3DXMatrixInverse(&viewInverse,	0, &view);

		TransformRay(&ray, &viewInverse);

		// test for a hit
		if( RaySphereIntTest(&ray, &BSphere) )
			::MessageBox(0, "Hit!", "HIT", 0);

		break;
	}
	return ::DefWindowProc(hwnd, msg, wParam, lParam);
}
Beispiel #2
0
//测试射线是否与开始按钮相交
bool START::test(int x,int y)
{
	RAY ray;
	ray = CalcPickingRay(x,y);
	if(RaySphereIntTest(&ray,&(_text_start->_sphere)) == true)
		return true;
return false; 
}