syn3d.ui
Class Transformator

java.lang.Object
  extended by syn3d.ui.Transformator
Direct Known Subclasses:
Frame3DBase, SynopticViewNodeXith3d.ViewTransformator

public class Transformator
extends java.lang.Object


Field Summary
protected  Matrix4f drotX
           
protected  Matrix4f drotY
           
protected  float eyeDistance
           
protected  boolean perspective
           
protected  int pos2DX
           
protected  int pos2DY
           
protected  Matrix4f rot
           
protected  float scaleFactor
           
protected  Matrix4f trans
           
protected  float transFactorX
           
protected  float transFactorY
           
protected  Vector3f vtrans
           
protected  float wsize
           
protected  Matrix4f zoom
           
protected  float zoomFactor
           
 
Constructor Summary
Transformator()
           
 
Method Summary
 void applyTransform()
          Hook for subclasses, to apply the current transformation to a relevant object This method is called internally when a change occurs.
 void changeProjection()
          Turns perspective on an off
 float getEyeDistance()
           
 int getPos2DX()
           
 int getPos2DY()
           
 Matrix4f getRot()
           
 float getScaleFactor()
           
 Matrix4f getTrans()
           
 float getTransFactorX()
           
 float getTranslationFactorY()
           
 float getWSize()
           
 Matrix4f getZoom()
           
 float getZoomFactor()
           
 void init2DPosition(int posX, int posY)
          Initialize 2D rotation algorithm with the current position as origin.
 boolean isPerspective()
           
 void reset()
          Reset all values to default
 void rotate2D(int newX, int newY)
          Does a rotation of the scene according to moves in a 2D coordinate system.
 void rotate2D(int newX, int newY, boolean inverse)
          Does a rotation of the scene according to moves in a 2D coordinate system.
 void setEyeDistance(float eyeDistance)
           
 void setPerspective(boolean p)
           
 void setPos2DX(int pos2DX)
           
 void setPos2DY(int pos2DY)
           
 void setRot(Matrix4f rot)
           
 void setScaleFactor(float scaleFactor)
           
 void setTrans(Matrix4f trans)
           
 void setTransFactorX(float transFactorX)
           
 void setTranslationFactorY(float transFactorY)
           
 void setWSize(float wsize)
           
 void setZoom(Matrix4f zoom)
           
 void setZoomFactor(float zoomFactor)
           
 void translate2D(int newX, int newY)
          Does a translation of the scene according to moves in a 2D coordinate system.
 void updateTranslateMatrix()
          Updates the translation matrix with the translation factors previously specified This is intentionally a separate function, so that it is possible to do multiple factor modifications, in both directions, then finally update the matrix at the end.
 void updateZoomMatrix()
          Updates the zoom matrix with the translation factors previously specified This is intentionally a separate function, so that it is possible to do multiple factor modifications, then finally update the matrix at the end.
 void zoom(int zoomIncrement)
          Zooms in or out of the scene according to the increment.
 void zoom2D(int newX, int newY)
          Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zoom

protected Matrix4f zoom

rot

protected Matrix4f rot

drotX

protected Matrix4f drotX

drotY

protected Matrix4f drotY

trans

protected Matrix4f trans

vtrans

protected Vector3f vtrans

pos2DX

protected int pos2DX

pos2DY

protected int pos2DY

perspective

protected boolean perspective

wsize

protected float wsize

zoomFactor

protected float zoomFactor

scaleFactor

protected float scaleFactor

eyeDistance

protected float eyeDistance

transFactorX

protected float transFactorX

transFactorY

protected float transFactorY
Constructor Detail

Transformator

public Transformator()
Method Detail

getEyeDistance

public float getEyeDistance()

setEyeDistance

public void setEyeDistance(float eyeDistance)

getScaleFactor

public float getScaleFactor()

setScaleFactor

public void setScaleFactor(float scaleFactor)

getTransFactorX

public float getTransFactorX()

setTransFactorX

public void setTransFactorX(float transFactorX)

getTranslationFactorY

public float getTranslationFactorY()

setTranslationFactorY

public void setTranslationFactorY(float transFactorY)

getWSize

public float getWSize()

setWSize

public void setWSize(float wsize)

getZoomFactor

public float getZoomFactor()

setZoomFactor

public void setZoomFactor(float zoomFactor)

setPerspective

public void setPerspective(boolean p)

isPerspective

public boolean isPerspective()

applyTransform

public void applyTransform()
Hook for subclasses, to apply the current transformation to a relevant object This method is called internally when a change occurs. It has been set public so it is possible to call it explicitely, but this should not be necessary. It does nothing by default, let subclasses do what they want.


updateTranslateMatrix

public void updateTranslateMatrix()
Updates the translation matrix with the translation factors previously specified This is intentionally a separate function, so that it is possible to do multiple factor modifications, in both directions, then finally update the matrix at the end.


updateZoomMatrix

public void updateZoomMatrix()
Updates the zoom matrix with the translation factors previously specified This is intentionally a separate function, so that it is possible to do multiple factor modifications, then finally update the matrix at the end.


init2DPosition

public void init2DPosition(int posX,
                           int posY)
Initialize 2D rotation algorithm with the current position as origin. Typically, this is related to mouse positions in X and Y. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.


rotate2D

public void rotate2D(int newX,
                     int newY)
Does a rotation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many rotate2D as required. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.

Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

rotate2D

public void rotate2D(int newX,
                     int newY,
                     boolean inverse)
Does a rotation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many rotate2D as required. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.

Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position
inverse - Inverse the direction of the rotation if true. This is used ROTATION_MODE viewing mode for the scene, in which case the scene rotates according to the mouse => in fact, the camera rotates in the opposite direction. => default is true

translate2D

public void translate2D(int newX,
                        int newY)
Does a translation of the scene according to moves in a 2D coordinate system. Use init2DPosition to position an origin, then do as many translate2D as required. Note that WSize should be set to the same value referential as the positions. This is typically a window dimension.

Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

zoom2D

public void zoom2D(int newX,
                   int newY)
Uses the 2D increments in position to compute a zoom factor, then zooms the scene accordingly.

Parameters:
newX - The new X position in 2D, typically a mouse position
newY - The new Y position in 2D, typically a mouse position

zoom

public void zoom(int zoomIncrement)
Zooms in or out of the scene according to the increment. This is an arbitrary algorithm to help create correct zoom factors. You could use setZoomFactor and then update the zoom matrix directly, with the same effect.
The added value of this function is to provide a relative and easy to manipulate way to zoom in or out, with increments like +1 or -1 for small zooms, and +10 and -10 for greater zooms, etc...
Note that WSize should be set correctly.

Parameters:
zoomIncrement - A value typically 1 or -1, but which can be greater for fast zooms. Positive values zoom in, negative values zoom out.

changeProjection

public void changeProjection()
Turns perspective on an off


reset

public void reset()
Reset all values to default


getRot

public Matrix4f getRot()
Returns:
Returns the rot.

setRot

public void setRot(Matrix4f rot)
Parameters:
rot - The rot to set.

getTrans

public Matrix4f getTrans()
Returns:
Returns the trans.

setTrans

public void setTrans(Matrix4f trans)
Parameters:
trans - The trans to set.

getZoom

public Matrix4f getZoom()
Returns:
Returns the zoom.

setZoom

public void setZoom(Matrix4f zoom)
Parameters:
zoom - The zoom to set.

getPos2DX

public int getPos2DX()
Returns:
Returns the pos2DX.

setPos2DX

public void setPos2DX(int pos2DX)
Parameters:
pos2DX - The pos2DX to set.

getPos2DY

public int getPos2DY()
Returns:
Returns the pos2DY.

setPos2DY

public void setPos2DY(int pos2DY)
Parameters:
pos2DY - The pos2DY to set.