Quoting [EMAIL PROTECTED]: > Hi opensg users, > > I work on a gesture based interaction technique, and I want to get the > objects behind each point of my 2D gesture. > > So I'm trying to make an "Identification buffer" so as to overcome the > slowness of getObject() method (IntersectAcction) .(which take 6 secs > for 300 points). So I make a deep clone of my root, and traverse it so > as to replace all geometrie materials by a unique color coresponding > to the node being drawn. After that, I render wy color-modified > environement into an FBOViewport,and try to retreive the texture to > the RAM. My personal getObject() method will retreive the color on > this buffer to deduce the NodePtr behind the pixel.
Side issue here: It might be faster to do a simple "cloneTree" and insert MaterialGroup nodes above each material node (geometry/materialgroup). However, if what you do now is fast enoough, don't bother. > So my first question is maybe an OpenGL one. How to disable all GL states > like > GL_BLEND,GL_DITHER,GL_FOG,GL_LIGHTING,GL_TEXTURE_xD so as to draw only > my color whithout the lighting model ? do I simply need to call > glDisable() (if I do that, it segfaults at glReadPixels), and let > opensg further re-enable them ? or can I set theses enums somewhere > else? Or How can I switch to glShadeModel(GL_FLAT) ? You have to set up your own chunkmaterial for this, with chunks for most of the things you want to control. I think ShadeModel can be set by using a PolygonChunk. I don't think you'll need much more than that and a MaterialChunk (with lit=false,emission=your color, everything else=black) in a chunkmaterial. > I also read something about the BlendEquation(SRC COLOR / DEST COLOR) > in the opengl specs, so as to don't apply lighting model, but I'have > no idea on how to use it in OpenSG... I'm blocked by this color problem. For doing an ID-buffer, you do not want any blending. (If I understand things right). Blending should be disabled. (I.e. don't use a BlendChunk at all) Lighting model is disabled by setting Lit=false in a MaterialChunk, as in above paragraph. > Secondly, I add a TextureChunk to FBOViewport, and I attach an Image > with no data to this texture chunk. Do I need to allocate this data > before rendering so as to be sure to get results (experimentaly, there > is no difference in my case) ? Then, I set the TextureChunk internal > format to GL_INT, and I call glReadPixels with (.. GL_RGBA,GL_INT ..), > I suppose it's the better choice for my case, but I'm not sure. If > sombody can confirm.. First, a "regular" viewport with an ImageGrabForeground might be a simpler way do get the readback. (Just put it before your regular viewport in your window, then the user won't see it.) Anyway, you won't have to bother with formats then. If you are still bent on FBOViewport, the internal format of the texture should probably be GL_RGB or GL_RGBA. To preallocate data, I add an Image with width/height (but not data) to the TextureChunk. > Thirdly I retreive the buffer with glReadBuffer(0x8CE0), and I didn' > found a method to get the real current GL_COLOR_ATTACHMENTx_EXT > identification of the FBOViewport buffer. Does it exists a method for > that ? (FboViewport seems to handle multiple buffers internaly, can I > use them into a single FboViewport) The Buffer is a texture, so you need to use glGetTexImage() or something similar. The texture id is stored in the TextureChunk. I'd still recommend the ImageGrabForeground though, which handles this better & simpler. The multiple-buffer stuff is for rendering to several buffers/textures at the same time, using gl_Fragdata[x] as destination. I don't think that's what you need for this project. (Unless you have 2^32 different ids. :) > ( I try some mad trick like > win->getGLObjectId(getTextures(0)->getGLId()) but it doesn't seems to > work.... ) With glGetTexImage, it probably would. :) OpenSG lacks a good way of getting texture data back, so you'd have to do it that way if you are rendering to a texture. The ImageGrabForeground, however, grabs the framebuffer, which is what you actually want. > PS : A the beginning, I try to derivate from RenderAction To > dynamicaly assign new colors to objects just before them being drawn, > while storing these <color/NodePtr> pairs in a map.... so as to avoid > a deepCloning. but I lost myself in the code... I didn't understant > how the tree is converted to OpenGL calls, ( at which moment the tree > parsed to simplify glCalls, and how.. ). If somebody have some example > around this problem, it would be the better ! I don't know much about the Action classes, but I think RenderAction is a bit tricky as it sorts objects after material a bit (transparent, sort_key) etc. I think the DrawAction is much simpler, as it just walks the graph and draws whatever comes along. It might be a better choise for you. I think Dirk & Co might have a better solution to this problem, as they have more experience with OpenSG's internals. It sounds like an interesting project though. I hope you'll get it running. Cheers, /Marcus ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Opensg-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opensg-users
