Esempio n. 1
0
        public static SceneHL ToHiddenLineScene(this Scene scene, Camera camera)
        {
            var cameraFrame = camera.Frame.Inverse();

            var dict = new Dictionary <Triangle, TriangleHL>();

            scene.Bodies.ForEach(body => ConvertTrianglesOfBody(body, dict, cameraFrame, camera.NearPlane));
            var trianglesHL = dict.Values.Where(triangle => triangle.Spin == TriangleSpin.counter_clockwise).ToArray();
            var edgesHL     = scene.Bodies.SelectMany(body => body.ConvertToEdgeHL(dict, cameraFrame)).FilterOutBorderEdges().ToArray();

            var sceneHL = new SceneHL
            {
                NearPlaneDistance = camera.NearPlane,
                Edges             = edgesHL,
                Triangles         = trianglesHL
            };

            return(sceneHL);
        }
Esempio n. 2
0
        public static IEnumerable <LineHL> FilterOutHiddenLines(this IEnumerable <LineHL> lines, SceneHL scene)
        {
            var nearPlaneDistance = scene.NearPlaneDistance;
            var triangles         = scene.Triangles;
            var visibleLines      = lines.AsParallel().Where(line => IsLineVisible(line, scene.NearPlaneDistance, triangles)).ToList();

            return(visibleLines);
        }