XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Picking with Triangle-Accuracy

Last post 1/12/2008 2:23 AM by Sorcerer. 7 replies.
  • 1/10/2008 3:32 AM

    Picking with Triangle-Accuracy

    Is there any chance to use the Picking with Triangle-Accuracy without using the content pipeline?
    http://www.youtube.com/alexmbr
  • 1/10/2008 8:19 AM In reply to

    Re: Picking with Triangle-Accuracy

    Sure you can... why not? Vertex data on models are not write only anymore. In 1.0 Refresh it was alreadedone.
  • 1/10/2008 9:47 AM In reply to

    Re: Picking with Triangle-Accuracy

    Can someone show me a working example? I spent all night trying to do this with no success.

    This is why I need this: Gizmos.  I need to use the mouse to click on a gizmo arrow.

    http://www.youtube.com/alexmbr
  • 1/10/2008 12:56 PM In reply to

    Re: Picking with Triangle-Accuracy

    You can do this at runtime, but it's not easy: to make the code robust you need to parse the vertex declaration to find out the location and format of the position field, then extract the relevant sequence of bytes and convert them from whatever format they are in (this will often be a Vector3, but could be other formats as well), and you also need to take account of the index data. The GPU mesh format is optimized for rendering, and not particularly easy to work with on the CPU side.

    Why can't you use a content processor for this? It is much easier that way!

    Alternatively, I wonder whether you even need to do a true mesh hit test to implement a gizmo? That seems like a simple enough shape that you could just do 2D geometric tests: check if the point is inside the central circle, test whether it is within a specified distance of one of the axis lines, etc. The nice thing about doing that is that you can tweak the hit-test tolerances differently to the visual appearance: to make a gizmo feel good, you might want the axis lines to have a slightly wider hit region than how they are rendered, for instance.
    XNA Framework Developer - blog - homepage
  • 1/10/2008 1:31 PM In reply to

    Re: Picking with Triangle-Accuracy

    "Why can't you use a content processor for this? It is much easier that way!"

     

    Well, because the scene editor will also allow the user to scale the models, making the code to have to calculate everything again anyway.

    http://www.youtube.com/alexmbr
  • 1/10/2008 2:47 PM In reply to

    Re: Picking with Triangle-Accuracy

    I assume you do the scaling by modifying the world transform on your objects? If so that should work pretty easily alongside the approach used in the sample: I believe it already takes in a per-object world transform so the collision ray can take this into account.
    XNA Framework Developer - blog - homepage
  • 1/10/2008 3:03 PM In reply to

    Re: Picking with Triangle-Accuracy

    Shawn Hargreaves:
    I assume you do the scaling by modifying the world transform on your objects? If so that should work pretty easily alongside the approach used in the sample: I believe it already takes in a per-object world transform so the collision ray can take this into account.

    No, it doesn't! I tried to add the scaling on the sample, and the triangles selection became all messed up.

    http://www.youtube.com/alexmbr
  • 1/12/2008 2:23 AM In reply to

    Re: Picking with Triangle-Accuracy

    Shawn Hargreaves:

    Alternatively, I wonder whether you even need to do a true mesh hit test to implement a gizmo? That seems like a simple enough shape that you could just do 2D geometric tests: check if the point is inside the central circle, test whether it is within a specified distance of one of the axis lines, etc. The nice thing about doing that is that you can tweak the hit-test tolerances differently to the visual appearance: to make a gizmo feel good, you might want the axis lines to have a slightly wider hit region than how they are rendered, for instance.

     

    Well, because I also need to select objects with the mouse.

    http://www.youtube.com/alexmbr
Page 1 of 1 (8 items) Previous Next