/// <summary> /// Checks if an object is visible and adds it to the render queue /// </summary> /// <param name="camera">Current camera</param> /// <param name="movable">IMovable instance</param> internal void ProcessesVisibleObject(Camera camera, IMovable movable) { movable.FrustumCulling(camera); if (movable.IsRendered) movable.UpdateRenderQueue(this); }
/// <summary> /// Add a camera to the manager /// </summary> /// <param name="name">Name of the camera</param> public Camera CreateCamera(string name) { Camera cam; if (_cameras.TryGetValue(name, out cam)) return cam; cam = new Camera(name, _owner); _cameras.Add(name, cam); return cam; }
/// <summary> /// Performs a frustum culling against a specified camera /// </summary> /// <param name="camera">Camera</param> public virtual void FrustumCulling(Camera camera) { _inCameraSight = camera.Frustum.Intersect(_worldAabb); }
/// <summary> /// <remarks>Not supported for the Camera class </remarks> /// </summary> /// <param name="camera">Camera</param> void IMovable.FrustumCulling(Camera camera) { throw new NotSupportedException(); }
/// <summary> /// Renders a scene graph into a viewport /// </summary> /// <param name="vp">Viewport in which the rendering is sent</param> /// <param name="cam">Camera representing the point of view</param> /// <param name="queue">Queue of objects to render</param> internal void Render(Viewport vp, Camera cam, RenderQueue queue) { BeginRender(); _renderingTechnique.Render(vp, cam, queue); EndRender(); }
/// <summary> /// Remove a camera /// </summary> /// <param name="camera">Camera to remove</param> /// <returns>Return true if the camera was removed, otherwise false</returns> public bool RemoveCamera(Camera camera) { return _cameras.Remove(camera.Name); }
/// <summary> /// Finds all the visible objects in the scene /// </summary> /// <param name="cam">Current camera</param> private void FindVisibleObjects(Camera cam) { _root.FindVisibleObjects(cam, _queue, true); }
/// <summary> /// Draws the entire scene /// </summary> public void RenderScene(Viewport vp, Camera cam) { Clean(); UpdateGraph(); FindVisibleObjects(cam); _renderer.Render(vp, cam, _queue); }
/// <summary> /// Finds all visible objects attached to this scene node /// </summary> /// <param name="cam">Current camera</param> /// <param name="queue">Current render queue</param> /// <param name="addChildren">Boolean indicating if the search goes through childrens</param> internal void FindVisibleObjects(Camera cam, RenderQueue queue, bool addChildren) { for (int i = 0; i < _movablesList.Count; i++) queue.ProcessesVisibleObject(cam, _movablesList[i]); if (addChildren) { for (int j = 0; j < Childrens.Count; j++) ((SceneNode)Childrens[j]).FindVisibleObjects(cam, queue, true); } }