Klasse TextureAsset

java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.TextureAsset

public class TextureAsset extends Asset
Represents a texture / image asset.

Important: Images get compressed to DXT format automatically, so it's recommendable to either use a power of two texture size (e.g 256, 512, 1024, 2048 etc), or at least a width/height which is a multiple of 4 - otherwise compression is not possible and the texture will consume 4-8 times more VRAM. Please bear in mind that the file size is not related to the actual memory consumption. But it's still a good idea to keep an eye on the file size to keep the download sizes low in multiplayer.

Supported file formats: jpg, jpeg, png, gif, tga, tiff, bmp
  • Methodendetails

    • loadFromGame

      public static TextureAsset loadFromGame(String path)
      Loads a texture / image from the game assets. This is quite efficient because the server doesn't have to send any data to the clients.
      Parameter:
      path - the path to the game texture.
      Gibt zurück:
      a new texture asset instance.
    • loadFromFile

      public static TextureAsset loadFromFile(String file)
      Creates a new texture asset instance and loads the texture / image from a file on the hard drive.
      Parameter:
      file - the path to the texture file on the harddrive.
      Gibt zurück:
      a new texture asset instance.
      Example: Load image "Banner.jpg" from "assets" subfolder in plugin directory
      1TextureAsset tex = TextureAsset.loadFromFile(getPath() + "/assets/Banner.jpg");
      2// do something with the asset
    • loadFromPlugin

      public static TextureAsset loadFromPlugin(Plugin plugin, String resource)
      Creates a new texture asset instance and loads the texture / image from the plugin jar file.
      Parameter:
      plugin - a reference to the plugin. This is required to make sure the game loads the resource from the correct plugin jar.
      resource - the path to the resource (inside the jar file).
      Gibt zurück:
      a new texture asset instance.
      Example: Load image "Banner.jpg" from jar file (in package rw.plugin.images)
      1TextureAsset tex = TextureAsset.loadFromFile(this, "/rw/plugin/images/Banner.jpg");
      2// do something with the asset
    • loadFromAssetBundle

      public static TextureAsset loadFromAssetBundle(AssetBundle bundle, String path)
    • loadFromURL

      public static TextureAsset loadFromURL(String url)
      Loads a texture from an URL
      Parameter:
      url - the URL you want to download the image from.
      Gibt zurück:
      a new texture asset instance.
      Example: Load image from an URL
      1TextureAsset tex = TextureAsset.loadFromURL("https://images.rising-world.net/media/update/api/plugin_api3.jpg");
      2// do something with the asset
    • load

      public static TextureAsset load(byte[] data)
      Loads a texture from raw byte data.
      Parameter:
      data - the raw byte data representing a PNG/JPG image (or any other supported format).
      Gibt zurück:
      a new texture asset instance.