Jump to content

  • Log In with Google      Sign In   
  • Create Account

XNA - Trying to get a point in space, based on viewscreen (not traditional picking)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Oblivion165   Members   -  Reputation: 107

Like
0Likes
Like

Posted 16 October 2012 - 03:47 AM

Hi there, Im trying to get the Vector3 of the bottom right corner of a viewport in 3d space. I'm trying to create a ray for a weapon but I cant seem to find the correct information to get it.

http://imageshack.us...51/65739345.png

My plan is to use the intersect point:

http://imageshack.us...76/55634161.png

and then create the ray from that point to the intersect point. Ive tried this:
public static Vector3 ScreenPositionToWorldPoint(Matrix View, Matrix Projection, Matrix World,IntVector2 MousePos)
{
	 Vector3 nearSource = new Vector3((float)MousePos.x, (float)MousePos.y, 0f);
	 Vector3 nearPoint = gGlobal.Device.Viewport.Unproject(nearSource, Projection, View, World);
	 return nearPoint;
}

But the vector3 returned isn't the correct number. For instance, if the player is standing at 10,0,10 then that will return 9.999, 0.00123, 9.9999. Thats with the viewport being 800x600 and sending that as the mouse position.

Anyone have a clue how to do this or an alternate way?

Edited by Oblivion165, 16 October 2012 - 03:48 AM.


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS