Class SoTexture

All Implemented Interfaces:
SafeDisposable
Direct Known Subclasses:
SoExtTexture2, SoIndexedTexture2, SoTexture2, SoTexture3, SoTextureCubeMap

public abstract class SoTexture extends SoNode
Abstract base class for texture mapping nodes. This is the abstract base class for all texture image nodes. It defines the common methods and fields that all texture image nodes have. When a texture image node is encountered during traversal, the associated image and parameters are applied to the current texture unit (see SoTextureUnit) and used to apply the texture to subsequent shapes.

Open Inventor provides multiple texture image nodes optimized for different purposes, including:

  • SoTexture2
    The basic 2D texture image node. The image may be loaded from a file, loaded from an image in memory or created by rendering a scene graph.
  • SoExtTexture2
    This node is similar to SoTexture2, but has specific optimizations that are valuable for applications that load a large number of textures from files.
  • SoIndexedTexture2
    The first two nodes load an image containing color values that are directly applied to the geometry. This node considers each texel to be a data value that is mapped to a color using the color map defined by an SoColorMap node. This is very useful for "intensity" data sets.
  • SoTextureCubeMap
    This node loads a set of six images representing the faces of a cube. These are "shrink wrapped" onto the geometry similar to environment mapping, but without the need for a single specially warped environment image.
  • SoTexture3
    This node defines a 3D texture map. The image may be loaded from a set of files or loaded directly from memory. A 3D texture may be used to load a volume data set, but note that the Open Inventor VolumeViz nodes are specifically implemented for this purpose (see SoVolumeData).

Applications may use the isSupported() method to check if the graphics hardware supports a specific texture mapping feature.

File format/default:

This is an abstract class. See the reference page of a derived class for the format and default values.

See Also:
  • Field Details

    • internalFormat

      public final SoSFEnum<SoTexture.InternalFormats> internalFormat
      Internal format for texture storage. If not available on the graphics device, internalFormat is set back to AUTO_INTERNAL_FORMAT. Use enum InternalFormat. Default is AUTO_INTERNAL_FORMAT. If internal format is set to AUTO_INTERNAL_FORMAT texture precision could only be 16-bit maximum. To go beyond this limitation, you must set the internal format to the needed value.

      Since:
      Open Inventor 6.0

    • enableCompressedTexture

      public final SoSFBool enableCompressedTexture
      Enables storage of textures on the graphics board in compressed form. The application supplies textures as usual, then OpenGL compresses the textures. This can reduce usage of texture memory significantly, depending on the texture image.

      To use this option, you must be using OpenGL 1.3 or higher, or your board must support the OpenGL GL_ARB_texture_compression extension.

      Since:
      Open Inventor 4.0

    • wrapS

      public final SoSFEnum<SoTexture.WrapType> wrapS
      Indicates what to do when texture coordinates in the S (horizontal) direction lie outside the range 0-1. Use enum Wrap. Default is REPEAT.
    • model

      public final SoSFEnum<SoTexture.Models> model
      Specifies how to map texture onto surface. Use enum Model. Default is MODULATE.
    • blendColor

      public final SoSFColor blendColor
      Color used for BLEND model.
    • enableBorder

      public final SoSFBool enableBorder
      Enables borders for textures. This means that the border is already in the texture.

      Since:
      Open Inventor 5.0

    • borderColor

      public final SoSFVec4f borderColor
      Defines border color used for border texture filtering. This value is only used if enableBorder is false.

      Since:
      Open Inventor 5.0

    • maxAnisotropy

      public final SoSFFloat maxAnisotropy
      Specifies on a per-texture object basis, the maximum degree of anisotropy to account for in texture filtering. If the specified value is greater than the maximum supported by the graphics board, the value is clamped to GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT.

      To use this option, you must be using OpenGL 1.1 or higher, or your board must support the OpenGL GL_EXT_filter_anisotropic extension.

      Since:
      Open Inventor 5.0

    • minFilter

      public final SoSFEnum<SoTexture.Filters> minFilter
      Specifies the OpenGL minFilter. Use enum Filter. Default is AUTO. The minification filter is used when the rendered size of the geometry is smaller than the texture image to be applied (typically far away objects). Effectively controls whether the GPU will select the "nearest" texel in the texture image or do linear interpolation (smoothing) or even interpolate between mipmap levels (subsampled versions of the base image). Using NEAREST may allow better performance, but the LINEAR options produce much higher quality rendering.

      The default value (AUTO) means that the minification filter setting is actually controlled by the SoComplexity.textureQuality field.

      Since:
      Open Inventor 5.0

    • magFilter

      public final SoSFEnum<SoTexture.Filters> magFilter
      Specifies the OpenGL magFilter. Use enum Filter. Default is AUTO. Only the following Filter values are valid: AUTO, NEAREST, and LINEAR.

      The magnification filter is used when the rendered size of the geometry is larger than the texture image to be applied (typically near objects). Effectively controls whether the GPU will select the "nearest" texel in the texture image or do linear interpolation (smoothing). Using NEAREST may allow better performance, but the LINEAR options produce much higher quality rendering.

      Only the values NEAREST and LINEAR are valid in this field (see OpenGL specification).

      The default value (AUTO) means that the magnification filter setting is actually controlled by the SoComplexity.textureQuality field.

      Since:
      Open Inventor 5.0

  • Method Details

    • readTexture

      public static SbRasterImage readTexture(String filename)
      Calls readTexture(filename, SoTexture.FileTypes.valueOf( SoTexture.FileTypes.UNKNOWN.getValue() )).
    • getBitmapFileType

      public SoTexture.FileTypes getBitmapFileType()
      Gets the texture file format.
    • setBitmapFileType

      public void setBitmapFileType(SoTexture.FileTypes in_type)
      Sets the texture file format. Default is UNKNOWN. If file type is set to UNKNOWN, Open Inventor tries to determine the file type from the file name extension (e.g., foo. gif implies a GIF file). If the set or determined file type is not UNKNOWN, Open Inventor attempts to read the file as that format. If this fails, Open Inventor will try reading the file as each possible format in turn. It is not necessary to set the file type if the image file has the standard file name extension.
    • readTexture

      public static SbRasterImage readTexture(String filename, SoTexture.FileTypes filetype)
      Convenience function that loads the image data from any texture file supported by Open Inventor and returns an SbRasterImage object. Returns null if the load fails for any reason.

      If the file type is known, you may specify it using the FileType enum and Open Inventor will use the corresponding image reader. If filetype is UNKNOWN, Open Inventor will try to automatically determine which image reader should be used for the given file.

    • isSupported

      public static boolean isSupported(SoTexture.HW_Features feature)
      Returns information about hardware support for various texture features. When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or see SoGLExtension for an example of using SoGLContext to avoid them.