com.motorola.iden.micro3d
Class Texture

java.lang.Object
  |
  +--com.motorola.iden.micro3d.Texture
Direct Known Subclasses:
MultiTexture

public class Texture
extends java.lang.Object

Texture contains and manages texture data. A texture can be used by Figure and some primitives. A Texture object is created either from a named resource or a byte array containing texture data, by using an appropriate Texture.createTexture() method.

A Texture object can be one of two types: regular texture or a sphere texture. The type of the texture is determined by a parameter specified at the time the texture is created. Once a texture is created, its type cannot be changed without creating a new instance of a Texture object. The type of the texture can be determined by using isSphereTexture() method.

The data used to create a Texture object must be in BMP format. Furthermore, the BMP image must be stored as an uncompresed 8-bit indexed color. The maximum size of the texture image is dependent on its intended use. For regular textures the maximum size is 256x256 pixels. For sphere textures the maximum size is 64x64 pixels. Textures that are larger than the maximum size will fail to decode. Note that once decoded, a single texture uses around 82 KB of memory regardless of its size. Therefore it is recommended to merge several small textures into a single 256x256 texture for memory efficiency.
MOTOROLA and the Stylized M Logo are registered trademarks of Motorola, Inc. Reg. U.S. Pat. & Tm. Off.
© COPYRIGHT 2003-2004 MOTOROLA, Inc. All Rights Reserved.


Method Summary
static Texture createTexture(byte[] data, int offset, int length, boolean sphereTexture)
          Creates a Texture which is decoded from the data stored in the specified byte array at the specified offset and length.
static Texture createTexture(java.lang.String name, boolean sphereTexture)
          Creates a Texture from the data obtained from the named resource.
 boolean isSphereTexture()
          Returns a boolean indicating if the texture data is to be used for environment mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createTexture

public static Texture createTexture(byte[] data,
                                    int offset,
                                    int length,
                                    boolean sphereTexture)
                             throws java.lang.NullPointerException,
                                    java.lang.IllegalArgumentException,
                                    java.lang.ArrayIndexOutOfBoundsException,
                                    java.io.IOException
Creates a Texture which is decoded from the data stored in the specified byte array at the specified offset and length. The data must be in the format supported by the implementation (.bmp).

The offset and length parameters specify a range of data within the data byte array. The offset parameter specifies the offset into the array of the first data byte to be used. It must therefore lie within the range [0..(data.length-1)]. The length parameter specifies the number of data bytes to be used. It must be a positive integer and it must not cause the range to extend beyond the end of the array. That is, it must be true that offset + length <= data.length.

A Texture object can be one of two types: regular texture or a sphere texture. The type of the texture is determined by the sphereTexture parameter. Once a texture is created, its type cannot be changed without creating a new instance of a Texture object.

This method is intended for use when loading a texture from a variety of sources, such as from persistent storage or from the network.

Parameters:
data - the array of texture data in .bmp format.
offset - the offset of the start of the data in the array.
length - the length of the data in the array.
sphereTexture - true to create a sphere texture, false for regular texture.
Returns:
the created texture.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if offset and length specify an invalid range.
java.lang.IllegalArgumentException - if the array does not contain valid texture data.
java.io.IOException - if the data contained cannot be decoded.
java.lang.NullPointerException - if the data array is null.

createTexture

public static Texture createTexture(java.lang.String name,
                                    boolean sphereTexture)
                             throws java.io.IOException,
                                    java.lang.NullPointerException
Creates a Texture from the data obtained from the named resource. The specified parameter must name a valid resource file containing the texture data.

A Texture object can be one of two types: regular texture or a sphere texture. The type of the texture is determined by the sphereTexture parameter. Once a texture is created, its type cannot be changed without creating a new instance of a Texture object.

Parameters:
name - the name of the resource containing the animation data in the supported .bmp format.
sphereTexture - true to create a sphere texture, false for regular texture.
Returns:
the created texture.
Throws:
java.io.IOException - if the resource does not exist, the data cannot be loaded, or the texture data cannot be decoded.
java.lang.NullPointerException - if the resource name is null.

isSphereTexture

public boolean isSphereTexture()
Returns a boolean indicating if the texture data is to be used for environment mapping.

Returns:
true if this texture is to be used for environment mapping, false otherwise.
See Also:
createTexture(byte[], int, int, boolean), createTexture(String, boolean)