org.jzy3d.plot3d.primitives.textured
Class DrawableTexture

java.lang.Object
  extended by org.jzy3d.plot3d.primitives.AbstractDrawable
      extended by org.jzy3d.plot3d.primitives.textured.DrawableTexture
All Implemented Interfaces:
IGLRenderer, ISortableDraw, ITranslucent
Direct Known Subclasses:
PickableTexture

public class DrawableTexture
extends AbstractDrawable
implements ITranslucent

A DrawableTexture can only mount its texture while the GL2 thread is current, so the best is to let draw() automount texture file the first time the resource is required. When a texture is loaded for the first time, it updates the current view bounds since the texture bounds where up to now unknown and fixed to origin with no width. A DrawableTexture requires a color filter (default is white), and a set of coordinates defining the polygon on which the texture should be drawn.

Author:
Martin

Field Summary
protected  float alpha
           
protected  float axisValue
           
protected  Color filter
           
protected  List<Coord2d> mapping
           
protected  PlaneAxis orientation
           
protected  Coord2d planePosition
           
protected  SharedTexture resource
           
protected  float[] texMatMix
           
protected  Transform textureScale
           
 
Fields inherited from class org.jzy3d.plot3d.primitives.AbstractDrawable
bbox, displayed, hasListeners, legend, legendDisplayed, listeners, transform
 
Constructor Summary
DrawableTexture(SharedTexture resource)
           
DrawableTexture(SharedTexture resource, PlaneAxis orientation)
           
DrawableTexture(SharedTexture resource, PlaneAxis orientation, float axisValue)
           
DrawableTexture(SharedTexture resource, PlaneAxis orientation, float axisValue, Color filter)
           
DrawableTexture(SharedTexture resource, PlaneAxis orientation, float axisValue, List<Coord2d> coords)
           
DrawableTexture(SharedTexture resource, PlaneAxis orientation, float axisValue, List<Coord2d> coords, Color filter)
           
 
Method Summary
protected  void after(javax.media.opengl.GL2 gl)
           
protected  void before(javax.media.opengl.GL2 gl)
           
 void debugMapping()
           
 void draw(javax.media.opengl.GL2 gl, javax.media.opengl.glu.GLU glu, Camera cam)
          Call OpenGL2 routines for rendering the object.
 BoundingBox3d getBounds()
          Return the BoundingBox of this object.
 Color getColorFilter()
           
protected  List<Coord2d> getDefaultTextureMapping()
           
static List<Coord2d> getManualTextureMapping(float width, float height)
           
static List<Coord2d> getManualTextureMapping(float width, float height, float xoffset, float yoffset)
          Must supply the expected size of texture in 3d coordinates.
 Coord2d getPlanePosition()
           
 SharedTexture getResource()
           
 Transform getTextureScale()
           
protected  void initBoundsWithMapping()
           
protected  void initBoundsWithResources()
           
 void setAlphaFactor(float a)
           
 void setColorFilter(Color filter)
           
 void setPlanePosition(Coord2d planePosition)
           
 void setResource(SharedTexture resource)
           
 void setTextureScale(Transform textureScale)
           
 
Methods inherited from class org.jzy3d.plot3d.primitives.AbstractDrawable
addDrawableListener, call, call, callWithAlphaFactor, dispose, fireDrawableChanged, fireDrawableChanged, getBarycentre, getDistance, getLegend, getLongestDistance, getShortestDistance, getTransform, hasLegend, isDisplayed, isLegendDisplayed, negative, removeDrawableListener, setDisplayed, setLegend, setLegendDisplayed, setTransform, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

textureScale

protected Transform textureScale

resource

protected SharedTexture resource

orientation

protected PlaneAxis orientation

texMatMix

protected float[] texMatMix

filter

protected Color filter

axisValue

protected float axisValue

mapping

protected List<Coord2d> mapping

alpha

protected float alpha

planePosition

protected Coord2d planePosition
Constructor Detail

DrawableTexture

public DrawableTexture(SharedTexture resource)

DrawableTexture

public DrawableTexture(SharedTexture resource,
                       PlaneAxis orientation)

DrawableTexture

public DrawableTexture(SharedTexture resource,
                       PlaneAxis orientation,
                       float axisValue)

DrawableTexture

public DrawableTexture(SharedTexture resource,
                       PlaneAxis orientation,
                       float axisValue,
                       Color filter)

DrawableTexture

public DrawableTexture(SharedTexture resource,
                       PlaneAxis orientation,
                       float axisValue,
                       List<Coord2d> coords)

DrawableTexture

public DrawableTexture(SharedTexture resource,
                       PlaneAxis orientation,
                       float axisValue,
                       List<Coord2d> coords,
                       Color filter)
Method Detail

getColorFilter

public Color getColorFilter()

setColorFilter

public void setColorFilter(Color filter)

setAlphaFactor

public void setAlphaFactor(float a)
Specified by:
setAlphaFactor in interface ITranslucent

initBoundsWithMapping

protected void initBoundsWithMapping()

initBoundsWithResources

protected void initBoundsWithResources()

getDefaultTextureMapping

protected List<Coord2d> getDefaultTextureMapping()

getManualTextureMapping

public static List<Coord2d> getManualTextureMapping(float width,
                                                    float height,
                                                    float xoffset,
                                                    float yoffset)
Must supply the expected size of texture in 3d coordinates.

Returns:

getManualTextureMapping

public static List<Coord2d> getManualTextureMapping(float width,
                                                    float height)

debugMapping

public void debugMapping()

getBounds

public BoundingBox3d getBounds()
Description copied from class: AbstractDrawable
Return the BoundingBox of this object.

Overrides:
getBounds in class AbstractDrawable
Returns:
a bounding box

getPlanePosition

public Coord2d getPlanePosition()

setPlanePosition

public void setPlanePosition(Coord2d planePosition)

getTextureScale

public Transform getTextureScale()

setTextureScale

public void setTextureScale(Transform textureScale)

draw

public void draw(javax.media.opengl.GL2 gl,
                 javax.media.opengl.glu.GLU glu,
                 Camera cam)
Description copied from class: AbstractDrawable
Call OpenGL2 routines for rendering the object.

Specified by:
draw in interface IGLRenderer
Specified by:
draw in class AbstractDrawable
Parameters:
gl - GL2 context
glu - GLU context
cam - a reference to a shooting Camera.

before

protected void before(javax.media.opengl.GL2 gl)

after

protected void after(javax.media.opengl.GL2 gl)

getResource

public SharedTexture getResource()

setResource

public void setResource(SharedTexture resource)