Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.cult3d.world
Class Texture

    java.lang.Object
      |
      +--com.cult3d.world.Texture

public class Texture
extends java.lang.Object

This class provides a Java representation of a texture that is mapped to some object in the scenegraph. By using the setTexture() methods, it is possible to dynamically update the texture an object of this class represents. Usually this is accomplished by painting on a TextureImage and then using the setTexture(Image) method to update the texture.

It is not possible to create new textures. Thus, if dynamic textures are needed, dummy textures must first be mapped to the objects in question in the 3D modelling tool of choice.

Since:
  Cult3D 4.0

Field Summary
`static byte` | `AA_DEFAULT` Sets the object to a none antialiased state when changing textures.
`static byte` | `AA_IGNORE` The object stays in its current mode when changing textures, as opposed to AA_DEFAULT.

Constructor Summary
`Texture(java.lang.String name)` Constructs a Java representation of an texture.
`Texture(java.lang.String name, int timeout)` Constructs a Java representation of an texture.

Method Summary
`int` | `getHeight()` Gets the height of the texture.
`java.lang.String` | `getInfo()` Returns a string representation of the values of this object.
`java.lang.String` | `getName()` Gets the name of the texture.
`int[]` | `getTexture()` Gets an int array containig the RGB values of the texture.
`void` | `getTexture(java.awt.Image surface)` Copies the texture to an Image.
`int` | `getWidth()` Gets the width of the texture.
`void` | `replaceColor(java.awt.Color oldColor, java.awt.Color newColor)` Replaces a color in the texture with a new color.
`void` | `replaceColor(java.awt.Color oldColor, java.awt.Color newColor, int tolerance)` Replaces a color in the texture with a new color.
`void` | `replaceColor(RGB oldColor, RGB newColor)` Replaces a color in the texture with a new color.
`void` | `replaceColor(RGB oldColor, RGB newColor, int tolerance)` Replaces a color in the texture with a new color.
`void` | `setTexture(java.awt.Image surface)` Sets the texture from an Image instance, it sets the antialasing to default when changing.
`void` | `setTexture(java.awt.Image surface, byte antialiasingMode)` Sets the texture from an Image instance.
`void` | `setTexture(int[] data)` Sets the texture from an array of int-values.
`java.lang.String` | `toString()` This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### AA_DEFAULT

    public static final byte AA_DEFAULT

  Sets the object to a none antialiased state when changing textures.
  Since:
    Cult3D 5.2

### AA_IGNORE

    public static final byte AA_IGNORE

  The object stays in its current mode when changing textures, as opposed to AA_DEFAULT.
  Since:
    Cult3D 5.2

Constructor Detail

### Texture

    public Texture(java.lang.String name)

  Constructs a Java representation of an texture. The given name is the name of the texture, as defined in the Cult3D Designer, and must match exactly. This method will wait up till 300 seconds (5 minutes) before failing.
  Parameters:
    `name` - the name of the texture.
  Throws:
    NameNotFoundException - If a texture with the given name is not found.
  Since:
    Cult3D 4.0

### Texture

    public Texture(java.lang.String name,
                   int timeout)

  Constructs a Java representation of an texture. The given name is the name of the texture, as defined in the Cult3D Designer, and must match exactly. You can by yourself set the max time (in milliseconds) it should try to load the texture.
  Parameters:
    `name` - the name of the texture.
    `timeout` - the timeout for retrieving the texture in ms with a granularity of 100 ms.
  Throws:
    NameNotFoundException - If a texture with the given name is not found.
  Since:
    Cult3D 5.3

Method Detail

### getName

    public java.lang.String getName()

  Gets the name of the texture.
  Returns:
    the name.
  Since:
    Cult3D 4.2

### getWidth

    public int getWidth()

  Gets the width of the texture.
  Returns:
    the width.
  Since:
    Cult3D 4.0

### getHeight

    public int getHeight()

  Gets the height of the texture.
  Returns:
    the height.
  Since:
    Cult3D 4.0

### getTexture

    public int[] getTexture()

  Gets an int array containig the RGB values of the texture.
  Returns:
    an array of int-values containing RGB-values for the texture.
  Since:
    Cult3D 4.0

### getTexture

    public void getTexture(java.awt.Image surface)

  Copies the texture to an Image. The Image must be created by calling the method com.cult3d.Cult.createImage().
  Parameters:
    `surface` - the Image instance to copy the texture to. The image must be a instance of com.cult3d.TextureImage
  Since:
    Cult3D 4.0
  See Also:
    `TextureImage`

### setTexture

    public void setTexture(int[] data)

  Sets the texture from an array of int-values. Note, that the image to apply to this texture must be of equal dimension (width, height).
  Parameters:
    `data` - An array of int-values.
  Since:
    Cult3D 4.0

### setTexture

    public void setTexture(java.awt.Image surface)

  Sets the texture from an Image instance, it sets the antialasing to default when changing. Note, that the image to apply to this texture must be of equal dimension (width, height).
  Parameters:
    `surface` - the Image to be set.
  Since:
    Cult3D 4.0

### setTexture

    public void setTexture(java.awt.Image surface,
                           byte antialiasingMode)

  Sets the texture from an Image instance. Note, that the image to apply to this texture must be of equal dimension (width, height). As of today if the dimension are incorrect a warning will be written once to standard error.
  Parameters:
    `surface` - the Image to be set.
    `antialiasingMode` - AntiAliasing beahvior. Set to AA_DEFAULT for default behavior, AA_IGNORE for Antialiasing not to care about this call.
  Since:
    Cult3D 5.2

### replaceColor

    public void replaceColor(RGB oldColor,
                             RGB newColor)

  Replaces a color in the texture with a new color.
  Parameters:
    `oldColor` - the color to replace
    `newColor` - the new color
  Returns:
    the width.
  Since:
    Cult3D 4.2

### replaceColor

    public void replaceColor(java.awt.Color oldColor,
                             java.awt.Color newColor)

  Replaces a color in the texture with a new color.
  Parameters:
    `oldColor` - the color to replace
    `newColor` - the new color
  Returns:
    the width.
  Since:
    Cult3D 4.2

### replaceColor

    public void replaceColor(RGB oldColor,
                             RGB newColor,
                             int tolerance)

  Replaces a color in the texture with a new color.
  Parameters:
    `oldColor` - the color to replace
    `newColor` - the new color
    `tolerance` - the tolerance
  Returns:
    the width.
  Since:
    Cult3D 4.2

### replaceColor

    public void replaceColor(java.awt.Color oldColor,
                             java.awt.Color newColor,
                             int tolerance)

  Replaces a color in the texture with a new color.
  Parameters:
    `oldColor` - the color to replace
    `newColor` - the new color
    `tolerance` - the tolerance
  Returns:
    the width.
  Since:
    Cult3D 4.2

### getInfo

    public java.lang.String getInfo()

  Returns a string representation of the values of this object.

  This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

  Returns:
    A string representing this object.
  Since:
    Cult3D 5.3

### toString

    public java.lang.String toString()

  This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

  Overrides:
    toString in class java.lang.Object
  Returns:
    A string representing this object.

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD