PDA

View Full Version : Frame selection



we will change the world
02-16-2012, 11:56 PM
Hi everyone,i have some trouble in frame selection, when i select the primitives in the frame. it just select the visible primitives, but the invisible primitives con'be selected. there is my code,any answer is well received.

byte[] pixels = new byte[(width * 3) * height];
gl.ReadBuffer(0x405);
gl.PixelStorei(0xd05, 1);
gl.ReadPixels(x, num3, width, height, 0x1907, 0x1401, pixels);
int num7 = -1;
int num8 = width * height;
for (int i = 0; i < num8; i++)
{
int index = i * 3;
int item = (pixels[index] + (pixels[index + 1] << 8)) + (pixels[index + 2] << 0x10);
if ((item < base.entities.Count) &amp;&amp; (item != num7))
{
if (!list.Contains(item))
{
list.Add(item);
}
num7 = item;
}
}

BionicBytes
02-17-2012, 02:29 AM
it just select the visible primitives, but the invisible primitives con'be selected
How can you select something which is invisible? By invisible do you mean 'was not even rendered'?

we will change the world
02-22-2012, 01:28 AM
the invisible primitive means that it is blocked by the visible one.

Dan Bartlett
02-26-2012, 05:39 AM
You have to use your own ray-casting code for this, since any data about previously drawn primitives is lost once it has been overwritten. You could use glRenderMode(GL_SELECT) (http://www.opengl.org/resources/faq/technical/selection.htm#sele0020) for what you want, but this has been dropped from core OpenGL and can be very slow (http://www.opengl.org/wiki/Common_Mistakes#Selection_and_Picking_and_Feedback _Mode).