Class AITexture

  • All Implemented Interfaces:
    Pointer

    public class AITexture
    extends Struct
    Helper structure to describe an embedded texture.

    Normally textures are contained in external files but some file formats embed them directly in the model file. There are two types of embedded textures:

    • Uncompressed textures. The color data is given in an uncompressed format.
    • Compressed textures stored in a file format like png or jpg.

    The raw file bytes are given so the application must utilize an image decoder (e.g. DevIL) to get access to the actual color data.

    Embedded textures are referenced from materials using strings like "*0", "*1", etc. as the texture paths (a single asterisk character followed by the zero-based index of the texture in the AIScene::mTextures array).

    Member documentation

    • mWidth – Width of the texture, in pixels. If mHeight is zero the texture is compressed in a format like JPEG. In this case mWidth specifies the size of the memory area pcData is pointing to, in bytes.
    • mHeight – Height of the texture, in pixels. If this value is zero, pcData points to an compressed texture in any format (e.g. JPEG).
    • achFormatHint – A hint from the loader to make it easier for applications to determine the type of embedded compressed textures. If mHeight != 0 this member is undefined. Otherwise it is set set to '\0\0\0\0' if the loader has no additional information about the texture file format used OR the file extension of the format without a trailing dot. If there are multiple file extensions for a format, the shortest extension is chosen (JPEG maps to 'jpg', not to 'jpeg'). E.g. 'dds\0', 'pcx\0', 'jpg\0'. All characters are lower-case. The fourth character will always be '\0'.
    • pcData – Data of the texture. Points to an array of mWidth * mHeight AITexel's. The format of the texture data is always ARGB8888 to make the implementation for user of the library as easy as possible. If mHeight = 0 this is a pointer to a memory buffer of size mWidth containing the compressed texture data. Good luck, have fun!
    • mFilename – texture original filename. Used to get the texture reference.

    Layout

    
     struct aiTexture {
         unsigned int mWidth;
         unsigned int mHeight;
         char achFormatHint[4];
         struct aiTexel * pcData;
         struct aiString mFilename;
     }
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • MWIDTH, MHEIGHT, ACHFORMATHINT, PCDATA, MFILENAME

        The struct member offsets.
    • Constructor Detail

      • AITexture

        public AITexture​(java.nio.ByteBuffer container)
        Creates a AITexture instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

        The created instance holds a strong reference to the container object.

    • Method Detail

      • sizeof

        public int sizeof()
        Description copied from class: Struct
        Returns sizeof(struct).
        Specified by:
        sizeof in class Struct
      • mWidth

        public int mWidth()
        Returns the value of the mWidth field.
      • mHeight

        public int mHeight()
        Returns the value of the mHeight field.
      • achFormatHint

        public java.nio.ByteBuffer achFormatHint()
        Returns a ByteBuffer view of the achFormatHint field.
      • achFormatHintString

        public java.lang.String achFormatHintString()
        Decodes the null-terminated string stored in the achFormatHint field.
      • pcData

        public AITexel.Buffer pcData​(int capacity)
        Returns a AITexel.Buffer view of the struct array pointed to by the pcData field.
        Parameters:
        capacity - the number of elements in the returned buffer
      • mFilename

        public AIString mFilename()
        Returns a AIString view of the mFilename field.
      • mFilename

        public AITexture mFilename​(java.util.function.Consumer<AIString> consumer)
        Passes the mFilename field to the specified Consumer.
      • create

        public static AITexture create​(long address)
        Returns a new AITexture instance for the specified memory address.
      • createSafe

        @Nullable
        public static AITexture createSafe​(long address)
        Like create, but returns null if address is NULL.
      • create

        public static AITexture.Buffer create​(long address,
                                              int capacity)
        Create a AITexture.Buffer instance at the specified memory.
        Parameters:
        address - the memory address
        capacity - the buffer capacity
      • createSafe

        @Nullable
        public static AITexture.Buffer createSafe​(long address,
                                                  int capacity)
        Like create, but returns null if address is NULL.
      • nmWidth

        public static int nmWidth​(long struct)
        Unsafe version of mWidth().
      • nmHeight

        public static int nmHeight​(long struct)
        Unsafe version of mHeight().
      • nachFormatHint

        public static java.nio.ByteBuffer nachFormatHint​(long struct)
        Unsafe version of achFormatHint().
      • nachFormatHintString

        public static java.lang.String nachFormatHintString​(long struct)
        Unsafe version of achFormatHintString().
      • nmFilename

        public static AIString nmFilename​(long struct)
        Unsafe version of mFilename().