atl/render.hpp
Rendering and visual helpers: sm.render, sm.visualization, sm.debris, sm.particle, sm.cullSphereGroup, sm.builderGuide and sm.jsonGui.
BlueprintVisualization
Section titled "BlueprintVisualization"[client] A ghost of a blueprint in the world.
class BlueprintVisualization : public atl::Objectvoid setPosition(Vec3 p) const;Moves, rotates and scales the ghost.
Parameters
p(Vec3): World position
Lua: BlueprintVisualization:setPosition
void setRotation(Quat q) const;Moves, rotates and scales the ghost.
Parameters
q(Quat)
Lua: BlueprintVisualization:setRotation
void setScale(Vec3 s) const;Moves, rotates and scales the ghost.
Parameters
s(Vec3)
Lua: BlueprintVisualization:setScale
void setVisualizationColor(StringView color) const;How it's drawn, e.g. "valid" / "invalid".
Parameters
color(StringView): Visualization color name to render the blueprint in.
Lua: BlueprintVisualization:setVisualizationColor
void updateBuilderGuide() const;For builder guides: call when the guided creation changes.
Lua: BlueprintVisualization:updateBuilderGuide
void destroy() const;Removes the ghost.
Lua: BlueprintVisualization:destroy
CullSphereGroup
Section titled "CullSphereGroup"Tracks which of many spheres (by id) are near a moving point.
class CullSphereGroup : public atl::Objectvoid addSphere(int id, Vec3 position, double radius) const;Adds a sphere. Duplicate ids are ignored.
Parameters
id(int): Sphere id.position(Vec3): Sphere position.radius(double): Sphere radius.
Lua: CullSphereGroup:addSphere
void removeSphere(int id) const;Removes a sphere.
Parameters
id(int): Sphere id.
Lua: CullSphereGroup:removeSphere
Delta delta(Vec3 position, double innerRadius, double outerRadius) const;Spheres that left outerRadius / entered innerRadius since the last call.
Parameters
position(Vec3)innerRadius(double)outerRadius(double)
Returns Delta
Vector<int> overlaps(Vec3 position, double radius) const;Ids of every sphere overlapping a sphere at position.
Parameters
position(Vec3)radius(double)
Returns Vector<int>
Vector<int> leave() const;Leaves every active sphere, returning their ids.
Returns Vector<int>
Ids of the spheres that left and entered.
struct DeltaVector<int> removed, added;BuilderGuide
Section titled "BuilderGuide"Compares a creation against a blueprint, stage by stage.
class BuilderGuide : public atl::Objectint id() const;The guide's id.
Returns int
Lua: BuilderGuide:getId
int currentStageIndex() const;The stage being built.
Returns int
Lua: BuilderGuide:getCurrentStageIndex
bool isComplete() const;True when every stage is built.
Returns bool
Lua: BuilderGuide:isComplete
void update() const;Rechecks the creation; call whenever it changes.
Lua: BuilderGuide:update
void destroy() const;Destroys the guide.
Lua: BuilderGuide:destroy
Stage stageInfo() const;Reads the current stage's progress.
Returns Stage
Lua: BuilderGuide:getStageInfo
Errors errorInfo() const;Reads the recorded mismatches (needs recordErrors).
Returns Errors
Lua: BuilderGuide:getErrorInfo
What remains to be built in the current stage.
struct Stageint blocksLeft = 0, partsLeft = 0, jointsLeft = 0, connectionsLeft = 0;Errors
Section titled "Errors"Counts of mismatches against the blueprint.
struct Errorsint blocks = 0, parts = 0, joints = 0, connections = 0, connectionsReversed = 0;JsonWidget
Section titled "JsonWidget"A widget of a JsonGui. All [client].
class JsonWidget : public atl::Objectvoid setVisible(bool visible) const;Shows or hides the widget.
Parameters
visible(bool): The widgets new visibility state.
Lua: JsonWidget:setVisible
void setPosition(int x, int y) const;Moves the widget (in 720p units) without changing its JSON.
Parameters
x(int): The x position.y(int): The y position.
Lua: JsonWidget:setPosition
void setPreview(const Uuid &item) const;Shows an item preview.
Parameters
item(const Uuid &)
Lua: JsonWidget:setPreview
void setBlueprintPreview(StringView blueprintPath) const;Shows a blueprint preview by path.
Parameters
blueprintPath(StringView)
Lua: JsonWidget:setPreview
void clearPreview() const;Removes the preview.
Lua: JsonWidget:setPreview
String userString(StringView key) const;Reads / writes a string stored on the widget.
Parameters
key(StringView): The key connected to the value.
Returns String
Lua: JsonWidget:getUserString
void setUserString(StringView key, StringView value) const;Reads / writes a string stored on the widget.
Parameters
key(StringView): The key connected to the value.value(StringView): The value being written onto the widget.
Lua: JsonWidget:setUserString
Effect effect(StringView name) const;An effect attached to the widget.
Parameters
name(StringView): The name of the effect on the json widget to get.
Returns Effect
Lua: JsonWidget:getEffect
void startEffect(StringView name) const;Starts / stops an effect attached to the widget.
Parameters
name(StringView): The name of the effect on the json widget to start.
Lua: JsonWidget:startEffect
void stopEffect(StringView name, bool immediate = false) const;Starts / stops an effect attached to the widget.
Parameters
name(StringView): The name of the effect to stop.immediate(bool): If the effect should stop immediately. (Optional) (Defaults to false)
Lua: JsonWidget:stopEffect
bool isEffectPlaying(StringView name) const;Whether an attached effect is playing / has finished.
Parameters
name(StringView): The name of the effect.
Returns bool
Lua: JsonWidget:isEffectPlaying
bool isEffectDone(StringView name) const;Whether an attached effect is playing / has finished.
Parameters
name(StringView): The name of the effect.
Returns bool
Lua: JsonWidget:isEffectDone
JsonGui
Section titled "JsonGui"A GUI built from a table "DOM" (see the game's JsonGui docs) instead of a .layout file.
class JsonGui : public atl::Objectvoid render(const Value &dom, bool forceProperties = false) const;Re-renders from dom; forceProperties re-applies unchanged properties too.
Parameters
dom(const Value &): A table representing the gui elements to showforceProperties(bool): Force update widget properties (optional). (Defaults to false)
Lua: JsonGui:render
JsonWidget widget(StringView name) const;A widget by name.
Parameters
name(StringView): The name of the widget.
Returns JsonWidget
Lua: JsonGui:getWidget
Position widgetAbsolutePosition(StringView name) const;A widget's position on screen.
Parameters
name(StringView)
Returns Position
bool isActive() const;True while open.
Returns bool
Lua: JsonGui:isActive
bool isHidden() const;True while hidden.
Returns bool
Lua: JsonGui:isHidden
void setHidden(bool hidden) const;Hides or shows the GUI.
Parameters
hidden(bool): True if the gui should be hidden.
Lua: JsonGui:setHidden
void close() const;Closes the GUI.
Lua: JsonGui:close
void clearOnCloseCallback() const;Removes the on-close callback.
Lua: JsonGui:clearOnCloseCallback
Position
Section titled "Position"A position in 720p units.
struct Positiondouble left = 0, top = 0;sm::render
Section titled "sm::render"Render setting overrides. Mostly [client]; each reset* restores the default.
inline Value defaultFog();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultFog
inline Value defaultVolumetricFog();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultVolumetricFog
inline Value defaultGI();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultGI
inline Value defaultHorizonLight();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultHorizonLight
inline Value defaultCameraLight();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultCameraLight
inline Value defaultReflectionColor();The default settings, as tables of the matching set* arguments.
Returns Value
Lua: sm.render.getDefaultReflectionColor
inline double defaultVoxelLODBoost();The default settings, as tables of the matching set* arguments.
Returns double
Lua: sm.render.getDefaultVoxelLODBoost
inline double drawDistance();The view distance.
Returns double
Lua: sm.render.getDrawDistance
inline bool isOutdoor();True when the camera is outdoors.
Returns bool
Lua: sm.render.isOutdoor
inline double outdoorLighting();The day/night lighting fraction.
Returns double
Lua: sm.render.getOutdoorLighting
inline void setOutdoorLighting(double v);Overrides the day/night lighting fraction.
Parameters
v(double): The fraction of the day cycle lighting.
Lua: sm.render.setOutdoorLighting
inline void setCinematic(bool cinematic);Turns the cinematic render mode on or off.
Parameters
cinematic(bool): If true, sets to cinematic
Lua: sm.render.setCinematic
inline ScreenPoint toScreen(Vec3 world, int width, int height);Where world appears on a screen of width x height pixels.
Parameters
world(Vec3): World position to alignwidth(int): Screen widthheight(int): Screen height
Returns ScreenPoint
Lua: sm.render.getScreenCoordinatesFromWorldPosition
inline void setFog(const Fog &f);Overrides the fog.
Parameters
f(const Fog &)
Lua: sm.render.setFog
inline void resetFog();Restores the default fog.
Lua: sm.render.resetFog
inline void setVolumetricFog(double min, double max, double loopSpeed, Vec3 scrollSpeed, Vec3 scale, double intensity);Overrides the volumetric fog.
Parameters
min(double): Fog min.max(double): Fog max.loopSpeed(double): Fog loop speed.scrollSpeed(Vec3): Fog scroll speed.scale(Vec3): Fog scale.intensity(double): Fog intensity.
Lua: sm.render.setVolumetricFog
inline void resetVolumetricFog();Restores the default volumetric fog.
Lua: sm.render.resetVolumetricFog
inline void setGI(double weight);Overrides the global illumination weight.
Parameters
weight(double): GI weight.
Lua: sm.render.setGI
inline void resetGI();Restores the default global illumination.
Lua: sm.render.resetGI
inline void setHorizonLight(Color top, Color horizon, Color bottom, Vec3 direction, double startDistance, double endDistance, double falloff);Overrides the sky's horizon light.
Parameters
top(Color): Color of the top of the horizon light.horizon(Color): Color of the horizon of the horizon light.bottom(Color): Color of the bottom of the horizon light.direction(Vec3): Direction of the horizon light.startDistance(double): Start distance for the horizon light. (Optional)endDistance(double): End distance for the horizon light. (Optional)falloff(double): Falloff factor for the horizon light. (Optional)
Lua: sm.render.setHorizonLight
inline void resetHorizonLight();Restores the default horizon light.
Lua: sm.render.resetHorizonLight
inline void setCameraLight(const CameraLight &l);Overrides the camera light.
Parameters
l(const CameraLight &)
Lua: sm.render.setCameraLight
inline void resetCameraLight();Restores the default camera light.
Lua: sm.render.resetCameraLight
inline void setLUT(StringView a, Optional<String> b = atl::none, Optional<double> blend = atl::none);Color grading: blends LUT texture a toward b.
Parameters
a(StringView): Name of LUT A.b(Optional<String>): Name of LUT B.blend(Optional<double>): blend between 0.0 and 1.0 for LUT A and B. (Defaults to 0.0)
Lua: sm.render.setLUT
inline void resetLUT();Restores the default color grading.
Lua: sm.render.resetLUT
inline void setReflectionLevelColor(StringView level, double min, double max, double mul);Overrides the reflection color of one level.
Parameters
level(StringView)min(double): Color min.max(double): Color max.mul(double): Color mul.
Lua: sm.render.setReflectionLevelColor
inline void resetAllReflectionColor();Restores every reflection color.
Lua: sm.render.resetAllReflectionColor
inline void setVoxelLODBoost(double boost);Overrides / restores the voxel terrain level-of-detail boost.
Parameters
boost(double): Voxel terrain LOD boost.
Lua: sm.render.setVoxelLODBoost
inline void resetVoxelLODBoost();Overrides / restores the voxel terrain level-of-detail boost.
Lua: sm.render.resetVoxelLODBoost
inline void setClouds(const Clouds &c);Overrides the clouds.
Parameters
c(const Clouds &)
Lua: sm.render.setCloudSettings
ScreenPoint
Section titled "ScreenPoint"A point in screen pixels.
struct ScreenPointdouble x = 0, y = 0;Distance and height fog settings.
struct Fogdouble startDistance = 0, endDistance = 0, falloff = 0;Color startColor, endColor;double verticalOpacity = 0, verticalFadeDistance = 0, verticalFalloff = 0, verticalStart = 0, verticalEnd = 0;Color verticalStartColor, verticalEndColor;double fadeDistance = 0;CameraLight
Section titled "CameraLight"The light that follows the camera, with optional far values.
struct CameraLightdouble intensity = 0, range = 0;Color color;Optional<double> farIntensity, farRange;Optional<Color> farColor;Clouds
Section titled "Clouds"Cloud settings.
struct Cloudsdouble coverage = 0, height = 0, radius = 0, tallnessScale = 0, directionalLightMod = 0;Vec3 scroll, scrollRotation;sm::visualization
Section titled "sm::visualization"[client] The placement visualizations the game draws for the local player.
inline BlueprintVisualization createBlueprint(StringView path);A ghost of the blueprint file at path.
Parameters
path(StringView): Table with blueprint information to be visualized
Returns BlueprintVisualization
Lua: sm.visualization.createBlueprint
inline BlueprintVisualization createBlueprint(const Value &blueprint);A ghost of a blueprint table.
Parameters
blueprint(const Value &): Table with blueprint information to be visualized
Returns BlueprintVisualization
Lua: sm.visualization.createBlueprint
inline BlueprintVisualization createBuilderGuide(StringView path, const Shape &shape, bool ignoreBlockUuid = false, Optional<String> completeEffect = atl::none, Optional<String> completeEffectAtBase = atl::none);Shows how to build blueprint path on the creation rooted at shape.
Parameters
path(StringView): A file path to the builder guide blueprintshape(const Shape &): RootShapefor comparing the creation fromignoreBlockUuid(bool): Should block uuid be evaluated for stage completion (Defaults to false)completeEffect(Optional<String>): The name of the effect that should be played at the placed block once the builder guide stage is completed (Defaults to "")completeEffectAtBase(Optional<String>): The name of the effect that should be played at the base once the builder guide stage is completed (Defaults to "")
Returns BlueprintVisualization
Lua: sm.visualization.createBuilderGuide
inline void drawLine(Vec3 from, Vec3 to, Optional<Color> color = atl::none);Draws a builder-guide connection line.
Parameters
from(Vec3): The starting point for the line.to(Vec3): The end point for the line.color(Optional<Color>): The color for the line. Defaults to yellow. (Optional)
Lua: sm.visualization.drawLine
inline ShapePlacement shapePlacement();Reads the current shape placement ghost.
Returns ShapePlacement
Lua: sm.visualization.getShapePlacementVisualization
inline void setBlockVisualization(Vec3 position, bool illegal = false);A block ghost at position in the world.
Parameters
position(Vec3)illegal(bool)
Lua: sm.visualization.setBlockVisualization
template <class On> void setBlockVisualization(Vec3 position, bool illegal, const On &on);A block ghost at position on a Lift, Shape or Joint.
Parameters
position(Vec3): The local space positionillegal(bool): Whether the visualization should render as illegal (Defaults to false)on(const On &)
Lua: sm.visualization.setBlockVisualization
inline void setCreationBodies(const Vector<Body> &bodies);The creation (lift) visualization: which bodies it shows, and whether it's visible and valid.
Parameters
bodies(const Vector<Body> &)
Lua: sm.visualization.setCreationBodies
inline void setCreationVisible(bool visible);The creation (lift) visualization: which bodies it shows, and whether it's visible and valid.
Parameters
visible(bool): Should the creation visualization be visible
Lua: sm.visualization.setCreationVisible
inline void setCreationValid(bool valid, Optional<bool> lift = atl::none);The creation (lift) visualization: which bodies it shows, and whether it's visible and valid.
Parameters
valid(bool): Should the visualization should render be validlift(Optional<bool>): Should the visualization should render be lift or place (Defaults to false)
Lua: sm.visualization.setCreationValid
inline void setCreationFreePlacement(bool on);Free placement: position and rotation are set by you instead of by the lift.
Parameters
on(bool): Should the creation visualization be free placement
Lua: sm.visualization.setCreationFreePlacement
inline void setCreationFreePlacementPosition(Vec3 p);Free placement: position and rotation are set by you instead of by the lift.
Parameters
p(Vec3): World position of the creation visualization
Lua: sm.visualization.setCreationFreePlacementPosition
inline void setCreationFreePlacementRotation(int index);Free placement: position and rotation are set by you instead of by the lift.
Parameters
index(int): Index to rotate the creation visualization with
Lua: sm.visualization.setCreationFreePlacementRotation
inline void setLiftVisible(bool visible);The lift ghost's visibility, validity, position and level.
Parameters
visible(bool): Whether the lift visualization is visible
Lua: sm.visualization.setLiftVisible
inline void setLiftValid(bool valid);The lift ghost's visibility, validity, position and level.
Parameters
valid(bool): Whether the visualization should render as valid
Lua: sm.visualization.setLiftValid
inline void setLiftPosition(Vec3 p);The lift ghost's visibility, validity, position and level.
Parameters
p(Vec3): World position of the lift visualization
Lua: sm.visualization.setLiftPosition
inline void setLiftLevel(int level);The lift ghost's visibility, validity, position and level.
Parameters
level(int): The level of the lift
Lua: sm.visualization.setLiftLevel
ShapePlacement
Section titled "ShapePlacement"The shape the local player is placing.
struct ShapePlacementbool isLegal = false;Uuid shapeUuid;Vec3 worldPosition;Quat worldRotation;sm::debris
Section titled "sm::debris"[client] Visual-only physics debris.
inline void create(const Uuid &uuid, Vec3 position, Quat rotation, const Options &o = {});A falling copy of shape uuid that collides with the world but that nothing collides with.
Parameters
uuid(const Uuid &)position(Vec3)rotation(Quat)o(const Options &)
Lua: sm.debris.createDebris
inline void createBlackHole(Vec3 position, const BlackHole &b = {});Pulls nearby debris toward position.
Parameters
position(Vec3)b(const BlackHole &)
Lua: sm.debris.createBlackHole
Options
Section titled "Options"Optional debris settings.
struct OptionsOptional<Vec3> velocity, angularVelocity;Optional<Color> color;Optional<double> timeToLive, gravity, friction, linearDamping, angularDamping, time;BlackHole
Section titled "BlackHole"Black hole settings.
struct BlackHoleOptional<double> radius, force;Optional<Vec3> position2;Makes it a line segment from the position to here.
Optional<double> wanderForce, dissolveRadius, timeToLive;Makes it a line segment from the position to here.
Optional<int> channel;Makes it a line segment from the position to here.
sm::particle
Section titled "sm::particle"inline void create(StringView name, Vec3 position, Quat rotation = {}, Optional<Color> color = atl::none);[client] Spawns a particle effect by name.
Parameters
name(StringView): The particle name.position(Vec3): The position.rotation(Quat): The rotation. (Defaults to no rotation)color(Optional<Color>): The blend color. (Defaults to white)
Lua: sm.particle.createParticle
sm::cullSphereGroups
Section titled "sm::cullSphereGroups"inline CullSphereGroup create();A new empty group.
Returns CullSphereGroup
Lua: sm.cullSphereGroup.newCullSphereGroup
sm::builderGuides
Section titled "sm::builderGuides"inline BuilderGuide create(StringView blueprintPath, const Shape &root, bool ignoreBlockUuid = false, bool recordErrors = false, bool allowExtraBlocks = false);Creates a guide comparing the creation at root with a blueprint.
Parameters
blueprintPath(StringView): A file path to the builder guide blueprint.root(const Shape &): RootShapefor comparing the creation from.ignoreBlockUuid(bool): Should block uuid be ignored for stage completion. (Defaults to false)recordErrors(bool): Should errors be recorded. Needed for getErrorInfo (Defaults to false)allowExtraBlocks(bool): Should extra blocks be ignored for stage completion. (Defaults to true)
Returns BuilderGuide
Lua: sm.builderGuide.createBuilderGuide
sm::jsonGui
Section titled "sm::jsonGui"inline JsonGui create(const Value &settings = {});Creates a JsonGui. settings: { isHud, isInteractive, needsCursor, hidesHotbar, backgroundAlpha, ... } (see GuiOptions).
Parameters
settings(const Value &): Table with bool settings for: isHud, isInteractive, needsCursor, hidesHotbar, isOverlapped, backgroundAlpha, handleKeySetup, name, layer
Returns JsonGui
Lua: sm.jsonGui.createGui
inline ViewSize viewSize();[client] The window size in 720p units.
Returns ViewSize
Lua: sm.jsonGui.getViewSize
ViewSize
Section titled "ViewSize"A size in 720p units.
struct ViewSizeint width = 0, height = 0;