Aviatrix3D
2.1.0

org.j3d.renderer.aviatrix3d.texture
Class TextureCreateUtils

java.lang.Object
  extended by org.j3d.renderer.aviatrix3d.texture.TextureCreateUtils

public class TextureCreateUtils
extends java.lang.Object

Convenience class with a collection of useful utility methods taking an image and turning it into a Aviatrix3D texture object.

Version:
$Revision: 1.8 $
Author:
Alan Hudson, Justin Couch

Constructor Summary
TextureCreateUtils()
          Default constructor.
 
Method Summary
 TextureComponent2D create2DTextureComponent(java.lang.Object content)
          Load the image component from the given object type.
 java.awt.image.BufferedImage createNormalMap(java.awt.image.BufferedImage bumpImage, java.awt.image.BufferedImage destImage)
          Convert an image that is a greyscale heightmap into a normal map, for use in DOT3 bump mapping.
 Texture2D createTexture2D(java.awt.image.RenderedImage img)
          Given the image, create a texture object from it, resizing the image to up to a power of 2 if needed.
 int getTextureFormat(TextureComponent comp)
          From the image component format, generate the appropriate texture format.
 int nearestPowerTwo(int val, boolean scaleUp)
          Determine the nearest power of two value for a given argument.
 java.awt.image.RenderedImage scaleTexture(java.awt.image.RenderedImage ri, int newWidth, int newHeight)
          Scale a texture to a new size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureCreateUtils

public TextureCreateUtils()
Default constructor.

Method Detail

createTexture2D

public Texture2D createTexture2D(java.awt.image.RenderedImage img)
Given the image, create a texture object from it, resizing the image to up to a power of 2 if needed. The texture created is a basic non-repeating texture, with no filtering information set.

Parameters:
img - The source image to work with
Returns:
A texture object to hold the image with

getTextureFormat

public int getTextureFormat(TextureComponent comp)
From the image component format, generate the appropriate texture format.

Parameters:
comp - The image component to get the value from
Returns:
The appropriate corresponding texture format value

scaleTexture

public java.awt.image.RenderedImage scaleTexture(java.awt.image.RenderedImage ri,
                                                 int newWidth,
                                                 int newHeight)
Scale a texture to a new size. Generally used to scale a texture to a power of 2.

Parameters:
ri - The texture to scale
newWidth - The new width
newHeight - The new height

create2DTextureComponent

public TextureComponent2D create2DTextureComponent(java.lang.Object content)
Load the image component from the given object type. All images are loaded by-reference. This does not automatically register the component with the internal datastructures. That is the responsibility of the caller.

Parameters:
content - The object that was loaded and needs to be converted
Returns:
An TextureComponent instance with byRef true and yUp false

nearestPowerTwo

public int nearestPowerTwo(int val,
                           boolean scaleUp)
Determine the nearest power of two value for a given argument. This function uses the formal ln(x) / ln(2) = log2(x)

Parameters:
val - The initial size
scaleUp - true to scale the value up, false for down
Returns:
The power-of-two-ized value

createNormalMap

public java.awt.image.BufferedImage createNormalMap(java.awt.image.BufferedImage bumpImage,
                                                    java.awt.image.BufferedImage destImage)
Convert an image that is a greyscale heightmap into a normal map, for use in DOT3 bump mapping. The input image must be one of the forms of grayscale image. The output image, if provided must be exactly the same dimensions as the input image and must be TYPE_INT_RGB. If it does not fit this description, a new instance will be created and used as the return value. If it does fit, then it will written to and returned as the return value.

Parameters:
bumpImage - The source image to take the heights from
destImage - An image to write the normal map to or null if creating new
Returns:
An image representing the new map

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org