yaarq.sys
Class yrqOverlayVisual

java.lang.Object
  |
  +--yaarq.sys.yrqVisual
        |
        +--yaarq.sys.yrqOverlayVisual

public class yrqOverlayVisual
extends yrqVisual

This class extends the yrqVisual class providing support for textured geometry.

The overlay class provides support for 2D sprites seemingly positioned exactly on the 2D screen plane. Normally, such operations would be done in the postRender method of the Java3D canvas, but the update routines used by Java3D have very low performance, so this class creates 3D objects and manipulates them to appear as if they were twodimensional and screen- aligned.

OverlayVisuals are internally attached to the viewport transform group to allow for automatic viewport alignment.

TODO: When allowing fov changes to viewport, change transform code!


Field Summary
 
Fields inherited from class yaarq.sys.yrqVisual
COLOR_AMBIENT, COLOR_DIFFUSE, COLOR_EMISSIVE, COLOR_SPECULAR, m_parent, MODE_ADD, MODE_BLEND, MODE_NONE, TEXTURE_DOT3BUMP, TEXTURE_LIGHTMAP, TEXTURE_MATERIAL, TEXTURE_REFLECT
 
Constructor Summary
yrqOverlayVisual(yrqEngine a_engine, javax.media.j3d.Texture2D a_texture, javax.vecmath.Point2d a_position, int a_mode, float a_transparency)
          Constructs a new overlayvisual using the passed parameters.
yrqOverlayVisual(yrqEngine a_engine, javax.media.j3d.Texture2D a_texture, javax.vecmath.Point2d a_position, int a_width, int a_height, int a_mode, float a_transparency)
          Constructs a new overlayvisual using the passed parameters.
 
Method Summary
 void attach(javax.media.j3d.Group a_group)
          This method attaches the overlay to a parent.
 void detach()
          This method detaches the overlay to a parent.
 javax.vecmath.Point2d getPosition()
          This function retrieves the current location of the overlay in screen coordinates
 javax.media.j3d.Texture2D getTexture()
          This function returns the texture used by the overlay
 int getTransparencyMode()
          Returns the transparency mode of the visual.
 float getTransparencyValue()
          Returns the transparency value for this visual.
 void setPosition(javax.vecmath.Point2d a_pos)
          This method sets the location of the overlay, in screen coordinates (pixels).
 void setRotation(double a_angle)
          This method sets the rotation for the overlay visual.
 void setTexture(javax.media.j3d.Texture2D a_texture)
          This method sets the texture to use for the overlay.
 void setTextureAnimation(double a_left, double a_top, double a_width, double a_height)
          This function sets a continuous texture animation to the base material texture.
 void setTextureAnimation(int a_clipIndex, int a_clipCountX, int a_clipCountY)
          This function set a clip-based texture animation to the base material texture.
 void setTransparency(float a_alpha, int a_mode)
          Sets the transparency factor for the visual.
 
Methods inherited from class yaarq.sys.yrqVisual
getBaseShape3D, getBumpShape3D, getGeometry, getParent, getTexture, setBrightness, setColor, setGeometry, setShininess, setTexture
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

yrqOverlayVisual

public yrqOverlayVisual(yrqEngine a_engine,
                        javax.media.j3d.Texture2D a_texture,
                        javax.vecmath.Point2d a_position,
                        int a_mode,
                        float a_transparency)
Constructs a new overlayvisual using the passed parameters. Width and height are set to texture width and height. This is useful for still images.

Parameters:
a_texture - The texture to use for the overlay
a_position - The initial position of the overlay
a_mode - The transparency mode of the visual. Use one of the MODE_xxx constants of yrqVisual
a_transparency - The initial transparency of the visual

yrqOverlayVisual

public yrqOverlayVisual(yrqEngine a_engine,
                        javax.media.j3d.Texture2D a_texture,
                        javax.vecmath.Point2d a_position,
                        int a_width,
                        int a_height,
                        int a_mode,
                        float a_transparency)
Constructs a new overlayvisual using the passed parameters. Width and height are configurable. This is useful for displaying animations.

Parameters:
a_texture - The texture to use for the overlay
a_position - The initial position of the overlay
a_height - The pixel height of the overlay
a_mode - The transparency mode of the visual. Use one of the MODE_xxx constants of yrqVisual
a_transparency - The initial transparency of the visual
Method Detail

attach

public void attach(javax.media.j3d.Group a_group)
This method attaches the overlay to a parent. Overrides the visuals method to take into account the transform needed for aligning the overlay

Overrides:
attach in class yrqVisual
Parameters:
a_group - The group to which to attach

detach

public void detach()
This method detaches the overlay to a parent. Overrides the visuals method to take into account the transform needed for aligning the overlay

Overrides:
detach in class yrqVisual

getPosition

public javax.vecmath.Point2d getPosition()
This function retrieves the current location of the overlay in screen coordinates

Returns:
Coordinates of the overlay in pixel

getTexture

public javax.media.j3d.Texture2D getTexture()
This function returns the texture used by the overlay

Returns:
the texture used by the overlay

getTransparencyMode

public int getTransparencyMode()
Returns the transparency mode of the visual. One of the MODE_xxx constants.

Overrides:
getTransparencyMode in class yrqVisual
Returns:
Global transparency value of the visual

getTransparencyValue

public float getTransparencyValue()
Returns the transparency value for this visual. Usage of this value is dependend on the transparency mode set for the visual.

Overrides:
getTransparencyValue in class yrqVisual
Returns:
Global transparency value of the visual

setPosition

public void setPosition(javax.vecmath.Point2d a_pos)
This method sets the location of the overlay, in screen coordinates (pixels). All calculations needed to align the internally used geometry are done automatically.

Parameters:
a_pos - The new location, in screen pixel coordinates, of the overlay

setRotation

public void setRotation(double a_angle)
This method sets the rotation for the overlay visual. The visual is always rotated around its center. Angle is given in radians.

Parameters:
a_angle - Rotation angle in radians.

setTexture

public void setTexture(javax.media.j3d.Texture2D a_texture)
This method sets the texture to use for the overlay. Internally, an according geometry is created and set to the visual to match the texture.

Parameters:
a_texture - The texture to use for the overlay

setTextureAnimation

public void setTextureAnimation(double a_left,
                                double a_top,
                                double a_width,
                                double a_height)
This function sets a continuous texture animation to the base material texture. For details, see yrqVisual.

Overrides:
setTextureAnimation in class yrqVisual
Parameters:
a_left - Left clip position, normalized (0-1)
a_top - Top clip position, normalized (0-1)
a_width - Width of clip to use, normalized (0-1)
a_height - Height of clip to use, normalized (0-1)

setTextureAnimation

public void setTextureAnimation(int a_clipIndex,
                                int a_clipCountX,
                                int a_clipCountY)
This function set a clip-based texture animation to the base material texture. For details, see yrqVisual.

Overrides:
setTextureAnimation in class yrqVisual
Parameters:
a_clipIndex - Index of the clip within the texture
a_clipCountX - Number of clips in X direction
a_clipCountY - Number of clips in Y direction

setTransparency

public void setTransparency(float a_alpha,
                            int a_mode)
Sets the transparency factor for the visual. Transparency can be additive, blended or disabled, pass one of the MODE_xxx constants as the mode parameter to switch modes.

Overrides:
setTransparency in class yrqVisual
Parameters:
a_alpha - Global transparency factor for this visual
a_mode - Transparency mode for this visual