<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.xna.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>XNA Framework</title><link>http://forums.xna.com/forums/56.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 0.0)</generator><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/37005.aspx</link><pubDate>Fri, 14 Dec 2007 09:11:43 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:37005</guid><dc:creator>Nightin</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/37005.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=37005</wfw:commentRss><description>&lt;P&gt;Pushing the near clip plane isn't quite a good solution to this, here's the method I worked out for generating pick ray:&lt;/P&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;
&lt;DIV style="PADDING-RIGHT:2px;OVERFLOW-Y:hidden;PADDING-LEFT:8px;PADDING-BOTTOM:2px;MARGIN:0px;OVERFLOW:scroll;WIDTH:505px;PADDING-TOP:2px;BACKGROUND-COLOR:white;"&gt;&lt;PRE&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;void&lt;/SPAN&gt; UpdatePickRay()&lt;BR&gt;{&lt;BR&gt;    MouseState mouseState &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Mouse.GetState();&lt;BR&gt;&lt;BR&gt;    Vector3 v;&lt;BR&gt;    v.X &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; (((2.0f &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;*&lt;/SPAN&gt; mouseState.X) &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;/&lt;/SPAN&gt; screenWidth) &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;-&lt;/SPAN&gt; 1);&lt;BR&gt;    v.Y &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;-&lt;/SPAN&gt;(((2.0f &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;*&lt;/SPAN&gt; mouseState.Y) &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;/&lt;/SPAN&gt; screenHeight) &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;-&lt;/SPAN&gt; 1);&lt;BR&gt;    v.Z &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; 0.0f;&lt;BR&gt;&lt;BR&gt;    pickRay.Position.X &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; viewInverse.M41;&lt;BR&gt;    pickRay.Position.Y &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; viewInverse.M42;&lt;BR&gt;    pickRay.Position.Z &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; viewInverse.M43;&lt;BR&gt;    pickRay.Direction &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Vector3.Normalize(&lt;BR&gt;        Vector3.Transform(v, viewProjectionInverse) &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;-&lt;/SPAN&gt; pickRay.Position);&lt;BR&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Where viewInverse, projectionInverse and viewProjectionInverse are computed every frame using&lt;/P&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;&lt;FONT face=Verdana&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;
&lt;DIV style="PADDING-RIGHT:2px;OVERFLOW-Y:hidden;PADDING-LEFT:8px;PADDING-BOTTOM:2px;MARGIN:0px;OVERFLOW:scroll;WIDTH:505px;PADDING-TOP:2px;BACKGROUND-COLOR:white;"&gt;&lt;PRE&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;projection &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; camera.Projection;&lt;BR&gt;viewProjection &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; view &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;*&lt;/SPAN&gt; projection;&lt;BR&gt;viewInverse &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Matrix.Invert(view);&lt;BR&gt;projectionInverse &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; Matrix.Invert(projection);&lt;BR&gt;viewProjectionInverse &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;=&lt;/SPAN&gt; projectionInverse &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:red;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;*&lt;/SPAN&gt; ViewInverse;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;This method works well for picking.&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;The only difference is that the pick ray position is exacly the&amp;nbsp;eye position using this method,&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;by using the method refered in the XNA documentation, pick ray position is on the near clip plane.&lt;/DIV&gt;
&lt;DIV style="BACKGROUND-COLOR:white;"&gt;But in most cases this difference is trivial.&lt;/DIV&gt;&lt;/FONT&gt;&lt;/DIV&gt;</description></item><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36990.aspx</link><pubDate>Fri, 14 Dec 2007 07:39:19 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36990</guid><dc:creator>ajmiles</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36990.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36990</wfw:commentRss><description>&lt;P&gt;I've been having a look at that sample, and while I can't really see that you're doing anything wrong per se, the problem is certainly lessened substantially by pushing your near clip plane out to 10 or 100, which suggests to me there might be some floating point inaccuracy going on, perhaps when using/normalising vectors somewhere, but as yet I can't fix it for sure.&lt;/P&gt;</description></item><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36988.aspx</link><pubDate>Fri, 14 Dec 2007 06:39:52 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36988</guid><dc:creator>Nightin</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36988.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36988</wfw:commentRss><description>&lt;P&gt;This is&amp;nbsp;the sample program modified from XNA tutorial, hope it demonstrates something.&lt;/P&gt;
&lt;P&gt;I'm using Visual Studio 2005 Team + XNA 2.0 Build 2.0.11022.3.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://files-upload.com/files/677911/Unproject.zip"&gt;&lt;FONT color=#ed145a&gt;http://files-upload.com/files/677911/Unproject.zip&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The link will be expired in 14 days :(&lt;/P&gt;</description></item><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36985.aspx</link><pubDate>Fri, 14 Dec 2007 05:00:56 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36985</guid><dc:creator>ajmiles</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36985.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36985</wfw:commentRss><description>I just converted the Triangle Picking with Triangle Accuracy sample from 1.0 to 2.0 to see if I could see any issues with the way Unproject worked and I could see none. No jittering, no inverse rays, it just worked. It does appear that Unproject (and possibly Project, I didn't check) are now implemented in C# rather than making a native call as in 1.0, but as I say, I can't see anything wrong with it. I don't pretend to be able to quite understand the math behind the Unproject method, but jittering isn't likely to occur unless you're feeding it different arguments each time you call it, it could conceivably be buggy, but its pretty unlikely Unproject is non-deterministic.</description></item><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36978.aspx</link><pubDate>Fri, 14 Dec 2007 03:08:52 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36978</guid><dc:creator>lidgren</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36978.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36978</wfw:commentRss><description>We've also had problems with Viewport.Unproject when creating a ray for picking. When using x,y,1 - x,y,0 it sometimes created an inversed ray. We solved the problem by using x,y,0.75f - x,y,0.25f instead; since we normalize the result anyway.</description></item><item><title>Re: Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36696.aspx</link><pubDate>Thu, 13 Dec 2007 10:47:52 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36696</guid><dc:creator>The ZMan</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36696.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36696</wfw:commentRss><description>Can you post the solution somewhere so we can try a repro (comment out one of the versions so we can switch between it).</description></item><item><title>Viewport.Unproject inconsistency in XNA 2.0 Beta</title><link>http://forums.xna.com/forums/thread/36628.aspx</link><pubDate>Thu, 13 Dec 2007 04:58:20 GMT</pubDate><guid isPermaLink="false">4aa5dbf6-357b-46b2-b5b2-1b660a6dc370:36628</guid><dc:creator>Nightin</dc:creator><slash:comments>0</slash:comments><comments>http://forums.xna.com/forums/thread/36628.aspx</comments><wfw:commentRss>http://forums.xna.com/forums/commentrss.aspx?SectionID=56&amp;PostID=36628</wfw:commentRss><description>&lt;P&gt;When I ported my game from XNA 1.0 Refresh to XNA 2.0 (Beta), the picking isn't working properly.&lt;BR&gt;The pick ray jitters a lot and I guess it's the problem with Viewport.Unproject.&lt;BR&gt;Whenever my view matrix changed a little bit, the direction of the pick ray changed back and forth.&lt;BR&gt;I'm using the approach refered in the XNA documentation to compute the pick ray.&lt;/P&gt;
&lt;P&gt;After I implemented my own version of pick ray generation, the jitter problem went away and everything went back to normal :)&lt;/P&gt;
&lt;P&gt;This isn't happening in XNA 1.0, so I guess it's probably a potential bug in XNA 2.0.&lt;/P&gt;
&lt;P&gt;Is there anyone experienced the same problem? Tell me why this is happening.&lt;BR&gt;&lt;/P&gt;</description></item></channel></rss>