dx#
local dx = require 'dx'
The dx
module contains functions and classes that can be used to draw
in the 3D scene, below the overlay UI.
Most of the rendering details are abstracted away, so all that is needed is an image to use for a texture and coordinates for display, either in the 3D scene (the ‘world’) or on the map/minimap.
Note
This module will render objects regardless of the UI state or MumbleLink data.
Module authors should track these states and only set elements to be drawn when appropriate.
Textures#
Textures are managed by the dxtexturemap
class.
A map can hold multiple textures that can be shared by multiple classes that use
them. Module authors are encouraged to create a single map and use it for all
3D rendering with a module.
Dimensions#
This module does not enforce any restrictions on texture dimensions when loading texture data, however internally all textures are stored in square textures with dimensions that are a power of 2.
This should not affect sprites because the original dimensions of the image are stored and used when rendering them, but trails may not be rendered as expected if a non-square and/or no-power of 2 image is used.
Functions#
- dx.texturemap()#
Create a new
dxtexturemap
object.- Return type:
Version History
Version
Notes
0.3.0
Added
- dx.spritelist(texturemap[, location])#
Create a new
dxspritelist
object.- Parameters:
texturemap (
dxtexturemap
)location (
string
) – (Optional) How the sprites in this list will be positioned. See below. Default:'world'
.
- Return type:
Location Values
Value
Description
'world'
Sprites are drawn within the 3D world, coordinates must be in map coordinates.
'map'
Sprites are dawn on the (mini)map, coordinates must be in continent coordinates.
Version History
Version
Notes
0.3.0
Added
- dx.traillist(texturemap[, location])#
Version History
Version
Notes
0.3.0
Added
Classes#
- class dx.dxtexturemap#
A texture map holds a list of textures that other objects in this module use when being displayed.
- clear()#
Remove all textures from this map.
Danger
If objects are still referencing textures within this map after this method is called, their draws will not function properly.
Version History
Version
Notes
0.3.0
Added
- add(name, data, mipmaps)#
Add a texture.
- Parameters:
Implementation Detail
EG-Overlay uses the Windows Imaging Component to load
data
, so any format it supports can be used.All textures are loaded as 4 channel BGRA images.
Version History
Version
Notes
0.3.0
Added
- class dx.dxspritelist#
- add(texture, attributes)#
Add a sprite to this list.
attributes
must be a table that may have the following fieldsField
Description
x
The sprite’s X coordinate in map units. Default:
0.0
.y
The sprite’s Y coordinate in map units. Default:
0.0
.z
The sprite’s Z coordinate in map units. Default:
0.0
.tags
A table of attributes that can be referenced with update or remove. Note: the table is referenced, not copied.
size
The sprite’s size, in map units. Default:
80
.color
Tint color and opacity, see Colors. Default:
0xFFFFFFFF
.billboard
A boolean indicating if the sprite should always face the camera. Default:
true
.rotation
A sequence of 3 numbers, indicating the rotation to be applied to the sprite along the X, Y, and Z axes, in that order. This value is only applicable if
billboard
is false.fadenear
The distance in map units from the player that the sprite will begin to fade to transparent. Default:
-1.0
. Note: negative values disable distance based fading.fadefar
The distance in map units from the player that the sprite will become completely transparent. Default:
-1.0
. Note: negative values disable distance based fading.mousetest
A boolean value indicating if the mouse position will be checked each frame against the position of this sprite.
- Parameters:
texture (
string
) – The name of the texture, seedxtexturemap.add()
.attributes (
table
) – See above.
Version History
Version
Notes
0.3.0
Added
- draw(value)#
Sets if this spritelist should be drawn.
- Parameters:
draw (
boolean
)
Version History
Version
Notes
0.3.0
Added
- update(tags, attributes)#
Update the sprites that have matching tags.
An empty tags table matches all sprites. A sprite must match all tag values given, if a sprite does not have a value for a tag it will not match.
Returns the number of sprites updated.
Version History
Version
Notes
0.3.0
Added
- remove(tags)#
Remove sprites that have matching tags.
An empty tags table matches all sprites. A sprite must match all tag values given, if a sprite does not have a value for a tag it will not match.
Version History
Version
Notes
0.3.0
Added
- clear()#
Version History
Version
Notes
0.3.0
Added
- class dx.dxtraillist#
- draw(value)#
Version History
Version
Notes
0.3.0
Added
- add(texturename, attributes)#
Create a new trail.
attributes
must be a table with the following fields:Field
Description
points
A sequence of sequences, trail points. ie. { {1,1,1}, {2,2,2} }
tags
A table of attributes that can be used other methods of this list to update or remove trails with matching tags. Note: the table is referenced directly, not copied.
fadenear
A number that indicates how far away from the player a trail begins to fade to transparent.
fadefar
A number that indicates how far away from the player a trail will become completely transparent.
- Parameters:
Version History
Version
Notes
0.3.0
Added
- remove(tags)#
Version History
Version
Notes
0.3.0
Added
- clear()#
Version History
Version
Notes
0.3.0
Added