PDA

View Full Version : Tool Tips for 3D scene span shot



Kumar K
10-12-2007, 07:49 AM
I have a scene graph rendered with bar chats( box shapped) in 3D using openGL. The final image will be the frame buffer captured one. Now i would like to move the mouse over the image and identify the componet. However i was succesful in doing that for scatter plot using gluProject API to extract the screen coods.


Scatter Plot looks like this:
http://filer.case.edu/~dbh10/eecs466/3dData.png

now in case of bar i need to extract the screen region.
bar plot looks similar to this :
http://www.statsoft.com/textbook/popups/popup110.gif

Thank you,
kumar.k

Kumar K
10-16-2007, 11:23 PM
Looks like most of you havent understood my above question, let me try explaining it once again.

My application Flow is like this :
1) init openGL.
2) Render the Scene Graph.
3) capture the frame buffer as image.
4) Finish openGL context.
5) render the captured image using gdi on the window.

In this process i would like to add few features like tooltips. For scatter plot I know the 3D point and i can get the corresponding 2D point using gluproject. now in the case of bar chat as shown in the above posted image, one box represent one point (x,y,z), my problem over here is if my mouse is over that box i would like to display the tooltip showing corresponding (x,y,x) values. My idea to implement this was to identify the outer edges of the individual box rendered in the above image and then project that outer edged polygon on to the screen for 2D screen coordinates and then while mouse move check if the 2D point is inside the screen projected polygon. Depth can be handled differently.

If you guys understood my requirement let me know if i am on the right track or Please suggest and give your valuble advises.

Ffelagund
10-17-2007, 01:52 PM
About steps 4 and 5, cant you directly draw the gl render into the screen rather than using GDI? And about the other question, the simplest solution is using an OpenGL mechanism called Picking. With picking, you assign an ID to a group of primitives (in your case, a whole bar for instance) and it returns to you a list of ID's that were under the mouse, ordered by it's Z, so taking the top of them will give you the bar that is directly under the mouse. Google for GL_SELECTION and picking for tutorials. There are many about this matter.

soconne
10-17-2007, 07:53 PM
Check out the following tutorial I wrote a while back. Its exactly what you need.
http://gpwiki.org/index.php/OpenGL_Selection_Using_Unique_Color_IDs

Basically what you want to do, is when you detect that the mouse has not moved for a certain period of time, then render your entire scene into the backbuffer, but when rendering your blocks in the graph, assign each a unique color ID. When you render them, use these colors with lighting, texturing, ect... turned off.

After all of them are rendered, call glReadPixels to get the current pixel color underneath your cursor. Then when you retrieve the RGBA color value, loop through all your blocks and see which one matches that color. When you find it, you know what tooltip to display.

Then call glClear() to get rid of the contents and render as usual. Its very easy to implement and much easier to understand that using OpenGL's selection mechanism.

Kumar K
10-18-2007, 01:50 AM
the simplest solution is using an OpenGL mechanism called Picking. With picking, I dont want to use the picking for mouse move tooltips, however i am doing that when my mouse Left button is down selections are already implemented for mouse click, however this selection process will go thru the render process which is expensive even if i have a small pixel range around in gluPickMatrix().

i want to store the meta information(screen point and corresponding polygon ID rendered) about the scene rendered in openGL and while mouse move i want to fecth the polygon under the mouse from that meta info data.


Basically what you want to do, is when you detect that the mouse has not moved for a certain period of time, then render your entire scene into the backbuffer, but when rendering your blocks in the graph, assign each a unique color ID. When you render them, use these colors with lighting, texturing, ect... turned off. This is really a good idea which i was aware of , again it requires renderpass in backbuffer,
But i still love to see if we can achive this more quickly by creating some kind geometry projected to viewing plane and get the screen polygons as meta information, and while mouse move simply go thru point in/our of polygon.

This was just my stupid mind... :)
If no other solution comes up then i would like to modify my current renderer with this flow using colorID.

1) init openGL.
2) Render the Scene Graph.
3) capture the frame buffer as image.
4) capture color ID in back buffer as meta info
4) Finish openGL context.
5) render the captured image using gdi on the window.

while mouse move.
1) get pixel color and compare with meta info.
2) display the hitted polygon x,y,z values in tooltip.