j3d.org Aviatrix3D

org.j3d.renderer.aviatrix3d.texture
Class TextureCreateUtils

java.lang.Object
  extended byorg.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 Java3D texture object.

Version:
$Revision: 1.2 $
Author:
Alan Hudson

Constructor Summary
TextureCreateUtils()
          Default constructor.
 
Method Summary
 TextureComponent2D create2DTextureComponent(java.lang.Object content)
          Load the image component from the given object type.
 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

j3d.org Aviatrix3D

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