/// <summary> /// Constructor</summary> /// <param name="renderStateGuardian">Render state guardian</param> public PickAction(RenderStateGuardian renderStateGuardian) : base(renderStateGuardian) { m_selectionBuffer = new int[65536]; m_openGlHits = 0; m_pickTolerance = 3.0f; m_viewFrust0 = new Frustum(); }
/// <summary> /// Registers all of the default render state handlers on the supplied RenderStateGuardian</summary> /// <param name="rsg">RenderStateGuardian to register default handlers on</param> public static void InitRenderStateGuardian(RenderStateGuardian rsg) { rsg.RegisterRenderStateHandler((int)RenderMode.Smooth, CommitSmooth); rsg.RegisterRenderStateHandler((int)RenderMode.Wireframe, CommitWire); rsg.RegisterRenderStateHandler((int)RenderMode.Alpha, CommitAlpha); rsg.RegisterRenderStateHandler((int)RenderMode.Lit, CommitLighting); rsg.RegisterRenderStateHandler((int)RenderMode.DisableZBuffer, CommitZBuffer); rsg.RegisterRenderStateHandler((int)RenderMode.Textured, CommitTextures); rsg.RegisterRenderStateHandler((int)RenderMode.CullBackFace, CommitCullBackFace); rsg.RegisterRenderStateHandler((int)RenderMode.DisableZBufferWrite, CommitDepthMask); }
// 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> /// Constructs a RenderAction</summary> /// <param name="renderStateGuardian">Render state guardian</param> public RenderAction(RenderStateGuardian renderStateGuardian) { m_renderStateGuardian = renderStateGuardian; Clear(); }