jpview.graphics
Class EnvironmentMap

java.lang.Object
  extended by jpview.graphics.EnvironmentMap

public class EnvironmentMap
extends java.lang.Object

The environment map class stores the environment images and provides a method to rotate the map

Author:
clyon

Field Summary
static int BLUR_TYPE_GAUSSIAN
          constant indicating a gaussian blur
static int BLUR_TYPE_NONE
          constant indicating no blur
static int BLUR_TYPE_SIMPLE
          constant indicating simple blur (no weighting)
static int DEFAULT_DOWNSAMPLE
          default setting for downsampling the map
static float DEFAULT_GAUSSIAN_SIGMA
          the default sigma setting for the gaussian kernel
static int DEFAULT_KERNEL_SIZE
          default gaussian kernel size
 int MAX_DOWNSAMPLE_SZ
          The maximum downsample size, determined by the environment map image
 
Constructor Summary
EnvironmentMap(java.awt.image.BufferedImage source, PTM ptm)
          Creates a new instance of EnvironmentMap
 
Method Summary
 int getDownSample()
          Returns the amount by which the map is downsampled
 int getHeight()
          returns the height of the environment map
 java.awt.image.BufferedImage getImage()
          Returns the sphere map image used for the environment map
 int getMapIndex(Vec3f normal)
          Returns the pixel value indexed by the provided normal in a flat (1D) pixel buffer
 int getMaxDownsample()
          Returns the current amount by which the map can be downsampled
 int getPixel(Vec3f normal)
          Returns the pixel indexed by light reflected by the provided normal
 java.awt.Point getPosition(Vec3f normal)
          Returns the point on a 2D plane indexed by the provided normal
 int getWidth()
          Returns the width of the PTM
 void refresh()
          Refreshes the sampling and blur routines
 void release()
          free all storage used by this class
 int[] rotatedMap()
          Returns a pixel buffer of the rotated map
 void setAngle(int degrees)
          Sets the angle for rotation of the map
 void setBlurKernelSize(int i)
          Sets the kernel size for the gaussian blur
 void setGaussianBlur()
          Set the blur type to gaussian blur
 void setGaussianSigma(float f)
          Sets the sigma value for the gaussian blur algorithm
 void setImage(java.awt.image.BufferedImage source)
          Set the sphere map image to be used
 void setNoBlur()
          Turn off blurring
 void setSampleSize(int i)
          Sets the downsample size for the map
 void setSimpleBlur()
          Set the blur type to a simple blur (no weights)
 void updateMonitor(Vec3f[] normals)
          Updates the local monitor (for debugging)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLUR_TYPE_NONE

public static final int BLUR_TYPE_NONE
constant indicating no blur

See Also:
Constant Field Values

BLUR_TYPE_SIMPLE

public static final int BLUR_TYPE_SIMPLE
constant indicating simple blur (no weighting)

See Also:
Constant Field Values

BLUR_TYPE_GAUSSIAN

public static final int BLUR_TYPE_GAUSSIAN
constant indicating a gaussian blur

See Also:
Constant Field Values

DEFAULT_KERNEL_SIZE

public static final int DEFAULT_KERNEL_SIZE
default gaussian kernel size

See Also:
Constant Field Values

DEFAULT_DOWNSAMPLE

public static final int DEFAULT_DOWNSAMPLE
default setting for downsampling the map

See Also:
Constant Field Values

DEFAULT_GAUSSIAN_SIGMA

public static final float DEFAULT_GAUSSIAN_SIGMA
the default sigma setting for the gaussian kernel

See Also:
Constant Field Values

MAX_DOWNSAMPLE_SZ

public int MAX_DOWNSAMPLE_SZ
The maximum downsample size, determined by the environment map image

Constructor Detail

EnvironmentMap

public EnvironmentMap(java.awt.image.BufferedImage source,
                      PTM ptm)
Creates a new instance of EnvironmentMap

Parameters:
source - the sphere map image
ptm - the parent PTM to be mapped
Method Detail

getDownSample

public int getDownSample()
Returns the amount by which the map is downsampled

Returns:
the downsample value

release

public void release()
free all storage used by this class


setImage

public void setImage(java.awt.image.BufferedImage source)
Set the sphere map image to be used

Parameters:
source - the sphere map image

getWidth

public int getWidth()
Returns the width of the PTM

Returns:
the width of the environment map

getHeight

public int getHeight()
returns the height of the environment map

Returns:
the height of the environment map

getMaxDownsample

public int getMaxDownsample()
Returns the current amount by which the map can be downsampled

Returns:
maximum amount by which this map can be downsampled

getImage

public java.awt.image.BufferedImage getImage()
Returns the sphere map image used for the environment map

Returns:
the image used for the environment map

getPixel

public int getPixel(Vec3f normal)
Returns the pixel indexed by light reflected by the provided normal

Parameters:
normal - the normal on the PTM
Returns:
the pixel indexed by the provided normal

getPosition

public java.awt.Point getPosition(Vec3f normal)
Returns the point on a 2D plane indexed by the provided normal

Parameters:
normal - normal from the PTM
Returns:
The point on the map indexed by the provided normal

getMapIndex

public int getMapIndex(Vec3f normal)
Returns the pixel value indexed by the provided normal in a flat (1D) pixel buffer

Parameters:
normal - a normal from the PTM surface
Returns:
the index of a pixel in a flat buffer indexed by the provided normal

setSampleSize

public void setSampleSize(int i)
Sets the downsample size for the map

Parameters:
i - the downsample size

setBlurKernelSize

public void setBlurKernelSize(int i)
Sets the kernel size for the gaussian blur

Parameters:
i - sets the blur kernel size

setGaussianSigma

public void setGaussianSigma(float f)
Sets the sigma value for the gaussian blur algorithm

Parameters:
f - the sigma value for the gaussian blur

setGaussianBlur

public void setGaussianBlur()
Set the blur type to gaussian blur


setSimpleBlur

public void setSimpleBlur()
Set the blur type to a simple blur (no weights)


setNoBlur

public void setNoBlur()
Turn off blurring


rotatedMap

public int[] rotatedMap()
Returns a pixel buffer of the rotated map

Returns:
A buffer of the rotated pixels

refresh

public void refresh()
Refreshes the sampling and blur routines


updateMonitor

public void updateMonitor(Vec3f[] normals)
Updates the local monitor (for debugging)

Parameters:
normals - list of normals to highlight for debugging

setAngle

public void setAngle(int degrees)
Sets the angle for rotation of the map

Parameters:
degrees - angle in degrees to rotate the map