MasteR Posted October 3, 2010 Share Posted October 3, 2010 A while back someone on the forum was working on a GUI, they posted a few video updates, but for the life of me I can't locate the threads. The video demonstrated simple rollover and clicking (visual only) functionality, the controls they had rendered to the screen were circular and the video showcased the cursor ignoring what I assume to be the transparent pixels from the texture/material. (either that or the controls were circular meshes, but I doubt it) Does anyone know the thread I'm talking about, I'd very much like to speak with the forum member responsible. As an interim or second line of thought, how would one go about ignoring transparent (alpha) pixels when camera picking, I've trialed a few approaches but need some external input. Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
macklebee Posted October 3, 2010 Share Posted October 3, 2010 I think you are referring to Roland's GUI... but from what I can tell the selection didn't ignore the square shape of the texture; it just appeared that it did since the visible circular part of the texture was close to the edges... http://leadwerks.com/werkspace/index.php?/blog/25/entry-317-image-based-gui-for-cells-final/ Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
MasteR Posted October 3, 2010 Author Share Posted October 3, 2010 That's the one, cheers. Blog entry not a forum post, explains why I could not locate it. Indeed you're right, transparent pixels are not ignored, so much for my memory. Well lets focus on the second line of thought, what is a good method (or theory) that allows picks to ignore transparent pixels. Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
macklebee Posted October 3, 2010 Share Posted October 3, 2010 i dont think he is using a pick on a 2d image... more likely just based on mouse position vs image location. Picks, as far as LE is concerned, only work on meshes and the terrain. Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
MasteR Posted October 3, 2010 Author Share Posted October 3, 2010 i dont think he is using a pick on a 2d image... more likely just based on mouse position vs image location. Picks, as far as LE is concerned, only work on meshes and the terrain. That’s cool, I'm aware. You have however sparked a new idea for 2d drawing and testing transparent pixels. Back to the question at hand: I create a simple mesh, I paint it with a material which includes transparent pixels, say the image is of a window and the glass panes are transparent. If I camera pick the mesh, I'm trying to get the pick to ignore the transparent pixels, so in effect the pick will return true only when performed on the window frame. Ideas? Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
Rick Posted October 3, 2010 Share Posted October 3, 2010 I've never done it but maybe look into TVec4 GetVertexColor(TSurface surface, int vertex=1), passing the surface that was picked? If it returns a certain color then ignore it? Would be cool to be able to ignore transparent areas with the pick directly though. Quote Link to comment Share on other sites More sharing options...
MasteR Posted October 3, 2010 Author Share Posted October 3, 2010 I've never done it but maybe look into TVec4 GetVertexColor(TSurface surface, int vertex=1), passing the surface that was picked? If it returns a certain color then ignore it? Would be cool to be able to ignore transparent areas with the pick directly though. Nifty command, Unsuccessful however, it did give me an idea but that didn't succeed either. The problem there is that a surface's vertex colour is unaffected by the surface material or texture, it will always return the draw colour. Anyone done this before? Surely ignoring transparency is required by many Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
MasteR Posted October 4, 2010 Author Share Posted October 4, 2010 OK, I devised a solution whilst nodding off last night. Initial tests have been a success. THEORY/PSEUDOCODE: (my needs are for 2D drawing, but the theory is the same for 3D) Create a new buffer the same size as the graphics window. (we only need a colour component so keep memory consumption down) Make your new colour buffer the current buffer Set the buffers drawing colour to something hideous like hot pink (or any other colour that you'll never actually use in your rendering) Render the entities to the buffer Read the pixel colour at the cursors position and store it Set the back buffer as the current buffer Render the entities to the buffer (this time to the back buffer so we can get some actual visuals) Now when you camera pick an entity at position MouseX() and MouseY(), you can check the pixel colour you stored previously (which also relates to MouseX() and MouseY()). If the pixel colour is a hideous hot pink then you know that... Even though the camera pick "hit" the entity, that specific pixel is transparent and the pick should in fact be ignored. Make sense? I'll neaten things up a bit and post an example in a few days, in the C++ section. Quote AMD Athlon 64 X2 Dual Core 6000+ (3.0 GHz) 4 GB DDR2 RAM 2 x NVIDIA GeForce 9500 GT 512 MB (SLI 1.0 GB) Windows XP Pro Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.