As Robert says, use osgUtil for this. For starters, osgUtil easily lets you pick multiple triangles, even if they are grouped together in the same Drawable.

osgUtil was designed for intersection testing / picking. The unique color method was devised to work around the slow OpenGL 1.x GL_SELECTION render mode, and is almost certainly much much slower than osgUtil. In other words, the color method is a hack.

If you are forced to implement the color method, I would implement it in OSG as follows: - You could render and read from the back buffer, but an easier approach might be to render and read from an FBO attached to your Camera. Attach it to pick, unattach it to render normally. In either case, you'd probably do the read back in a post-draw callback attached to the Camera. - If all your pickable objects are in unique Drawables already, then you could toggle between the actual color and the pick color using BlendColor for the pick color and enabling blending when you want to pick. - If you have multiple pickable objects in the same Drawable, then I don't know an easy way for you to toggle between the actual color and the pick color, except possibly with shaders and vertex attributes.

All things considered, osgUtil is the superior design decision.
   -Paul


On 8/30/2012 2:03 AM, wh_xiexing wrote:
Dear friends:
in openGL programming . there is a method to pick the object from the scene.
rendering the scene in the back buffer, every object with an unique color .
than , rendering second time in a normal way. when the user move mouse in the
screen . read the pixel value under the mouse point . then find the color in
an prepared hashmap. comparing the color , we can known which object is 
selected.
i am wondering whether the osg can archieve the same goal ? because i want to
implement an edit function with osg . i have a mountain model composite of
hundreds of
thousand
<http://dict.bing.com.cn/?q=%e4%b8%ad%e5%9b%bd%e5%8d%9a%e5%a3%ab%e5%90%8e&FORM=BDFD#thousand>s
of triangles . and my goal is putting high resolution digital image on the
model, and fusion the image and model into a model with texture . now , the
problem i face is
that using the mouse to find the same points in the model and in the digital 
image.
can some one give me an advice.
--------------------------------------------------------------------------------
Shawl
**


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to