public void Build(SceneGraph scene) { BuildCache = new Dictionary<string, object>(StringComparer.CurrentCultureIgnoreCase); var camera = scene.First<SceneCamera>(); Guard.NotNull(camera, "Couldn't find camera in scene"); var cameras = scene.OfType<SceneCamera>().ToArray(); Cameras = new Camera[cameras.Length]; for (int i = 0; i < cameras.Length; i++) { Cameras[i] = new Camera(); Cameras[i].LookAt(cameras[i].Position, cameras[i].Direction, cameras[i].Up); Cameras[i].Fov = camera.Fov; Cameras[i].BuildView(); } var sceneGeometryData = scene.First<SceneMeshData>(); Guard.NotNull(sceneGeometryData, "Couldn't find sceneGeometryData in scene"); var sceneGeometry = scene.Subset<SceneMeshEntity>().ToArray(); Guard.NotNullOrEmpty(sceneGeometry, "No scene geometry present"); var sceneMaterials = scene.Subset<SceneMaterial>().ToArray(); Guard.NotNullOrEmpty(sceneMaterials, "No scene materials present"); var sceneLights = scene.Subset<SceneLightsource>().ToArray(); Guard.NotNullOrEmpty(sceneLights, "No scene lightsources present"); var sceneResources = scene.Subset<SceneResourceReference>().ToArray(); Camera = new Camera(); Camera.LookAt(camera.Position, camera.Direction, camera.Up); Camera.Fov = camera.Fov; Camera.BuildView(); Tracer.WriteLine("Start Building Materials"); this.BuildMaterials(sceneMaterials, sceneResources); BuildCache.Add("Materials", sceneMaterials); Tracer.WriteLine("Start Building Geometry"); var areaLights = sceneLights.Where(lt => lt.LightType == LightSourceTypes.Area).ToArray(); if (areaLights.Any()) { BuildCache.Add("AreaLights", areaLights.ToArray()); } this.BuildGeometry(sceneGeometryData, sceneGeometry, areaLights.Any(), areaLights); this.BoundingSphereRadius = sceneGeometryData.BoundingSphereRadius; BuildCache.Add("Geometry", sceneGeometry); Tracer.WriteLine("Start Building Lightsources"); this.BuildLights(sceneLights); Session.Frame.TopObject = this.topObject; }