Skip to content

Draw

Shapes a plugin places in the world: tubes along a path and balls, in one colour, glowing or not. They have no collision and cast no shadow, belong to the plugin that made them, and go when it stops or the map changes. Everything here needs host 0.14.0.

Tube

int Draw::Tube(const array<double>@ path, double radius, float r, float g, float b, bool glow = false, float opacity = 1)

A tube along a path (x, y, z of each point, one after another), radius thick. Returns its id, or 0 if it couldn't be made. Colours are linear, 0 to 1. opacity below 1 makes it see-through, drawn as the game's tinted glass (it doesn't glow then).

Example
int trail = Draw::Tube(path, 5, 0.2f, 0.6f, 1.0f, true);
int faint = Draw::Tube(path, 5, 0.2f, 0.6f, 1.0f, false, 0.25f);    // a quarter opaque

Glow

bool Draw::Glow(int id, float r, float g, float b, float brightness)

Changes a glowing shape's colour and brightness in place (0 is dark; shapes are made at 8). For fading a shape in and out smoothly, without making it again. Requires host 0.14.0.

Example
Draw::Glow(trail, 0.2f, 0.6f, 1.0f, 8 * fade);

Fade

bool Draw::Fade(int id, float opacity)

Changes a see-through shape's opacity in place (a shape made with an opacity below 1; 0 is invisible, 1 solid). For fading glass in and out without making it again. Requires host 0.14.0.

Example
Draw::Fade(segment, 0.25f + 0.65f * (1 - age));

Ball

int Draw::Ball(double radius, float r, float g, float b, bool glow = false)

A ball of that radius, at the world's origin until it's moved. Returns its id, or 0.

Example
int ball = Draw::Ball(30, 1, 0.3f, 0.1f, true);
Draw::Move(ball, x, y, z);

Segments

int Draw::Segments(const array<double>@ pairs, double radius, float r, float g, float b, bool glow = false, float opacity = 1)

Many separate straight tubes in one shape (one object to draw, so thousands cost little): the points come in pairs, the start then the end of each (x, y, z of each point, one after another). Pairs shorter than 2 cm are skipped. Colours and opacity as Tube's. Returns its id, or 0 (fewer than two points). Requires host 0.25.0.

Example
array<double> ticks = {x, y, z, x, y, z + 50,   x2, y2, z2, x2, y2, z2 + 50};
int marks = Draw::Segments(ticks, 2, 1, 1, 1, true);

Retube

bool Draw::Retube(int id, const array<double>@ path, double radius)

Gives a tube from Tube a new path in place: the same shape and colour, its mesh emptied and swept again, for a line that changes every frame (a trail's growing end) without making a new shape. A path too short to sweep leaves it empty. False (nothing changed) if id isn't one of your tubes. Requires host 0.25.0.

Example
Draw::Retube(head, lastPoints, 5);      // every frame

Move

bool Draw::Move(int, double, double, double)

Puts a shape somewhere else: a ball's middle goes to the point; a tube moves by as much as its first placement.

Example
Draw::Move(ball, x, y, z);

Show

bool Draw::Show(int, bool)

Shows or hides a shape.

Example
Draw::Show(trail, false);

Remove

void Draw::Remove(int)

Removes one shape.

Example
Draw::Remove(trail);

Clear

void Draw::Clear()

Removes every shape the plugin made.

Example
Draw::Clear();

Model

int Draw::Model(const string &in)

Builds a model from a model text file (the models format) at the world's origin: place it with Draw::Move, Draw::Turn and Draw::Scale. Its spinning groups spin. 0 if the file can't be read or has a mistake (the log says which line). Requires host 0.20.0.

Example
int star = Draw::Model(Plugins::Folder() + "models/star.txt");
Draw::Move(star, x, y, z + 80);

Turn

bool Draw::Turn(int, double pitch, double yaw, double roll)

Turns a shape: pitch, yaw and roll in degrees, as the engine's rotations are. Requires host 0.20.0.

Example
Draw::Turn(star, 0, Host::Time() * 180, 0);

Collide

bool Draw::Collide(int, bool on = true)

Makes a model (Draw::Model) solid for the ball, or not again: the ball rolls on the model's own triangles, exactly what is drawn, as one continuous surface (no seams between pieces), and it blocks the camera as the game's pieces do. Only on the player's own map that was never published (in the editor, its test runs, or raced from its file with Tracks::OpenLocal); refused elsewhere (false, and the log says why), and taken back by itself when another map opens. Faces are solid from both sides. Requires host 0.26.0.

Example
int track = Draw::Model(Plugins::Folder() + "tracks/" + Editor::MapName() + ".txt");
Draw::Collide(track);

Scale

bool Draw::Scale(int, double)

Makes a shape bigger or smaller: 1 is the size it was made. Requires host 0.20.0.

Example
Draw::Scale(star, 0.5);

Effect

bool Draw::Effect(const string &in, double x, double y, double z, double scale = 1, double nx = 0, double ny = 0, double nz = 1)

Plays one of the game's particle effects once at a point, by its object path, scale times its size and turned to face along nx, ny, nz (up by default). False if there's no such effect. Custom effect files can't be loaded: the game only loads its own packaged content. Requires host 0.20.0.

Example
Draw::Effect("/Game/Art/NS_BallExplosion.NS_BallExplosion", x, y, z, 0.5);

Sound

bool Draw::Sound(const string &in, double volume = 1, double pitch = 1)

Plays a sound once, not placed in the world: one of the game's, by its object path, or the plugin's own .wav file (16-bit PCM, mono or stereo, any rate), by its full path. False if there's no such sound; a file that can't be played says why in the log. Requires host 0.20.0.

Example
Draw::Sound("/Game/Sound/Gameplay/SFX_SoftPop.SFX_SoftPop", 0.5, 1.2);
Draw::Sound(Plugins::Folder() + "sounds/boing.wav");