jglcore
Class JGL_3DBsp

java.lang.Object
  extended by jglcore.JGL_3DBsp
All Implemented Interfaces:
JGL_3DStruct

public final class JGL_3DBsp
extends java.lang.Object
implements JGL_3DStruct

Dynamic BSP tree. Provides, besides display functionalities, the possibility to add JGL_3DMovable objects (these ones are removed after each BSP display).
JGL_3DBsp class also provides a mechanism to modify its content by cleaning/adding faces (useful to emulate a real-time z-buffer or to manage animated meshes).

Author:
Nicolas Devere

Field Summary
 java.util.Vector faces
          Node's faces list.
 int facesSize
          Faces number in the node
 JGL_3DBsp front
          Front son
 java.util.Vector movables
          Movable objects's sorted list.
 JGL_3DPlane plane
          Node's split plane
 JGL_3DBsp rear
          Rear son
 int type
          Instance's type (-1 : solid leaf / 0 : node / 1 : empty leaf)
 
Constructor Summary
JGL_3DBsp()
          Constructs an empty BSP (empty leaf).
JGL_3DBsp(int _type)
          Constructs a BSP given its type.
 
Method Summary
 void addFace(JGL_3DTriangle face)
          Adds a face in the BSP.
 void addMovable(JGL_3DMovable movable)
          Adds a JGL_3DMovable object in the BSP.
 void clear()
          Clears the BSP (resets all nodes as leaves).
 void display(JGL_3DVector eye)
          Displays the BSP according to the specified eye position.
 void display(JGL_3DVector eye, JGL_3DVector[] cone)
          Displays the BSP according the specified vision cone (an eye position and 4 points to make a 4 sides pyramid).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plane

public JGL_3DPlane plane
Node's split plane


type

public int type
Instance's type (-1 : solid leaf / 0 : node / 1 : empty leaf)


front

public JGL_3DBsp front
Front son


rear

public JGL_3DBsp rear
Rear son


faces

public java.util.Vector faces
Node's faces list.
WARNING : its size is given by the faces_size variable, not by the faces.size() method !!


facesSize

public int facesSize
Faces number in the node


movables

public java.util.Vector movables
Movable objects's sorted list.
WARNING : movable objects are removed after each display. An insertion over each frame is needed to keep a constant render.

Constructor Detail

JGL_3DBsp

public JGL_3DBsp()
Constructs an empty BSP (empty leaf).


JGL_3DBsp

public JGL_3DBsp(int _type)
Constructs a BSP given its type.

Parameters:
_type - : the BSP type (-1 : solid leaf / 0 : node / 1 : empty leaf)
Method Detail

addFace

public void addFace(JGL_3DTriangle face)
Adds a face in the BSP.

Parameters:
face - : the face to add

addMovable

public void addMovable(JGL_3DMovable movable)
Adds a JGL_3DMovable object in the BSP. WARNING : the object will be removed after the BSP display.

Parameters:
movable - : the object to add

clear

public final void clear()
Clears the BSP (resets all nodes as leaves).


display

public final void display(JGL_3DVector eye)
Displays the BSP according to the specified eye position.

Specified by:
display in interface JGL_3DStruct
Parameters:
eye - : the eye position

display

public final void display(JGL_3DVector eye,
                          JGL_3DVector[] cone)
Displays the BSP according the specified vision cone (an eye position and 4 points to make a 4 sides pyramid).

Specified by:
display in interface JGL_3DStruct
Parameters:
eye - : the eye position (cone base)
cone - : the vision cone represented by 4 points