jglcore
Class JGL_3DMovable

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

public class JGL_3DMovable
extends java.lang.Object
implements JGL_3DStruct

Representation of a movable 3D object witch can be insert into a BSP tree. A JGL_3DMovable object can stores a JGL_3DStruct object and provides methods to move it (translation, rotation, scale).

Author:
Nicolas Devere

Constructor Summary
JGL_3DMovable(JGL_3DStruct _struct)
          Constructs a JGL_3DMovable object given a JGL_3DStruct object.
 
Method Summary
 void display(JGL_3DVector eye)
          Displays the object according to the specified eye position.
 void display(JGL_3DVector eye, JGL_3DVector[] cone)
          Displays the object according the specified vision cone (an eye position and 4 points to make a 4 sides pyramid).
 float getEyeSquareDistance()
          Returns the last computed eye square distance.
 JGL_3DVector getPosition()
          Returns the object's current position.
 JGL_3DStruct getStruct()
          Returns the JGL_3DStruct object currently stored.
 void identity()
          Resets the object's situation (sets its matrix to identity).
 void rotate(float angle, float x, float y, float z)
          Applies a rotation (in degrees) to the object around the specified axis.
 void rotate(float angleX, float angleY, float angleZ, int order)
          Applies a rotation to the object with the specified Euler angles, in the chosen order (the angles order is given by constants from the JGL class.
 void scale(float x, float y, float z)
          Applies a scale transformation on 3 axis to the object.
 void setEyeSquareDistance(JGL_3DVector eye)
          Computes the square of the distance between the object and the specified eye position.
 void setStruct(JGL_3DStruct _struct)
          Stores the specified JGL_3DStruct object.
 void translate(float x, float y, float z)
          Applies a translation to the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGL_3DMovable

public JGL_3DMovable(JGL_3DStruct _struct)
Constructs a JGL_3DMovable object given a JGL_3DStruct object.

Parameters:
_struct - : the 3D object implementing the JGL_3DStruct interface
Method Detail

setStruct

public void setStruct(JGL_3DStruct _struct)
Stores the specified JGL_3DStruct object.

Parameters:
_struct - : the 3D object implementing the JGL_3DStruct interface

getStruct

public JGL_3DStruct getStruct()
Returns the JGL_3DStruct object currently stored.

Returns:
the JGL_3DStruct object currently stored

getPosition

public final JGL_3DVector getPosition()
Returns the object's current position.

Returns:
the object's current position

identity

public final void identity()
Resets the object's situation (sets its matrix to identity).


translate

public final void translate(float x,
                            float y,
                            float z)
Applies a translation to the object.

Parameters:
x - : the X axis translation value
y - : the Y axis translation value
z - : the Z axis translation value

rotate

public final void rotate(float angle,
                         float x,
                         float y,
                         float z)
Applies a rotation (in degrees) to the object around the specified axis.

Parameters:
angle - : the rotation angle (in degrees)
x - : the rotation axis's X value
y - : the rotation axis's Y value
z - : the rotation axis's Z value

rotate

public final void rotate(float angleX,
                         float angleY,
                         float angleZ,
                         int order)
Applies a rotation to the object with the specified Euler angles, in the chosen order (the angles order is given by constants from the JGL class. Ex : JGL.ZXY means that the matrix is rotated around Z, then X, then Y).

Parameters:
angleX - : the rotation angle around the X axis
angleY - : the rotation angle around the Y axis
angleZ - : the rotation angle around the Z axis
order - : the 3 axis rotations order

scale

public final void scale(float x,
                        float y,
                        float z)
Applies a scale transformation on 3 axis to the object.

Parameters:
x - : the X axis scale value
y - : the Y axis scale value
z - : the Z axis scale value

setEyeSquareDistance

public void setEyeSquareDistance(JGL_3DVector eye)
Computes the square of the distance between the object and the specified eye position.

Parameters:
eye - : the eye position

getEyeSquareDistance

public float getEyeSquareDistance()
Returns the last computed eye square distance.

Returns:
the last computed eye square distance

display

public final void display(JGL_3DVector eye)
Displays the object 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 object 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