Package net.risingworld.api.assets
Class TextureAsset
java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.TextureAsset
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
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
-
Nested Class Summary
Nested classes/interfaces inherited from class net.risingworld.api.assets.Asset
Asset.Source, Asset.Type
-
Field Summary
Fields inherited from class net.risingworld.api.assets.Asset
DEFAULT_EXTENSION
-
Method Summary
Modifier and TypeMethodDescriptionstatic TextureAsset
load
(byte[] data) Loads a texture from raw byte data.static TextureAsset
loadFromAssetBundle
(AssetBundle bundle, String path) static TextureAsset
loadFromFile
(String file) Creates a new texture asset instance and loads the texture / image from a file on the hard drive.static TextureAsset
loadFromGame
(String path) Loads a texture / image from the game assets.static TextureAsset
loadFromPlugin
(Plugin plugin, String resource) Creates a new texture asset instance and loads the texture / image from the plugin jar file.static TextureAsset
loadFromURL
(String url) Loads a texture from an URLMethods inherited from class net.risingworld.api.assets.Asset
dispose, equals, getChecksum, getDependency, getExtension, getHandle, getPath, getSource, getType, hashCode, isDisposed
-
Method Details
-
loadFromGame
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.- Parameters:
path
- the path to the game texture.- Returns:
- a new texture asset instance.
- Example: Loads the pickaxe item icon from the game assets
-
loadFromFile
Creates a new texture asset instance and loads the texture / image from a file on the hard drive.- Parameters:
file
- the path to the texture file on the harddrive.- Returns:
- a new texture asset instance.
- Example: Load image "Banner.jpg" from "assets" subfolder in plugin directory
-
loadFromPlugin
Creates a new texture asset instance and loads the texture / image from the plugin jar file.- Parameters:
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).- Returns:
- a new texture asset instance.
- Example: Load image "Banner.jpg" from jar file (in package rw.plugin.images)
-
loadFromAssetBundle
-
loadFromURL
Loads a texture from an URL- Parameters:
url
- the URL you want to download the image from.- Returns:
- a new texture asset instance.
- Example: Load image from an URL
-
load
Loads a texture from raw byte data.- Parameters:
data
- the raw byte data representing a PNG/JPG image (or any other supported format).- Returns:
- a new texture asset instance.
-