// For 'action', first set the TypeFilter and call Init. If picking is true and pickManipulatorOnly // is true, then only the currently active manipulator is tested against, which is a huge speed-up. private void Render(IRenderAction action, bool picking, bool pickManipulatorOnly) { base.BeginPaint(picking); action.Title = Camera.ViewTypeName; action.ViewportWidth = Width; action.ViewportHeight = Height; // If we're doing a picking operation, then we don't need to display the results to the user, etc. if (picking) { RenderState pickState = new RenderState(m_renderState); pickState.RenderMode &= ~(RenderMode.Textured | RenderMode.Lit | RenderMode.Alpha); pickState.OverrideChildState = RenderMode.Textured | RenderMode.Lit | RenderMode.Alpha; pickState.InheritState = 0; RenderStateGuardian.Reset(); // Manipulator picking can be further optimized to only render the manipulator. if (pickManipulatorOnly && m_manipulator != null && m_manipulatorNode != null) { // Replace the scene node's children temporarily with just our one child of interest. // Replacing the children is easier than creating a new Scene because the manipulators // need the HitRecord.GraphPath to have the full correct Scene, not a temp Scene. List <SceneNode> originalChildren = new List <SceneNode>(m_scene.Children); m_scene.Children.Clear(); m_scene.Children.Add(m_manipulatorNode); m_scene.StateStack.Push(pickState); action.PushMatrix(m_manipulatorParentToWorld, false); action.Dispatch(m_scene, Camera); action.PopMatrix(); m_scene.StateStack.Pop(); m_scene.Children.Clear(); foreach (SceneNode node in originalChildren) { m_scene.Children.Add(node); } } else { //Regular picking. Render the whole scene. m_scene.StateStack.Push(pickState); action.Dispatch(m_scene, Camera); m_scene.StateStack.Pop(); } // When picking, we don't want to display this buffer, so don't swap OpenGl buffers. // This property gets reset by base.EndPaint(). SwapBuffers = false; } else { m_scene.StateStack.Push(m_renderState); RenderStateGuardian.Reset(); action.Dispatch(m_scene, Camera); RenderAxisSystem(action); m_scene.StateStack.Pop(); } base.EndPaint(); }
/// <summary> /// Called after post visiting the SceneNode specified by the graph path</summary> /// <param name="graphPath">The graph path</param> /// <param name="action">The render action</param> /// <param name="camera">The camera</param> /// <param name="list">The traverse list</param> /// <returns></returns> public override TraverseState PostTraverse(Stack<SceneNode> graphPath, IRenderAction action, Camera camera, ICollection<TraverseNode> list) { action.PopMatrix(); return TraverseState.Continue; }
// For 'action', first set the TypeFilter and call Init. If picking is true and pickManipulatorOnly // is true, then only the currently active manipulator is tested against, which is a huge speed-up. private void Render(IRenderAction action, bool picking, bool pickManipulatorOnly) { base.BeginPaint(picking); action.Title = Camera.ViewTypeName; action.ViewportWidth = Width; action.ViewportHeight = Height; // If we're doing a picking operation, then we don't need to display the results to the user, etc. if (picking) { RenderState pickState = new RenderState(m_renderState); pickState.RenderMode &= ~(RenderMode.Textured | RenderMode.Lit | RenderMode.Alpha); pickState.OverrideChildState = RenderMode.Textured | RenderMode.Lit | RenderMode.Alpha; pickState.InheritState = 0; RenderStateGuardian.Reset(); // Manipulator picking can be further optimized to only render the manipulator. if (pickManipulatorOnly && m_manipulator != null && m_manipulatorNode != null) { // Replace the scene node's children temporarily with just our one child of interest. // Replacing the children is easier than creating a new Scene because the manipulators // need the HitRecord.GraphPath to have the full correct Scene, not a temp Scene. List<SceneNode> originalChildren = new List<SceneNode>(m_scene.Children); m_scene.Children.Clear(); m_scene.Children.Add(m_manipulatorNode); m_scene.StateStack.Push(pickState); action.PushMatrix(m_manipulatorParentToWorld, false); action.Dispatch(m_scene, Camera); action.PopMatrix(); m_scene.StateStack.Pop(); m_scene.Children.Clear(); foreach (SceneNode node in originalChildren) m_scene.Children.Add(node); } else { //Regular picking. Render the whole scene. m_scene.StateStack.Push(pickState); action.Dispatch(m_scene, Camera); m_scene.StateStack.Pop(); } // When picking, we don't want to display this buffer, so don't swap OpenGl buffers. // This property gets reset by base.EndPaint(). SwapBuffers = false; } else { m_scene.StateStack.Push(m_renderState); RenderStateGuardian.Reset(); action.Dispatch(m_scene, Camera); RenderAxisSystem(action); m_scene.StateStack.Pop(); } base.EndPaint(); }
/// <summary> /// Called after post visiting the SceneNode specified by the graph path</summary> /// <param name="graphPath">The graph path</param> /// <param name="action">The render action</param> /// <param name="camera">The camera</param> /// <param name="list">The traverse list</param> /// <returns></returns> public override TraverseState PostTraverse(Stack <SceneNode> graphPath, IRenderAction action, Camera camera, ICollection <TraverseNode> list) { action.PopMatrix(); return(TraverseState.Continue); }