Firing from cross hair towards the forward direction

Started by
9 comments, last by Medo Mex 11 years, 3 months ago

Okay, I tried the following but can't get it to work yet:


float distance = 1000.0f;
D3DXVECTOR3 rayFrom = camera->GetPosition();
D3DXVECTOR3 rayTo = ScreenToWorld(hWnd, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, camera->viewMatrix(), camera->projectionMatrix());
D3DXVECTOR3 direction;
D3DXVec3Normalize(&direction, &(rayTo - rayFrom));
D3DXVec3Scale(&direction, &direction, distance);
Raycasting(rayFrom, direction);

This topic is closed to new replies.

Advertisement