Drawing3d.PrimIdObj[,] ReadPickingBuffer(int x, int y, int w, int h) { uint[,] Pixels = new uint[w, h]; Drawing3d.PrimIdObj[,] Result = new Drawing3d.PrimIdObj[w, h]; ShaderKind Save = Device.ShaderKind; Device.ShaderKind = ShaderKind.SmallShader; SnapBuffer.ReadPixel(x, y, Pixels); for (int i = 0; i < w; i++) { for (int j = 0; j < h; j++) { Result[i, j].Object = (short)(Pixels[i, j] & 0XFFFF); if (Result[i, j].Object != 0) { } Result[i, j].PrimId = (short)(Pixels[i, j] >> 16); if (Result[i, j].PrimId != 0) { } } } Device.ShaderKind = Save; return(Result); }
int IndexOf(Drawing3d.PrimIdObj R) { for (int i = 0; i < Intermediate.Count; i++) { if ((Intermediate[i].Object == R.Object)) { return(i); } } return(-1); }
Drawing3d.PrimIdObj[,] SubArray(int x, int y, int Width, int Height) { Drawing3d.PrimIdObj[,] Result = new Drawing3d.PrimIdObj[Width, Height]; if (ObjectBuffer == null) { return(Result); } for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { if ((i + x >= 0) && (j + y >= 0) && (i + x < ObjectBuffer.GetLength(0)) && (j + y < ObjectBuffer.GetLength(1))) { Result[i, j] = ObjectBuffer[i + x, j + y]; } } } return(Result); }