Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXVec3Project

Started by treeway Jul 31, 2006 at 5:39 PM 0 replies 2.4k views
Original Post
treeway
treeway
Hi Im trying to render some text to the screen where an object apears in 3d space by using D3DXVec3Project() but im getting the wrong results:

base->D3dDevice->GetViewport(&vp);
D3DXVec3Project(&textPos,playerPosition,&vp,base->camera->getProjectionMatrix(),base->camera->getViewMatrix(),base->camera->getWorldMatrix());
		
sprintf(base->buffer,"CamDist: %f \n StrDist: %f \n FPS %d \n X %f Y %f Z %f",camDistance,storedDistace,base->getFPS(),textPos.x,textPos.y,textPos.z);
		base->renderText(base->buffer,textPos.x,textPos.y,D3DCOLOR_XRGB(0,0,0));
		test->setPosition(&textPos);
what could be wrong?
circlesoft
circlesoft
That looks to be the correct usage, so check you input parameters:

(1) Does the GetViewport() call actually succeed? If you have a pure device, it will fail.

(2) Are the matrices correct? Check to see if they are still valid at this point in the frame.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.