FacePicker Sample

Aug 19, 2010 at 4:51 PM
Edited Aug 19, 2010 at 5:45 PM

Thanks for making concerted effort of constantly expanding and improving the quality of the samples, it really help newbie like myself to learn Silverlight 3D through Balder.

I have been scanning through the sample for ideas how to determine the texture coordinate of the hit point in triangle and I was joy when I  found the FacePicket sample.

        private void Box_MouseMove(object sender, Input.MouseEventArgs args)
            var pickRay = Game.Viewport.GetPickRay((int)args.Position.X, (int)args.Position.Y);
            Face face;
            int faceIndex;
            float faceU;
            float faceV;
            var distance = Box.Intersects(pickRay, out face, out faceIndex, out faceU, out faceV);
            if( null != distance )
                Visualizer.FaceIndex = faceIndex;

Is there a possibility to determine the "Point in Triangle" from the method above.

What exactly is faceU and faceV. Is it related to texture U and V coordinate of the ray hit point in the triangle.?

if not, a sicnere request for an improved tutorial or sample illustrating how to do that.


Aug 19, 2010 at 4:55 PM
Edited Aug 19, 2010 at 5:32 PM

I wonder if it is a good idea to have objects based on geometry class to return a Class (e..g Hitdata) that contain information about the hit point on the triangle, given the screen coordinate of the mouse position.

Some of the possible attributes of the class are:  local vector coordinates (x,yz) and texture coordinates (u,v) so that it is possible to use these coordinate to attach a primitive geometry tothe local vector coordinate or to change the texture pixel color corresponding to the (u,v).

This would be an early christmas gift for me. :-)

Thanks again for this excellent pioneering effort.

Aug 19, 2010 at 7:08 PM


There is a second set of events you might want to have a look at - manipulation.


It gives you all the information you need in the event args.

The FaceU and V are X,Y within the face/triangle.  

I've been thinking about providing the exact position in 3D space for the intersection as well. Probably will do that soon. 

Aug 20, 2010 at 12:12 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 20, 2010 at 12:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 3, 2010 at 2:54 PM
Edited Oct 3, 2010 at 2:54 PM

Hi i have been trying to exploide the code from face picker example inside layoutRoot_mouseMove event

also i tryed to explicitely call prepareBoundingSphere but _geometryObject.Intersects always returns null distance !

the pickRay looks allright though..

is this a bug in balder source from 2010-09-24 : 1047 ?

or has the functionality changed ?