Class Culler

  • All Implemented Interfaces:
    java.io.Serializable

    public class Culler
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected float[] m_afFrustum
      A copy of the view frustum for the input camera.
      protected Plane3f[] m_akPlane
      The world culling planes corresponding to the view frustum plus any additional user-defined culling planes.
      protected int m_iPlaneQuantity
      number of culling planes.
      protected VisibleSet m_kVisible
      The potentially visible set for a call to GetVisibleSet.
      protected Camera m_pkCamera
      The input camera has information that might be needed during the culling pass over the scene.
      protected int m_uiPlaneState
      The member m_uiPlaneState represents bit flags to store whether or not a plane is active in the culling system.
      private static long serialVersionUID  
      static int VS_MAX_PLANE_QUANTITY
      Access to the stack of world culling planes.
    • Constructor Summary

      Constructors 
      Constructor Description
      Culler​(int iMaxQuantity, int iGrowBy, Camera pkCamera)
      Construction and destruction.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void ComputeVisibleSet​(Spatial pkScene)
      This is the main function you should use for culling within a scene graph.
      void dispose()
      Delete memory.
      Camera GetCamera()
      Access to the camera.
      float[] GetFrustum()
      Access to frustum copy.
      int GetPlaneQuantity()
      Get the number of culling planes.
      Plane3f[] GetPlanes()
      Get the culling planes.
      int GetPlaneState()
      Get the culling plane state.
      VisibleSet GetVisibleSet()
      Access to the potentially visible set.
      void Insert​(Spatial pkObject, Effect pkGlobalEffect)
      The base class behavior creates a VisibleObject from the input and appends it to the end of the VisibleObject array.
      boolean IsVisible​(int iVertexQuantity, Vector3f[] akVertex, boolean bIgnoreNearPlane)
      Support for Portal::GetVisibleSet.
      boolean IsVisible​(BoundingVolume pkBound)
      Compare the object's world bounding volume against the culling planes.
      void PopPlane()
      Remove the last plane from the culling planes, if the current number of planes is not already 0.
      void PushPlane​(Plane3f rkPlane)
      Add a plane to the culling planes, if the current number of planes has not been exceeded.
      void SetCamera​(Camera pkCamera)
      Access to the camera.
      void SetFrustum​(float[] afFrustum)
      Access to frustum copy.
      void SetPlaneState​(int uiPlaneState)
      Set the culling plane state.
      int WhichSide​(Plane3f rkPlane)
      Support for BspNode::GetVisibleSet.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • VS_MAX_PLANE_QUANTITY

        public static final int VS_MAX_PLANE_QUANTITY
        Access to the stack of world culling planes. You may push and pop planes to be used in addition to the view frustum planes. PushPlane requires the input plane to be in world coordinates. public enum { VS_MAX_PLANE_QUANTITY = 32 };
        See Also:
        Constant Field Values
      • m_pkCamera

        protected Camera m_pkCamera
        The input camera has information that might be needed during the culling pass over the scene.
      • m_afFrustum

        protected float[] m_afFrustum
        A copy of the view frustum for the input camera. This allows various subsystems to change the frustum parameters during culling (for example, the portal system) without affecting the camera, whose initial state is needed by the renderer.
      • m_iPlaneQuantity

        protected int m_iPlaneQuantity
        number of culling planes.
      • m_akPlane

        protected Plane3f[] m_akPlane
        The world culling planes corresponding to the view frustum plus any additional user-defined culling planes.
      • m_uiPlaneState

        protected int m_uiPlaneState
        The member m_uiPlaneState represents bit flags to store whether or not a plane is active in the culling system. A bit of 1 means the plane is active, otherwise the plane is inactive. An active plane is compared to bounding volumes, whereas an inactive plane is not. This supports an efficient culling of a hierarchy. For example, if a node's bounding volume is inside the left plane of the view frustum, then the left plane is set to inactive because the children of the node are automatically all inside the left plane.
      • m_kVisible

        protected VisibleSet m_kVisible
        The potentially visible set for a call to GetVisibleSet.
    • Constructor Detail

      • Culler

        public Culler​(int iMaxQuantity,
                      int iGrowBy,
                      Camera pkCamera)
        Construction and destruction. The first two input parameters are used to create the set of potentially visible objects. If the camera is not passed to the constructor, you should set it using SetCamera before calling ComputeVisibleSet.
        Parameters:
        iMaxQuantity - maximum number of visible objects.
        iGrowBy - number to grow by.
        pkCamera - Camera for computing what's visible.
    • Method Detail

      • ComputeVisibleSet

        public void ComputeVisibleSet​(Spatial pkScene)
        This is the main function you should use for culling within a scene graph. Traverse the scene and construct the potentially visible set relative to the world planes.
        Parameters:
        pkScene - root node of scene to cull.
      • dispose

        public void dispose()
        Delete memory.
      • GetCamera

        public final Camera GetCamera()
        Access to the camera.
        Returns:
        Camera for computing what's visible.
      • GetFrustum

        public final float[] GetFrustum()
        Access to frustum copy.
        Returns:
        current frustum.
      • GetPlaneQuantity

        public final int GetPlaneQuantity()
        Get the number of culling planes.
        Returns:
        the number of culling planes.
      • GetPlanes

        public final Plane3f[] GetPlanes()
        Get the culling planes.
        Returns:
        the culling planes.
      • GetPlaneState

        public final int GetPlaneState()
        Get the culling plane state.
        Returns:
        the culling plane state.
      • GetVisibleSet

        public final VisibleSet GetVisibleSet()
        Access to the potentially visible set.
        Returns:
        current visible set.
      • Insert

        public void Insert​(Spatial pkObject,
                           Effect pkGlobalEffect)
        The base class behavior creates a VisibleObject from the input and appends it to the end of the VisibleObject array. Derived classes may override this behavior; for example, the array might be maintained as a sorted array for minimizing render state changes or it might be maintained as a unique list of objects for a portal system.
        Parameters:
        pkObject - object to add to the visible object set.
        pkGlobalEffect - global effect applied to object.
      • IsVisible

        public boolean IsVisible​(BoundingVolume pkBound)
        Compare the object's world bounding volume against the culling planes. Only Spatial calls this function.
        Parameters:
        pkBound - input bounding volume to compare.
        Returns:
        false if object is on negative side of planes and is culled, true otherwise.
      • IsVisible

        public boolean IsVisible​(int iVertexQuantity,
                                 Vector3f[] akVertex,
                                 boolean bIgnoreNearPlane)
        Support for Portal::GetVisibleSet.
        Parameters:
        iVertexQuantity - number of vertices
        akVertex - vertices.
        bIgnoreNearPlane - .
        Returns:
        false if the polygon is totally outside this plane, true otherwise.
      • PopPlane

        public void PopPlane()
        Remove the last plane from the culling planes, if the current number of planes is not already 0.
      • PushPlane

        public void PushPlane​(Plane3f rkPlane)
        Add a plane to the culling planes, if the current number of planes has not been exceeded.
        Parameters:
        rkPlane - plane to add.
      • SetCamera

        public final void SetCamera​(Camera pkCamera)
        Access to the camera.
        Parameters:
        pkCamera - Camera for computing what's visible.
      • SetFrustum

        public void SetFrustum​(float[] afFrustum)
        Access to frustum copy.
        Parameters:
        afFrustum - new frustum.
      • SetPlaneState

        public final void SetPlaneState​(int uiPlaneState)
        Set the culling plane state.
        Parameters:
        uiPlaneState - the culling plane state.
      • WhichSide

        public int WhichSide​(Plane3f rkPlane)
        Support for BspNode::GetVisibleSet. Determine if the view frustum is fully on one side of a plane. The "positive side" of the plane is the half space to which the plane normal points. The "negative side" is the other half space.
        Parameters:
        rkPlane - The input plane is in world coordinates and the world camera coordinate system is used for the test.
        Returns:
        +1 if the view frustum is fully on the positive side of the plane, -1 if the view frustum is fully on the negative side of the plane, or 0 if the view frustum straddles the plane.