public void Proc() { result = new Vector3[camera.height, camera.width]; //Random random = new Random(); int i, j; var zero = new ZeroVector3(); for (i = 0; i < camera.height; i++) { for (j = 0; j < camera.width; j++) { result[i, j] = zero; } } for (i = yMin; i < yMax; i++) { progress = (float)(i - yMin) / (yMax - yMin); NotifyProgress(); for (j = xMin; j < xMax; j++) { result[i, j] = camera.Trace(camera.pixelRays[i, j], triangles, depth); //mgr.OnPixelFinish(ID, i, j, result); //if (pixelFinishCallback != null) //{ // pixelFinishCallback(ID, i, j, result); //} } } progress = (float)(i - yMin) / (yMax - yMin); NotifyProgress(); }
public Vector3[,] DepthScan(List <Triangle> triangles, double depthMin, double depthMax) { Vector3[,] result = new Vector3[height, width]; //var rays = CreatePixelRays(position, direction, up, width, height); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { var intersection = IntersectionTest(pixelRays[i, j], triangles); double depth = 1; Vector3 norm = null; if (intersection != null) { depth = (intersection.distance - depthMin) / (depthMax - depthMin); norm = intersection.triangle.PlaneNormal; norm.Normalize(); } else { norm = new ZeroVector3(); } //result[i, j] = new Vector3(1 - depth, 1 - depth, 1 - depth); result[i, j] = norm * (1 - depth); //new Vector3(1 - depth, 1 - depth, 1 - depth); } } return(result); }