Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
iengine.h File Reference

The interface the game uses to access the engine. More...

Go to the source code of this file.

Functions

void moveragdoll (dynent *d)
 Update a ragdoll's position and physics.
 
void cleanragdoll (dynent *d)
 Deletes the ragdoll associated with the passed dynent.
 
void gle::begin (GLenum mode)
 Sets the type of primitive to draw.
 
void gle::begin (GLenum mode, int numverts)
 Sets up an immediate-like rendering context.
 
void gle::attrib (const vec &v)
 Adds three float values, packed in a vec, to the attribbuf.
 
void gle::attribf (float x, float y)
 Adds two float values to the attribbuf.
 
void gle::colorf (float x, float y, float z, float w=0.0f)
 Calls glVertexAttrib of the appropriate dimension.
 
void gle::colorub (uchar x, uchar y, uchar z, uchar w=255)
 Calls glVertexAttrib4Nub to set the color of an attribute.
 
void gle::deftexcoord0 (int size=2, int format=GL_FLOAT)
 Sets texcoord0 with the given dimensionality and type.
 
void gle::defvertex (int size=3, int format=GL_FLOAT)
 
int gle::end ()
 
void initcscmds ()
 Initializes core cubescript commands.
 
void conoutf (const char *s,...) PRINTFARGS(1
 Prints a message to the ingame console.
 
void void conoutf (int type, const char *s,...) PRINTFARGS(2
 Prints a message to the ingame console, with a specific type flag.
 
void clear_console ()
 Clears the console KeyM history hashtable.
 
void initconsolecmds ()
 Initializes console cubescript commands.
 
FILE * getlogfile ()
 Returns the logfile (Linux) or stdout (Windows)
 
void logoutf (const char *fmt,...)
 Prints a line to the log file.
 
bool initsdl ()
 Initializes SDL functions necessary to run a game.
 
void fatal (const char *s,...) PRINTFARGS(1
 Immediately shuts down the game and prints error message(s)
 
void int getclockmillis ()
 Returns the number of milliseconds since the game started.
 
std::string enginebuilddate ()
 Returns the engine library's build date.
 
std::string enginestr ()
 Returns the engine library's name string.
 
void initmathcmds ()
 Adds math commands to the cubescript interpreter.
 
void initstrcmds ()
 Adds string commands to the cubescript interpreter.
 
void initcontrolcmds ()
 Adds program control commands to the cubescript interpreter.
 
bool interceptkey (int sym)
 
void inputgrab (bool on)
 
void checkinput (int map=0)
 Handles input from SDL.
 
void ignoremousemotion ()
 Flushes all queued mouse events.
 
void keyrepeat (bool on, int mask=~0)
 Sets the key repeat mask for SDL.
 
void initmenuscmds ()
 
void inittextcmds ()
 Initializes textedit cubescript commands.
 
bool UI::hascursor ()
 Queries UI windows' cursor input ability.
 
void UI::getcursorpos (float &x, float &y)
 Queries current UI cursor location.
 
void UI::resetcursor ()
 Sets the cursor to the middle of the screen.
 
bool UI::movecursor (int dx, int dy)
 Moves the UI cursor by the amount perscribed.
 
void UI::setup ()
 Creates a new UI World object, used globally for UI functionality.
 
void UI::update ()
 Updates cursor vis a vis the UI elements.
 
void UI::cleanup ()
 Deletes all of the open windows exposed and deletes the UI world object.
 
bool UI::showui (const char *name)
 Shows a UI window with the specified name.
 
bool UI::hideui (const char *name)
 Hides an open UI window with the specified name.
 
bool UI::toggleui (const char *name)
 Toggles the open/closed state of a window.
 
void UI::holdui (const char *name, bool on)
 Opens or closes the specified UI.
 
bool UI::uivisible (const char *name)
 Gets the open/close status of a UI window.
 
void UI::inituicmds ()
 Binds the UI commands to the command parser.
 
void initaacmds ()
 Initializes AA cubescript commands.
 
void inithudcmds ()
 Initializes HUD cubescript commands.
 
void initnormalcmds ()
 Initializes normal.cpp cubescript commands.
 
void initoctarendercmds ()
 Initializes octarender.cpp cubescript commands.
 
void initrenderglcmds ()
 Initializes rendergl.cpp cubescript commands.
 
vec camdir ()
 returns the camera matrix direction component
 
vec camright ()
 returns the camera matrix right component
 
vec camup ()
 returns the camera matrix up component
 
void disablezoom ()
 Unsets any zoom progress and disables zooming.
 
vec calcavatarpos (const vec &pos, float dist)
 
void damageblend (int n)
 
void damagecompass (int n, const vec &loc)
 
void bindminimap ()
 Binds a GL texture to the minimaptex global object.
 
void resethudmatrix ()
 
void pushhudmatrix ()
 
void flushhudmatrix (bool flushparams=true)
 
void pophudmatrix (bool flush=true, bool flushparams=true)
 
void resethudshader ()
 Binds the HUD shader via glUseProgram()
 
void initgbuffer ()
 
void computezoom ()
 
void enablepolygonoffset (GLenum type)
 Enables GL offset mode for overlay drawing.
 
void disablepolygonoffset (GLenum type)
 Disables GL offset mode for overlay drawing.
 
void vectoryawpitch (const vec &v, float &yaw, float &pitch)
 Returns 2 Euler angles for a given vector.
 
void gl_checkextensions ()
 Ensures computer environment can run the engine.
 
void gl_init ()
 Sets up GL global parameters for the game.
 
void gl_resize ()
 Changes the viewport size to set values.
 
void gl_setupframe (bool force=false)
 Sets render frame variables up.
 
void gl_drawframe (int crosshairindex, void(*gamefxn)(), void(*hudfxn)(), void(*editfxn)(), void(*hud2d)())
 Draws the frame to the screen.
 
void drawminimap (int yaw, int pitch, vec loc, const cubeworld &world, int scalefactor=1)
 Draws a minimap texture.
 
void initrenderlightscmds ()
 Initializes renderlights CubeScript commands.
 
void clearshadowcache ()
 Clears the shadow maps cached in the shadow atlas.
 
void initrendermodelcmds ()
 Initializes rendermodel CubeScript commands.
 
void rendermodel (std::string_view mdl, int anim, const vec &o, float yaw=0, float pitch=0, float roll=0, int cull=Model_CullVFC|Model_CullDist|Model_CullOccluded, dynent *d=nullptr, modelattach *a=nullptr, int basetime=0, int basetime2=0, float size=1, const vec4< float > &color=vec4< float >(1, 1, 1, 1))
 Renders a world model.
 
int intersectmodel (std::string_view mdl, int anim, const vec &pos, float yaw, float pitch, float roll, const vec &o, const vec &ray, float &dist, dynent *d=nullptr, modelattach *a=nullptr, int basetime=0, int basetime2=0, float size=1)
 Returns the intersection status of a model.
 
void abovemodel (vec &o, const char *mdl)
 Adds the z height of the model to the vector passed.
 
const char * mapmodelname (int i)
 Returns the mapmodel name at the given index.
 
void preloadmodel (std::string name)
 Adds a model to the cache of models to load.
 
model * loadmapmodel (int n)
 Loads the mapmodel assigned to the specified index.
 
model * loadmodel (const char *name, int i=-1, bool msg=false)
 Loads the model with the associated name.
 
void flushpreloadedmodels (bool msg=true)
 Clears the loaded model cache.
 
void preloadusedmapmodels (bool msg=false, bool bih=false)
 Preloads mapmodels corresponding to the world's mapmodel entities.
 
void clear_models ()
 Clears all loaded models' basic information.
 
const char * getentname (int i)
 Returns the entity name of of a given entity type index.
 
void regular_particle_splash (int type, int num, int fade, const vec &p, int color=0xFFFFFF, float size=1.0f, int radius=150, int gravity=2, int delay=0)
 Spawns a splash particle with the designated properties.
 
void regular_particle_flame (int type, const vec &p, float radius, float height, int color, int density=3, float scale=2.0f, float speed=200.0f, float fade=600.0f, int gravity=-15)
 Spawns a flame particle.
 
void particle_splash (int type, int num, int fade, const vec &p, int color=0xFFFFFF, float size=1.0f, int radius=150, int gravity=2)
 
void particle_trail (int type, int fade, const vec &from, const vec &to, int color=0xFFFFFF, float size=1.0f, int gravity=20)
 
void particle_text (const vec &s, const char *t, int type, int fade=2000, int color=0xFFFFFF, float size=2.0f, int gravity=0)
 
void particle_textcopy (const vec &s, const char *t, int type, int fade=2000, int color=0xFFFFFF, float size=2.0f, int gravity=0)
 
void particle_icon (const vec &s, int ix, int iy, int type, int fade=2000, int color=0xFFFFFF, float size=2.0f, int gravity=0)
 
void particle_meter (const vec &s, float val, int type, int fade=1, int color=0xFFFFFF, int color2=0xFFFFF, float size=2.0f)
 
void particle_flare (const vec &p, const vec &dest, int fade, int type, int color=0xFFFFFF, float size=0.28f, physent *owner=nullptr)
 
void particle_fireball (const vec &dest, float max, int type, int fade=-1, int color=0xFFFFFF, float size=4.0f)
 
void removetrackedparticles (physent *owner=nullptr)
 
void initparticles ()
 Loads the shaders/renderer objects to render particles.
 
void initrendertextcmds ()
 Initializes rendertext Cubescript commands.
 
bool setfont (const char *name)
 Sets the currently used font.
 
void initrenderwindowcmds ()
 Initializes renderwindow Cubescript commands.
 
void swapbuffers (bool overlay=true)
 Refreshes the rendered screenbuffer.
 
void setupscreen ()
 Sets up the SDL window the application runs in.
 
void restoregamma ()
 
void restorevsync ()
 
void resetfpshistory ()
 Sets the entirety of the fps history buffer (used for averaging the FPS readout) to 1.
 
void limitfps (int &millis, int curmillis)
 delays a frame by a specified amount
 
void updatefpshistory (int millis)
 Adds an entry to the fps history.
 
void cleargamma ()
 Sets the SDL gamma level to 1.
 
void renderbackground (const char *caption=nullptr, Texture *mapshot=nullptr, const char *mapname=nullptr, const char *mapinfo=nullptr, bool force=false)
 
void renderprogress (float bar, const char *text, bool background=false)
 Renders a loading progress bar at the bottom center of the window.
 
void initshadercmds ()
 Initializes shader Cubescript commands.
 
void loadshaders ()
 Loads a series of shaders hardcoded into the engine.
 
void initstains ()
 Loads stains into the global stains array.
 
void addstain (int type, const vec &center, const vec &surface, float radius, const bvec &color=bvec(0xFF, 0xFF, 0xFF), int info=0)
 
void addstain (int type, const vec &center, const vec &surface, float radius, int color, int info=0)
 
void inittexturecmds ()
 Initializes texture Cubescript commands.
 
Texture * textureload (const char *name, int clamp=0, bool mipit=true, bool msg=true)
 
void packvslot (std::vector< uchar > &buf, int index)
 Packs into the passed char vector the contents of a VSlot.
 
void packvslot (std::vector< uchar > &buf, const VSlot *vs)
 Packs into the passed char vector the contents of a VSlot.
 
bool settexture (const char *name, int clamp=0)
 
void adddynlight (const vec &o, float radius, const vec &color, int fade=0, int peak=0, int flags=0, float initradius=0, const vec &initcolor=vec(0, 0, 0), physent *owner=nullptr, const vec &dir=vec(0, 0, 0), int spot=0)
 
void removetrackeddynlights (const physent *owner=nullptr)
 
bool isheightmap (int o, bool empty, const cube &c)
 Determines if a heightmap is active for the current selection.
 
void heightmaprun (int dir, int mode)
 
void initheightmapcmds ()
 Initializes heightmap Cubescript commands.
 
int findmaterial (const char *name)
 Returns the bitmask for the given material name.
 
void initoctaworldcmds ()
 Initializes octaworld Cubescript commands.
 
void freeocta (std::array< cube, 8 > *&c)
 Deletes a cube and its children.
 
void getcubevector (const cube &c, int d, int x, int y, int z, ivec &p)
 
void optiface (const uchar *p, cube &c)
 
void initoctaeditcmds ()
 Initializes the octaedit cubescript commands.
 
void clearremappedvslots ()
 
void boxs3D (const vec &o, vec s, int g, bool boxoutline)
 Draws a box corresponding to positions in worldspace.
 
void boxs (int orient, vec o, const vec &s, float size, bool boxoutline)
 Draws a box corresponding to positions in worldspace.
 
void boxs (int orient, vec o, const vec &s, bool boxoutline)
 Draws a box corresponding to positions in worldspace.
 
void boxsgrid (int orient, vec o, vec s, int g, bool boxoutline)
 
bool editmoveplane (const vec &o, const vec &ray, int d, float off, vec &handle, vec &dest, bool first)
 
void countselchild (const std::array< cube, 8 > &c, const ivec &cor, int size)
 Assigns selchildcount the number of cubes in selection.
 
void normalizelookupcube (const ivec &o)
 
void updateselection ()
 
bool packeditinfo (const editinfo *e, int &inlen, uchar *&outbuf, int &outlen)
 
bool unpackeditinfo (editinfo *&e, const uchar *inbuf, int inlen, int outlen)
 
void freeeditinfo (editinfo *&e)
 Safely frees an editinfo object.
 
bool packundo (bool undo, int &inlen, uchar *&outbuf, int &outlen)
 
bool noedit (bool view=false, bool msg=true)
 
bool pointinsel (const selinfo &sel, const vec &o)
 Determines whether selection contains location at specified location.
 
void cancelsel ()
 Deselects edit selection.
 
void addundo (undoblock *u)
 Adds an undo entry to the global undos vector.
 
cubeblockcube (int x, int y, int z, const block3 &b, int rgrid)
 Looks up a world cube inside the block passed.
 
void makeundo (selinfo &s)
 Adds an undo entry to the undos vector given the passed selection.
 
void makeundo ()
 Adds an undo entry to the undos vector given the current selection.
 
void reorient ()
 Reorients sel to point in the direction of orient.
 
int countblock (block3 *b)
 Counts the number of cubes (incl. children) within a block3 volume.
 
void forcenextundo ()
 Sets lastsel's orientation flag to -1.
 
void freeundo (undoblock *u)
 Deletes an undoblock object.
 
void pasteblock (const block3 &b, selinfo &sel, bool local)
 Pastes the block3 passed to the volume in the selinfo object.
 
undoblocknewundocube (const selinfo &s)
 Creates an undoblock object given a cube selection.
 
void remapvslots (cube &c, bool delta, const VSlot &ds, int orient, bool &findrep, VSlot *&findedit)
 
void edittexcube (cube &c, int tex, int orient, bool &findrep)
 Changes the texture for a cube and its children.
 
bool haveselent ()
 Queries whether the current selection has entities selected.
 
void pastecube (const cube &src, cube &dst)
 Copies and pastes a single cube (with its children).
 
void pasteundoblock (block3 *b, const uchar *g)
 Pastes an undo block associated with the passed block3 object.
 
bool uncompresseditinfo (const uchar *inbuf, int inlen, uchar *&outbuf, int &outlen)
 
void unpackundocube (ucharbuf &buf, uchar *outbuf)
 Unpacks a buffer containing an undo action into a unsigned char array.
 
void multiplayerwarn ()
 Prints a warning message to the console.
 
ushort getmaterial (cube &c)
 Returns the material bitmask for the given cube.
 
void linkedpush (cube &c, int d, int x, int y, int dc, int dir)
 Pushes cubes linked with the passed cube.
 
float raycubepos (const vec &o, const vec &ray, vec &hit, float radius=0, int mode=Ray_ClipMat, int size=0)
 Returns the distance before a ray hits a cube.
 
float rayfloor (const vec &o, vec &floor, int mode=0, float radius=0)
 
bool raycubelos (const vec &o, const vec &dest, vec &hitpos)
 
float rayent (const vec &o, const vec &ray, float radius, int mode, int size, int &orient, int &ent)
 
bool insideworld (const vec &o)
 Queries whether the given vector lies inside the octree world.
 
dynentiterdynents (int i)
 Returns the dynent at index i.
 
bool collide (const physent *d, const vec &dir=vec(0, 0, 0), float cutoff=0.0f, bool playercol=true, bool insideplayercol=false)
 Determines whether the specified physent has collided with the octree world.
 
void avoidcollision (physent *d, const vec &dir, const physent *obstacle, float space)
 
bool movecamera (physent *pl, const vec &dir, float dist, float stepdist)
 
void dropenttofloor (entity *e)
 Drops the map entity to a set distance above the floor.
 
void rotatebb (vec &center, vec &radius, int yaw, int pitch, int roll=0)
 Rotates the center and radius vectors using the given Euler angles.
 
void vecfromyawpitch (float yaw, float pitch, int move, int strafe, vec &m)
 Modifies a vector based on passed movement modifiers.
 
void cleardynentcache ()
 
void updatedynentcache (physent *d)
 
bool entinmap (dynent *d, bool avoidplayers=false)
 Brute force but effective way to find a free spawn spot in the map.
 
void recalcdir (const physent *d, const vec &oldvel, vec &dir)
 Recalculates dir based on the provided physent, normalized to oldvel.
 
void slideagainst (physent *d, vec &dir, const vec &obstacle, bool foundfloor, bool slidecollide)
 Re-projects a physent's velocity according to a given wall normal.
 
void freeblock (block3 *b, bool alloced=true)
 Deletes dynamically allocated cubes to a block entity.
 
block3blockcopy (const block3 &s, int rgrid)
 Allocates a new copy of the given block3 on the heap.
 
void entcancel ()
 Cancels selection of selected entities.
 
void attachentity (extentity &e)
 Attempts to attach the given entity to another entity.
 
void attachentities ()
 Attempts to attach all entities in selection.
 
void removeentityedit (int id)
 
void addentityedit (int id)
 
void detachentity (extentity &e)
 Attempts to dettach the given entity.
 
void entselectionbox (const entity &e, vec &eo, vec &es)
 
void mmboundbox (const entity &e, model *m, vec &center, vec &radius)
 
float getdecalslotdepth (const DecalSlot &s)
 Gets the depth of a decal slot.
 
std::vector< extentity * > & entities::getents ()
 Returns the entities::ents vector.
 
extentityentities::newentity ()
 
void entities::deleteentity (extentity *e)
 
const char * getclientmap ()
 Returns the name of the map currently loaded.
 
const void setmapname (const char *newname)
 Sets the client map string to the provided value.
 
void initworldiocmds ()
 Initializes worldio Cubescript commands.
 

Variables

void void int initing
 
int curtime
 
int lastmillis
 
int elapsedtime
 
int totalmillis
 
FILE * logfile
 
dynentplayer
 The dynamic entity representing the player.
 
bool inbetweenframes
 
bool renderedframe
 
int scr_w
 
int scr_h
 
int desktopw
 
int desktoph
 
bool grabinput
 
bool minimized
 
int mainmenu
 
physentcamera1
 
vec worldpos
 
float fovy
 
bool detachedcamera
 
int xtraverts
 
vec minimapcenter
 
vec minimapradius
 
vec minimapscale
 
matrix4 hudmatrix
 
std::vector< std::string > animnames
 
std::vector< std::string > entnames
 
SDL_Window * screen
 
int fullscreen
 
Texture * notexture
 
int showmat
 
bool allowediting
 
bool multiplayer
 
std::vector< ushort > texmru
 
selinfo repsel
 
int reptex
 
int lasttex
 
int curtexindex
 
int moving
 
int orient
 
int horient
 
bool editmode
 
int entmoving
 
int entediting
 
selinfo sel
 
selinfo lastsel
 
std::deque< undoblock * > undos
 
std::deque< undoblock * > redos
 
int nompedit
 
int hmapedit
 
bool havesel
 
std::vector< editinfo * > editinfos
 
int texpaneltimer
 
ivec cor
 
ivec cur
 
ivec lastcor
 
int gridsize
 
int passthroughsel
 
int outline
 
int dragging
 
int selectcorners
 
vec collidewall
 
int collideinside
 
const physentcollideplayer
 
int numdynents
 
std::vector< dynent * > dynents
 
std::vector< int > entgroup
 
std::vector< extentity * > entities::ents
 The list of extentities corresponding to the cube world's entities.
 

Detailed Description

The interface the game uses to access the engine.

The file contains functions which comprise the API for writing games. This header file is not called by the game internally but should be included in the game code to expose functions to the game.

Function Documentation

◆ abovemodel()

void abovemodel ( vec & o,
const char * mdl )
extern

Adds the z height of the model to the vector passed.

Takes the passed-by-reference vector and adds the z height of the bounding box to the vector given.

Parameters
othe vector to add the height to
mdlthe name of the model object to use

◆ addundo()

void addundo ( undoblock * u)
extern

Adds an undo entry to the global undos vector.

Parameters
theundo object to add

◆ attachentities()

void attachentities ( )
extern

Attempts to attach all entities in selection.

For all eligible entities in the current selection, the engine attempts to link it with its nearest entity it can link with; silently fails and does nothing if no entities in selection are eligible or selected.

◆ attachentity()

void attachentity ( extentity & e)
extern

Attempts to attach the given entity to another entity.

Attempts to attach the entity passed to another entity that it can be attached to, as long as it is within the attach radius.

Fails silently if the given entity has no close by entities to link to or the entity type is ineligible to be linked

Parameters
ethe extentity to attempt to link

◆ attrib()

void gle::attrib ( const vec & v)
extern

Adds three float values, packed in a vec, to the attribbuf.

Parameters
vthe vec to add to the attribbuf

◆ attribf()

void gle::attribf ( float x,
float y )
extern

Adds two float values to the attribbuf.

Parameters
xthe first value to add
ythe second value to add

◆ begin() [1/2]

void gle::begin ( GLenum mode)
extern

Sets the type of primitive to draw.

Parameters
modeone of the GL primitive types (e.g. GL_TRIANGLES, GL_TRIANGLE_STRIP, ..)

◆ begin() [2/2]

void gle::begin ( GLenum mode,
int numverts )
extern

Sets up an immediate-like rendering context.

Does not use glBegin() or other legacy constructs.

Parameters
modeone of the GL primitive types (e.g. GL_TRIANGLES, GL_TRIANGLE_STRIP, ..)
numvertsthe number of vertices to draw

◆ bindminimap()

void bindminimap ( )
extern

Binds a GL texture to the minimaptex global object.

The global variable minimap texture, minimaptex, has a GL buffer bound to it. Before this is called, no texture is associated with it.

◆ blockcopy()

block3 * blockcopy ( const block3 & s,
int rgrid )
extern

Allocates a new copy of the given block3 on the heap.

Generates a new object of type uchar[blocksize] which is filled with the same contents of the passed block. This is operated on by reinterpret_cast<block3 *> to return a pointer of the return type.

Parameters
sthe block3 to copy
thegrid power to copy at
Returns
a pointer to a char array that has been cast to a block3*

◆ blockcube()

cube & blockcube ( int x,
int y,
int z,
const block3 & b,
int rgrid )
extern

Looks up a world cube inside the block passed.

Parameters
xthe x coordiante inside the block3 to look up
ythe y coordiante inside the block3 to look up
zthe z coordiante inside the block3 to look up
bthe block3 object to search inside
rgridthe grid power to look up with
Returns
a reference to the cube found

◆ boxs() [1/2]

void boxs ( int orient,
vec o,
const vec & s,
bool boxoutline )
extern

Draws a box corresponding to positions in worldspace.

Parameters
orientthe orientation direction of the square
othe origin from where to draw the box
sthe displacement vector from the origin to place the opposite corner
boxoutlinetoggles rendering such that it appears outside a cube with the same dimensions

◆ boxs() [2/2]

void boxs ( int orient,
vec o,
const vec & s,
float size,
bool boxoutline )
extern

Draws a box corresponding to positions in worldspace.

Parameters
orientthe orientation direction of the square
othe origin from where to draw the box
sthe displacement vector from the origin to place the opposite corner
sizethe scale factor of the box in the world
boxoutlinetoggles rendering such that it appears outside a cube with the same dimensions

◆ boxs3D()

void boxs3D ( const vec & o,
vec s,
int g,
bool boxoutline )
extern

Draws a box corresponding to positions in worldspace.

Parameters
othe origin from where to draw the box
sthe displacement vector from the origin to place the opposite corner
gthe gridpower to multiply the box by
boxoutlinetoggles rendering such that it appears outside a cube with the same dimensions

◆ camdir()

vec camdir ( )
extern

returns the camera matrix direction component

Returns
a vec containing the transposed transform of the camera matrix and view matrix's dir component

◆ camright()

vec camright ( )
extern

returns the camera matrix right component

Returns
a vec containing the transposed transform of the camera matrix and view matrix's right component

◆ camup()

vec camup ( )
extern

returns the camera matrix up component

Returns
a vec containing the transposed transform of the camera matrix and view matrix's up component

◆ cancelsel()

void cancelsel ( )
extern

Deselects edit selection.

This function deselects the cubes and entities currently selected.

◆ checkinput()

void checkinput ( int map = 0)
extern

Handles input from SDL.

Executes the CubeScript commands associated with any SDL key operations queued.

Parameters
mapthe keymap to use: 0 for default, 1 for edit, 2 for spec

◆ cleanragdoll()

void cleanragdoll ( dynent * d)
extern

Deletes the ragdoll associated with the passed dynent.

The function does nothinf if the dynent does not point to a ragdoll object. Also, the function does nothing if the dynent is a ragdoll that is not present.

Parameters
da dynent pointer.

◆ clear_console()

void clear_console ( )
extern

Clears the console KeyM history hashtable.

Empties the KeyM hashtable keyms, typicall used when shutting down the program.

◆ clear_models()

void clear_models ( )
extern

Clears all loaded models' basic information.

Clears the model information from its associated hashmap. Does not clear preloaded model information.

◆ cleargamma()

void cleargamma ( )
extern

Sets the SDL gamma level to 1.

Sets SDL_SetWindowBrightness of the screen the engine is rendering to to 1, if the screen exists and the current gamma global variable has been changed from its default.

◆ clearshadowcache()

void clearshadowcache ( )
extern

Clears the shadow maps cached in the shadow atlas.

Also clears the radiance hints cache, if enabled.

◆ collide()

bool collide ( const physent * d,
const vec & dir = vec(0, 0, 0),
float cutoff = 0.0f,
bool playercol = true,
bool insideplayercol = false )
extern

Determines whether the specified physent has collided with the octree world.

Parameters
da pointer to the physent
dirthe direction to attempt to collide at
cutoffcollision cutoff slope
playercoltoggles colliding with outside players
insideplayercoltooggles collidign with players you share space with

◆ colorf()

void gle::colorf ( float x,
float y,
float z,
float w = 0.0f )
extern

Calls glVertexAttrib of the appropriate dimension.

If the alpha value (w) is 0, glVertexAttrib3f is called, else glVertexAttrib4f. Sets the color of the attribute currently active.

Parameters
xthe red channel (0..1)
ythe green channel (0..1)
zthe blue channel (0..1)
wthe alpha channel (0..1)

◆ colorub()

void gle::colorub ( uchar x,
uchar y,
uchar z,
uchar w = 255 )
extern

Calls glVertexAttrib4Nub to set the color of an attribute.

Parameters
xthe red channel (0..255)
ythe green channel (0..255)
zthe blue channel (0..255)
wthe alpha channel (0..255)

◆ conoutf() [1/2]

void conoutf ( const char * s,
... )
extern

Prints a message to the ingame console.

This function behaves the same way as printf() except it prints to the console instead.

Parameters
sthe string to print
...the names of variables to substitute into the string, in order

◆ conoutf() [2/2]

void void conoutf ( int type,
const char * s,
... )
extern

Prints a message to the ingame console, with a specific type flag.

This function behaves the same way as printf() except it prints to the console instead. It uses a parameter type to indicate what type of console message to print. The console flags are defined in consts.h.

Parameters
typethe flag to modify the console printout with
sthe string to print
...the names of variables to substitute into the string, in order

◆ countblock()

int countblock ( block3 * b)
extern

Counts the number of cubes (incl. children) within a block3 volume.

Parameters
bthe block to evaluate
Returns
the number of cubes in the block

◆ countselchild()

void countselchild ( const std::array< cube, 8 > & c,
const ivec & cor,
int size )
extern

Assigns selchildcount the number of cubes in selection.

Recursively counts the number of cubes being selected in the current selection, and assigns this value to selchildcount

◆ deftexcoord0()

void gle::deftexcoord0 ( int size = 2,
int format = GL_FLOAT )
extern

Sets texcoord0 with the given dimensionality and type.

Parameters
sizethe number of dimensions to use
theGL format of the dimensions

◆ detachentity()

void detachentity ( extentity & e)
extern

Attempts to dettach the given entity.

Attempts to detach the entity from any entity it may be attached to. Fails silently if the entity is not attached.

Parameters
ethe extentity to attempt to de-link

◆ disablepolygonoffset()

void disablepolygonoffset ( GLenum type)
extern

Disables GL offset mode for overlay drawing.

Also disables the GL mode passed to type.

Parameters
typethe GL mode to glDisable()

◆ disablezoom()

void disablezoom ( )
extern

Unsets any zoom progress and disables zooming.

Sets the zoom variable to 0 (disabled) and removes any zoom progress that may be occuring.

◆ drawminimap()

void drawminimap ( int yaw,
int pitch,
vec loc,
const cubeworld & world,
int scalefactor = 1 )
extern

Draws a minimap texture.

Draws a minimap buffer at the specified orientation and location on the map. Does not render it to the screen, instead rendering it to the minimaptex buffer.

Parameters
yawthe yaw angle to draw the texture at
pitchthe pitch angle to draw the texture at
locthe location about which to draw the texture
cubeworldthe world to draw
scalefactorthe texture zoom factor

◆ dropenttofloor()

void dropenttofloor ( entity * e)
extern

Drops the map entity to a set distance above the floor.

Drops the entity passed such that it is 4 cube units above the floor, unless the map entity is of the type "particles", whereupon it is dropped to be at the same height as the floor.

Parameters
ethe entity to drop towards the floor.

◆ edittexcube()

void edittexcube ( cube & c,
int tex,
int orient,
bool & findrep )
extern

Changes the texture for a cube and its children.

The integer indices for the orient parameter are indicated below.

+z
| /+x
| /
|/___+y
______
/. /|
/ . 5 / |
/__.__/ |
| ...|3./
| .0 | /
|. |/
.-----/
______
/| .|
/ | 1. |
/..|... |
|2 |-----/
| / . /
|/ 4./
.-----/
Parameters
cthe cube to modify
texthe texture slot to apply
orientthe face of the cube to apply to; -1 indicates all faces
findreptoggles whether to find the existing texture

◆ enablepolygonoffset()

void enablepolygonoffset ( GLenum type)
extern

Enables GL offset mode for overlay drawing.

Controlled by polygonoffsetfactor/polygonoffsetunits variables; negative values will overlay in depth so there is no z fighting. Enables the GL mode passed to type.

Parameters
typethe GL mode to glEnable()

◆ enginebuilddate()

std::string enginebuilddate ( )
extern

Returns the engine library's build date.

Returns the value of DATE macro at the time the engine was built; this value is in the format MMM DD YYYY (e.g. Jan 01 1970). The purpose of the function is to quickly disambiguate how old a (development) build of the engine is.

Returns
a std::string corresponding to the engine's build date

◆ enginestr()

std::string enginestr ( )
extern

Returns the engine library's name string.

Returns the version string for the engine library, which is a compiled-in constant inside the engine library. The purpose of the function is to quickly disambiguate different versions of the library.

Returns
a std::string corresponding to the engine's name string

◆ entcancel()

void entcancel ( )
extern

Cancels selection of selected entities.

Clears the selection of any entities in edit mode. Has no effect if no entities are selected.

◆ entinmap()

bool entinmap ( dynent * d,
bool avoidplayers = false )
extern

Brute force but effective way to find a free spawn spot in the map.

Attemps to place a dynent onto the map.

Parameters
dthe dynent to place onto the map
avoidplayerstoggles whether this dynent should be spawned on top of others

◆ fatal()

void fatal ( const char * s,
... )
extern

Immediately shuts down the game and prints error message(s)

Shuts down SDL and closes the game immediately. Up to two error messages are printed in a SDL message box after exiting the game.

Parameters
sa series of C strings corresponding to error messages

◆ findmaterial()

int findmaterial ( const char * name)
extern

Returns the bitmask for the given material name.

Given a material name (water, clip, noclip, etc.), returns the bitmask value the material is associated with in the octree world.

Parameters
namea C string with the name of the material to look up
Returns
an integer corresponding to the bitmask value of the material

◆ flushpreloadedmodels()

void flushpreloadedmodels ( bool msg = true)
extern

Clears the loaded model cache.

Parameters
msgtoggles rendering a loading progress meter

◆ freeblock()

void freeblock ( block3 * b,
bool alloced = true )
extern

Deletes dynamically allocated cubes to a block entity.

Deletes the cube octree associated with the block3 object. If alloced is true, also deletes the block3 object itself.

Parameters
ba pointer to the block to free
allocedif true, deletes the block itself

◆ freeeditinfo()

void freeeditinfo ( editinfo *& e)
extern

Safely frees an editinfo object.

Deletes an editinfo object, including its position in the editinfos vector.

Parameters
ethe editinfo object to destroy.

◆ freeocta()

void freeocta ( std::array< cube, 8 > *& c)
extern

Deletes a cube and its children.

Recursively deletes child members of the cube passed, then deletes the cube itself. The node allocation counter is also decreased to correspond to the removed cubes.

Parameters
cthe cube object to be deleted

◆ freeundo()

void freeundo ( undoblock * u)
extern

Deletes an undoblock object.

Destroys an undoblock and frees its memory allocation. The pointer passed will become invalid.

Parameters
uthe undoblock to destroy.

◆ getclockmillis()

void int getclockmillis ( )
extern

Returns the number of milliseconds since the game started.

Uses SDL to retrieve the amount of time since the game started.

◆ getcursorpos()

void UI::getcursorpos ( float & x,
float & y )

Queries current UI cursor location.

Returns to the parameters passed by reference the location of the UI cursor. This location ranges from 0 to 1.f in x and y, with 0,0 being the bottom left part of the screen, and 0.5 0.5 being the middle of the screen. The x and y parameters do not scale by aspect ratio, and 1,1 is always the top right corner of the screen

Parameters
xvariable to assign x-coordinate of the cursor's location to
yvariable to assign y-coordinate of the cursor's location to

◆ getdecalslotdepth()

float getdecalslotdepth ( const DecalSlot & s)
extern

Gets the depth of a decal slot.

Returns the depth value for a decal slot. The depth value determines the distance between a decal and a piece of geometry where the decal will still render.

Parameters
sthe decalslot to query
Returns
a floating point value indicating the slot's depth

◆ getentname()

const char * getentname ( int i)
extern

Returns the entity name of of a given entity type index.

For the given entity type index (light, model, etc.) returns the human readable name of the entity type. Returns an empty string if index out of bounds.

Returns
a C string corresponding to the ent type's name

◆ getlogfile()

FILE * getlogfile ( )

Returns the logfile (Linux) or stdout (Windows)

the file where the

Log files are not supported on Windows, so this function returns stdout if on Windows.

◆ getmaterial()

ushort getmaterial ( cube & c)
extern

Returns the material bitmask for the given cube.

Returns the bitmask for the cube passed, which corresponds to the sum of all materials occupying the cube. Every sum is unique due to the basis selection, and therefore any combination of materials can be represented in the output. Returns 0 (air) if there is no valid material that describes the entire cube.

Returns
An unsigned short integer corresponding to the material bitmask

◆ gl_checkextensions()

void gl_checkextensions ( )
extern

Ensures computer environment can run the engine.

This function checks for the OpenGL contexts, GLSL version information, and other graphics capabilities required to run the engine. This function will call fatal() and exit the game if any of its conditions are not met.

◆ gl_drawframe()

void gl_drawframe ( int crosshairindex,
void(* gamefxn )(),
void(* hudfxn )(),
void(* editfxn )(),
void(* hud2d )() )
extern

Draws the frame to the screen.

Parameters
crosshairindexthe crosshair to render at the center of the screen
gamefxnthe game interface rendering function
hudfxnthe 3d HUD rendering function
editfxnthe game's edit rendering function
hud2dthe game's HUD rendering function

◆ gl_init()

void gl_init ( )
extern

Sets up GL global parameters for the game.

This function sets up the global variables which allow for the appropriate operation of the renderer, and sets up the basic shaders required.

◆ gl_resize()

void gl_resize ( )
extern

Changes the viewport size to set values.

This function sets the size of the viewport to the dimensions defined in hudw and hudh. It also calls gl_setupframe().

◆ gl_setupframe()

void gl_setupframe ( bool force = false)
extern

Sets render frame variables up.

Sets renderw/h and hudw/h to the screen size, then sets up deferred buffers if force is true.

◆ hascursor()

bool UI::hascursor ( )

Queries UI windows' cursor input ability.

Returns whether the UI system is accepting cursor input; if any windows in the UI system accept cursor input, returns True.

Returns
true if any UI window is accepting cursor input
false if no windows exist that accept cursor input

◆ haveselent()

bool haveselent ( )
extern

Queries whether the current selection has entities selected.

Returns
true if there are entities selected
false if no entities selected

◆ hideui()

bool UI::hideui ( const char * name)

Hides an open UI window with the specified name.

If the specified window is not shown or does not exist, no action is taken, Otherwise, hides the open window specified

Parameters
namethe name of the UI window to show
Returns
true if the window was hidden
false if the window was not previously shown or did not exist

◆ holdui()

void UI::holdui ( const char * name,
bool on )

Opens or closes the specified UI.

Opens the specified UI if on is true and closes it if on is false; calls either showui() or hideui().

Parameters
namethe name of the window to hold
onwhether to open or close the specified UI window

◆ ignoremousemotion()

void ignoremousemotion ( )
extern

Flushes all queued mouse events.

For all SDL_MOUSEMOTION events currently queued in SDL's event queue, this function dumps them one by one while doing nothing. This is used to clear any mouse events which may happen while the game is starting up, to ensure the cursor spawns in the middle of the screen.

◆ initaacmds()

void initaacmds ( )
extern

Initializes AA cubescript commands.


getsmaaproperty int index

  • Returns the selected SMAA property (int)
  • List of types for the type parameter:
    0. T2X
    1. S2X
    2. X4
    3. SMAA
    4. Spatial
    5. Quality
    6. ColorEdge
    7. GreenLuma
    8. DepthMask
    9. Stencil
    10. Debug


setsmaaproperty int index int value

  • Sets the selected SMAA property (int)
  • If a value out of bounds is specified, value will be modified to remain in range.
  • List of types for the index parameter:
    0. T2X
    1. S2X
    2. X4
    3. SMAA
    4. Spatial
    5. Quality
    6. ColorEdge
    7. GreenLuma
    8. DepthMask
    9. Stencil
    10. Debug

◆ initconsolecmds()

void initconsolecmds ( )
extern

Initializes console cubescript commands.

fullconsole

toggleconsole

conskip

miniconskip

clearconsole

keymap

bind

specbind

editbind

getbind

getspecbind

geteditbind

searchbinds

searchspecbinds

searcheditbinds

clearbinds

clearspecbinds

cleareditbinds

clearallbinds

inputcommand

saycommand

history

onrelease

complete

listcomplete

◆ initcontrolcmds()

void initcontrolcmds ( )
extern

Adds program control commands to the cubescript interpreter.

exec string file int msg

escape string str

unescape string str

writecfg

changedvars

doargs

if

?

pushif

do

append

result tagval v

  • Sets the passed tagval as a the command result.
  • If a string literal is passed, the command result is a tagval with that string as its stored value
  • Attempting to get a float/int from a string literal returns 0.0 and 0 respectively

listlen string list

  • Returns the length of the list given
  • List length is not zero indexed, empty lists are the only length 0 list

at string list int index

  • Returns the value at index position in list
  • List elements are zero-indexed

sublist

  • Returns a count length subset of the list given
  • If no count is given then all elements fromskip to the end of the list are returned
  • If no skip is given then all elements will be returned
  • Negative skip and count values are treated as zero

listcount ident id string list expression condition

  • Counts the number of elements in the list that satisfy the given condition
  • id is set to the value of each list element before running the condition
  • empty list returns zero

listfind ident id string list expression condition

  • Returns the index of the first element in list that satisfies the given condition
  • Returned indices are zero-indexed
  • id is set to the value of each list element before running the condition
  • If no element found, returns -1

listfind=

loop ident id int num expression body

  • Executes body num times with id set from 0 to num-1
  • id will become an int regardless of prior type
  • id retains its value set at the last loop iteration

loop+ ident id int offset int num expression body

  • Executes body num times with id set from offset to offset+num-1
  • id will become an int regardless of prior type
  • id retains its value set at hte last loop iteration

loop* *ident* id *int* step *int* num *expression* body

  • Executes body

numtimes withidset from 0 to (num-1)*step

  • If

stepis zero,idis zero for all iterations (num` iterations)

loop+**ident* id int step int num expression body

  • Executes body num times with id set from offset to (offset+num-1)*step
  • If step is zero, id is offset for all iterations (num iterations)

loopconcat ident id int num expression body

  • Executes body num times with id set from 0 to num-1
  • Returns a list string containing the returns from the expression body
  • Returns values from the body expression are delimited by single spaces
  • id will become an int regardless of prior type
  • id retains its value set at hte last loop iteration

loopconcat+ ident id int offset int num expression body

  • Executes body num times with id set from offset to offset+num-1
  • Returns values from the body expression are delimited by single spaces

looplist

looplist2

looplist3

listassoc=

looplistconcat

looplistconcatword

prettylist string list string conjunction

  • Returns the list formatted with appropriate grammar for an English sentence
  • If there are three or more list elements, or if no conjunction provided, returns a comma-delimited representation
  • If there is exactly two list elements, and a conjunction argument provided, returns list delimited only by conjunction
  • If there is only one list element, no delimiters or conjunctions will be added
  • If there is three or more elements and a conjunction, returns a comma-delimited list with the last element preceded by the conjunction

indexof string list string elem

  • Returns the first index where elem is found within list
  • All comparisons are done by string equality
  • If nothing in list compares equal to elem, returns -1

listdel string list string elems

  • Returns the list passed with all elements in elems removed from it
  • All comparisons done by string equality

listintersect string list string elems

  • Returns the set intersection of list and elems (both space-delimited strings)
  • All elements both in list and elems are included in the return set
  • The return set is strictly a subset of both list and elems
  • The return set is ordered in the same order as list
  • Duplicate entries in list are preserved in the output set, if such a value is also in elems
  • Duplicate entries in elems are never preserved in the output set

listunion string list string elems

  • Returns the set union of list and elems (both space-delimited strings)
  • All elements in list are in the return set
  • Elements in elems that are not in list are appended (up to one per unique entry)
  • Duplicate entries in list are preserved in the output set
  • Duplicate entries in elems are not preserved in the output set

loopfiles

listsplice string list string list2 int skip int count

  • Splices list2 into list1, optionally overwriting up to count elements with spliced-in list
  • List splicing begins after skip number of elements (starting from zero)

findfile

sortlist string list ident lesser ident greater expression comparison expression unique

  • Sorts the given list (space delimited string) given the provided idents and comparison expression
  • If a unique expression is provided, removes all but one value that compares equal for each unique list element
  • Comparison expression and unique expression take the lesser and greater parameters to evaluate
  • For example, sortlist $list lesser greater [<s $lesser $greater] will sort in ascending order
  • An expression that asserts$greater<$lesser` can be used to sort in reverse (descending) order

uniquelist string list ident arg1 ident arg2 expression unique

  • Removes all redundent list elements that compare equal under the unique expression
  • Unique expression takes arg1 and arg2 and returns if they compare equal
  • For example `uniquelist $list a b [=s $a $b] will compare a list of strings for strcmp equality

getmillis

sleep

clearsleep

◆ initcscmds()

void initcscmds ( )
extern

Initializes core cubescript commands.

defvar

defvarp

deffvarp

defsvar

defsvarp

getvarmin

getfvarmin

getfvarmax

identexists

getalias

nodebug

push

alias

resetvar

◆ initheightmapcmds()

void initheightmapcmds ( )
extern

Initializes heightmap Cubescript commands.

hmapcancel

hmapselect

clearhbrush

hbrushvert

◆ inithudcmds()

void inithudcmds ( )
extern

Initializes HUD cubescript commands.

loadcrosshair string file int index

  • Loads the crosshair file at the specified location into the crosshair manager at the specified index.
    • file the file where the crosshair image is located
    • index the index to alias the crosshair to

getcrosshair int index

  • Returns the path to the crosshair aliased by index.
    • index the crosshair index to query

◆ initmathcmds()

void initmathcmds ( )
extern

Adds math commands to the cubescript interpreter.

+ +f

  • returns the sum of the passed (int, float) parameters

* *f

  • returns the product of the passed (int, float) parameters

- -f

  • returns the first (int, float) minus the remaining parameters
  • if only one parameter is given, returns the unary negative of that value

= =f =s

  • returns whether the (int, float, string) compares equal

!= !=f !=f

  • returns whether the (int, float, string) compares not equal
  • equality for strings is determined by std::strncmp()

< <f <s

  • returns whether the (int, float, string) parameters are ordered in strictly ascending order
  • order for strings is determined by std::strncmp()

> >f >s

  • returns whether the (int, float, string) parameters are ordered in strictly descending order
  • order for strings is determined by std::strncmp()

<= <=f <=s

  • returns whether the (int, float, string) parameters are ordered in non-descending order
  • order for strings is determined by std::strncmp()

>= >=f >=s

  • returns whether the (int, float, string) parameters are ordered in non-ascending order
  • order for strings is determined by std::strncmp()

! tagval val

  • returns whether the tagval passed evaluates to true (1)
  • all nonzero floats and int values return true
  • all nonnull strings return true
  • null strings, and 0.f/0 return false

&& (variadic) expression arg1, expression arg2...

  • returns the logical AND of the collection of expressions passed
  • AND condition applies to only expressions actually existing (no implied false parameters)
  • if no parameters passed returns 1
  • if one parameter returns the truthiness of that expression
  • if multiple parameters passed returns 1 only if all expressions evaluate true
  • returns false for all other cases

|| (variadic) expression arg1, expression arg2...

  • returns the logical OR of the collection of expressions passed
  • OR condition returns 1 if any expression passed evaluates true
  • OR condition returns false if no parameters passed

div divf

mod modf

pow

sin float angle

  • returns the sine of the value passed
  • takes values denominated in degrees

cos float angle

  • returns the cosine of the value passed
  • takes values denominated in degrees

tan float angle

  • returns the tangent (sine divided by cosine) of the value passed
  • takes values denominated in degrees

asin float ratio

  • returns the arcsine of the value passed
  • returns values denominated in degrees

acos float ratio

  • returns the arccosine of the value passed
  • returns values denominated in degrees

atan float ratio

  • returns the arctangent of the value passed
  • returns values denominated in degrees

atan2 float y float x

  • returns the two-parameter arctangent from the two values passed
  • equal to atan(arg1/arg2)
  • returns values denominated in degrees
  • uses Fortran (y,x) formalism

sqrt float value

  • returns the square root of the value passed

loge float value

  • returns log base e (Euler's number) of the value passed

log2 float value

  • returns log base 2 of the value passed

log10 float value

  • returns log base 10 of the value passed

exp float value

  • returns e (Euler's number) to the power passed

min minf (variadic) (int, float) arg1, (int, float) arg2...

  • returns the smallest of the list of (int, float) values passed

max maxf (variadic) (int, float) arg1, (int, float) arg2...

  • returns the largest of the list of (int, float) values passed

bitscan int value

  • returns the index of the least significant bit
  • this is one less than the GCC builtin_ffs

abs absf

  • returns the absolute value of the (int, float) passed

floor

ceil

round

cond (variadic) expression arg1, expression arg2...

  • Evaluates a series of conditions to determine an expression to evaluate and return
  • Odd parameters are conditions and even parameters are consequent expressions to potentially evaluate
  • The first odd parameter (arg1, arg3, etc) to have an expression that evaluates to 1 will have its consequent parameter executed/returned
  • Execution stops with the first valid condition met
  • The final expression is evaluated and returned regardless of antecedent clauses, if no other expression evaluated
  • cond with one or zero parameters returns 0 regardless of parameter values

case

casef

cases

rnd

rndstr

tohex int value int digits

  • Returns a string containing the hexadecimal representation of the given value
  • Number of digits of output is at least digits (more if necessary to represent value)
  • Returned is a string beginning with "0x" followed by the hex representation

strcmp

◆ initmenuscmds()

void initmenuscmds ( )
extern

Initializes menus CubeScript commands.

applychanges

pendingchanges

◆ initnormalcmds()

void initnormalcmds ( )
extern

Initializes normal.cpp cubescript commands.

smoothangle int id int angle

  • Returns id, unless id is negative or larger than the maximum number of smoothgroups.
    • id the id to query
    • the angle to set the smoothgroup at id's location

◆ initoctaeditcmds()

void initoctaeditcmds ( )
extern

Initializes the octaedit cubescript commands.

moving

entcancel

cubecancel

cancelsel

reorient

selextend

selmoved

selsave

selrestore

selswap

havesel

selchildnum

selchildmat

clearundos

delprefab

saveprefab

pasteprefab

wtr

  • Returns the number of world triangles

vtr

  • Returns the number of va triangles

wvt

  • Returns the number of world vertices

vvt

  • Returns the number of va vertices

evt

  • Returns the number of extra vertices (sky, lightsphere, box guides, materials, water, fireballs)

eva

  • Returns the number of extra va vertices (models, some buffers, stains)

octa

  • Returns the number of allocated octree nodes

va

  • Returns the number of vertex arrays

gldes

  • Returns the number of GL draw range element calls

geombatch

  • Returns the number of geometry batches

oq

  • Returns the number of occlusion queries

◆ initoctarendercmds()

void initoctarendercmds ( )
extern

Initializes octarender.cpp cubescript commands.

recalc

  • Recalculates the world geometry to merge cubes & faces where possible.

◆ initoctaworldcmds()

void initoctaworldcmds ( )
extern

Initializes octaworld Cubescript commands.

printcube prints debug information for a cube

◆ initparticles()

void initparticles ( )
extern

Loads the shaders/renderer objects to render particles.

Loads a series of particle related shader (particle, particlenotexture, particlesoft, particletext) as well as initializing particlerenderer objects as necessary to begin particle rendering.

◆ initrenderglcmds()

void initrenderglcmds ( )
extern

Initializes rendergl.cpp cubescript commands.

glext ext

  • Returns whether the given GL extension was loaded
    • ext the name of the extension to query

getcamyaw

  • Returns the current camera's yaw angle in degrees

getcampitch

  • Returns the current camera's pitch angle in degrees

getcamroll

  • Returns the current camera's roll angle in degrees

getcampos

  • Returns the current camera's world position, in the format "$x $y $z"

◆ initrenderlightscmds()

void initrenderlightscmds ( )
extern

Initializes renderlights CubeScript commands.

usepacknorm

debuglightinfo int type

  • Returns the selected type of light debug information (int)
  • 0: lightpassesused
  • 1: lightsvisible
  • 2: lightsoccluded
  • 3: lightbatchesused
  • 4: lightbatchrectsused
  • 5: lightbatchstacksused
  • If a value not specified is entered, returns -1.

getcsmproperty int type

  • Returns the selected cascaded shadow map property (float)
  • List of types for the type parameter:
    1. csmmaxsize
    2. csmnearplane
    3. csmfarplane
    4. csmcull
    5. csmsplitweight
    6. csmpradiustweak
    7. csmdepthrange
    8. csmdepthmargin
    9. csmbias
    10. csmbias2
    11. csmsplits
    12. csmshadowmap
    13. csmpolyoffset
    14. csmpolyoffset2
    15. csmpolyfactor
    16. csmpolyfactor2

setcsmproperty int type float value

  • Sets the selected cascaded shadow map property.
  • If a value out of bounds is specified, value will be modified to remain in range.
  • List of types for the type parameter:
    1. csmmaxsize
    2. csmnearplane
    3. csmfarplane
    4. csmcull
    5. csmsplitweight
    6. csmpradiustweak
    7. csmdepthrange
    8. csmdepthmargin
    9. csmbias
    10. csmbias2
    11. csmsplits
    12. csmshadowmap
    13. csmpolyoffset
    14. csmpolyoffset2
    15. csmpolyfactor
    16. csmpolyfactor2

◆ initrendermodelcmds()

void initrendermodelcmds ( )
extern

Initializes rendermodel CubeScript commands.

Commands starting with obj or md5 will only have an effect when called by files loaded by the following functions: loadmodel rendermodel loadmapmodel(int) intersectmodel preloadusedmapmodels flushpreloadedmodels abovemodel.

They define the parameters of the loaded model, and are not to be used when not loaded by the above functions. All obj/md5 functions will return a "not loading an X" error if they are called outside of these special scopes.

mapmodelreset int index

mapmodel string name

mapmodelname int index int prefix

mapmodelloaded int index

nummapmodels null

clearmodel string name

findanims string name

objcullface int cullface

objcolor float red float green float blue

objcollide bool collide

objellipsecollide bool collide

objtricollide bool collide

objspec float scale

objgloss float type

objalphatest float cutoff

objdepthoffset int offset

objglow float scale float delta float pulse

objfullbright float scale

objshader string shader

objspin float yaw float pitch float roll

objscale float scale

objtrans float x float y float z

objyaw float angle

objpitch float angle

objroll float angle

objshadow bool shadow

objalphashadow bool shadow

objbb float radius float height float eyeheight

objextendbb float x float y float z

objname

objskin string meshname string tex string masks

objtexspec string tex float scale

objtexgloss string tex int type

objtexglow string tex float percent float delta float pulse

objmeshalphatest string meshname float cutoff

objcullface string meshname int cullface

objmeshcolor string meshname float red float green float blue

objbumpmap string meshname string tex

objdecal string meshname string tex

objmeshfullbright string meshname string brightness

objmeshshader string meshname string shader

objscroll string meshname float xscroll float yscroll

objnoclip string meshname bool clip

objtricollide string meshname

objlink int parent int child string tagname float x float y float z

objload string meshname float smooth

objtag string tagname float tx float ty float tz float rx float ry float rz

objpitch string meshname

md5cullface gltfcullface int cullface

md5color gltfcolor float red float green float blue

md5collide gltfcollide bool collide

md5ellipsecollide gltfellipsecollide bool collide

md5tricollide gltftricollide bool collide

md5spec gltfspec float scale

md5gloss gltfgloss float type

md5alphatest gltfalphatest float cutoff

md5depthoffset gltfdepthoffset int offset

md5glow gltfglow float scale float delta float pulse

md5fullbright gltffullbright float scale

md5shader gltfshader string shader

md5spin gltfspin float yaw float pitch float roll

md5scale gltfscale float scale

md5trans gltftrans float x float y float z

md5yaw gltfyaw float angle

md5pitch gltfpitch float angle

md5roll gltfroll float angle

md5shadow gltfshadow bool shadow

md5alphashadow gltfalphashadow bool shadow

md5bb gltfbb float radius float height float eyeheight

md5extendbb gltfextendbb float x float y float z

md5name gltfname

md5skin gltfskin string meshname string tex string masks

md5texspec gltftexspec string tex float scale

md5texgloss gltftexgloss string tex int type

md5texglow gltftexglow string tex float percent float delta float pulse

md5meshalphatest gltfmeshalphatest string meshname float cutoff

md5meshcullface gltfmeshcullface string meshname int cullface

md5meshcolor gltfmeshcolor string meshname float red float green float blue

md5bumpmap gltfbumpmap string meshname string tex

md5decal gltfdecal string meshname string tex

md5meshfullbright gltfmeshfullbright string meshname string brightness

md5meshshader gltfmeshshader string meshname string shader

md5scroll gltfscroll string meshname float xscroll float yscroll

md5noclip gltfnoclip string meshname bool clip

md5tricollide gltftricollide string meshname string meshname

md5link gltflink int parent int child string tagname float x float y float z

md5load gltfload string meshname string skel float smooth

md5tag gltftag string tagname float tx float ty float tz float rx float ry float rz

md5pitch gltfpitch string meshname float pitchscale float pitchoffset float pitchmin float pitchmax

md5pitchtarget gltfpitchtarget string meshname string animfile int frameoffset float pitchmin float pitchmax

md5pitchcorrect gltfpitchcorrect string meshname string targetname float scale float pitchmin float pitchmax

md5hitzone gltfhitzone int hitzoneid string maskstring

md5anim gltfanim string animname string animfile float speed int priority int startoffset int endoffset

md5animpart gltfanimpart string maskstring

md5adjust gltfadjust string bonename float yaw float pitch float roll float translatex float translatey float translatez

md5rdvert gltfrdvert float x float y float z float radius

md5rdeye gltfrdeye int level

md5rdtri gltfrdtri int vertex1 int vertex2 int vertex3

md5rdjoint `gltfrdjoint int num int tri bool vertex1 bool vertex2 bool vertex3

md5rdlimitdist gltfrdlimitdist int vertex1 int vertex2 float mindist float maxdist

md5rdlimitrot gltfrdlimitrot int tri1 int tri2 float maxangle float quatx float quaty float quatz float quatw

md5rdanimjoints gltfrdanimjoints bool on

◆ initrendertextcmds()

void initrendertextcmds ( )
extern

Initializes rendertext Cubescript commands.

font

fontborder

fontoutline

fontoffset

fontscale

fonttex

fontchar

fontskip

◆ initrenderwindowcmds()

void initrenderwindowcmds ( )
extern

Initializes renderwindow Cubescript commands.

getfps bool raw

  • Returns an integer number of frames rendered per second. If raw is true, returns a float instead.

resetgl null

  • Resets the OpenGL environment, including textures, shaders, and fonts.

screenres int width int height

  • Sets the screen resolution to width by height

◆ initsdl()

bool initsdl ( )
extern

Initializes SDL functions necessary to run a game.

Initializes SDL_INIT_TIMER, SDL_INIT_VIDEO, and SDL_INIT_AUDIO.

◆ initshadercmds()

void initshadercmds ( )
extern

Initializes shader Cubescript commands.

defershader

forceshader

shader type name ps vs

  • Adds a shader to the engine's catalog.
    • type a bitmask describing the properties of the shader
    • name the name of the shader for calls from e.g. useshaderbyname
    • vs the vertex shader
    • ps the pixel shader

variantshader

setshader

isshaderdefined

setshaderparam

reuseuniformparam

clearpostfx

addpostfx

setpostfx

resetshaders

variantshader_new int string int int code

  • Defines a new variant shader
  • Allows shader manipulation commands to be used if passed to code

shader_new int string exec

  • Defines a new shader
  • Allows shader manipulation commands to be used if passed to code

shader_define string string

shader_source string vs string fs

  • Sets the paths to get vertex and fragment shaders
  • Only works within context of shader_new

shader_include_vs string

shader_include_ps string

shader_get_defines null

shader_get_includes_vs null

shader_get_includes_ps null

◆ initstains()

void initstains ( )
extern

Loads stains into the global stains array.

Sets up each entry in the stains global variable array using init() method and then preloads them.

Fails to do anything if initing is set (early game loading time).

◆ initstrcmds()

void initstrcmds ( )
extern

Adds string commands to the cubescript interpreter.

echo commandstr expression

  • echoes the parameter passed directly to the console

error commandstr expression

  • echos the parameter passed out as an error to the console

strstr string haystack string needle

  • finds the first instance of needle in the haystack string passed, returns int index, wrapper around std::strstr()

strlen string

  • returns the length of the string passed as an int

struni

unistr

strlower converts the string to lowercase

strupper converts the string to uppercase

strsplice string str string vals int skip int count

  • replaces a substring between indices skip and skip + count with the passed vals
  • if the size of vals is larger than count + 1, the resulting string will be lengthened instead of values overwritten

strreplace string str string oldval string newval string newval2

  • replaces every instance of oldval with newval
  • if newval2 parameter exists, every other oldval will be newval2 (starting with newval)

substr

stripcolors string str

  • strips any color formatting from the argument passed

appendword

concat (variadic) string param1, string param2...

  • concatenates the strings passed, without inserting spaces between arguments

concatword (variadic) string param1, string param2...

  • concatenates the strings passed, adding a space between each argument

format nicely formats the string passed

◆ inittextcmds()

void inittextcmds ( )
extern

Initializes textedit cubescript commands.

textinit

textlist

textshow

textfocus

textprev

textmode

textsave

textload

textcopy

textpaste

textmark

textselectall

textclear

textcurrentline

textexec

◆ inittexturecmds()

void inittexturecmds ( )
extern

Initializes texture Cubescript commands.

texturereset int max

  • Resets the v-slot list.
    • max the maximum number of slots to retain.

materialreset null

  • Resets the octree materials.

decalreset int max

  • Resets the decals list.
    • max the maximum number of decals to retain.

compactvslots int max

  • Removes unnecessary v-slots.
    • max the maximum number of slots to retain.

The below tex* commands all require there to be a currently selected vslot. They will silently fail otherwise.

texture string type string name int rot int xoffset int yoffset float scale

  • Loads a single texture file
    • type the type of texture file being loaded:
      • 0 diffuse
      • 1 unknown tex
      • c diffuse
      • u unknown tex
      • n normal map
      • g glow map
      • s specular map
      • z depth map
      • a alpha map
    • name the path to the texture files
    • rot the rotation value of the texture (see texrotate)
    • xoffset the x-offset of the texture (see texoffset)
    • yoffset the y-offset of the texture (see texoffset)
    • scale the scale factor for the texture on the world

texgrass string name

  • Applies grass with the specified texture.

texscroll float x float y

  • Causes the texture to scroll by the amount specified in each axis

texoffset int x int y

  • Translates the texture by the specified number of pixels.

texrotate int xform

  • Transforms the texture by rotation, flipping, or transposition.
    • xform the transform code:
      • 0 no transform
      • 1 90 degrees
      • 2 180 degrees
      • 3 270 degrees CW
      • 4 flip, X axis
      • 5 flip, Y axis
      • 6 transpose
      • 7 flipped transpose

texangle float angle

  • Sets the texture's rotation angle.
    • angle the angle in degrees to rotate the texture

texalpha float front float back

  • Sets the front-side and back-side alpha intensity of the texture.
  • Both parameters will be clamped from 0 to 1.
    • front the opacity of a texture viewed from the front
    • back the opacity of a texture viewed from the back

texcolor float red float green float blue

  • Sets the alpha properties of the material.
  • All three parameters will be clamped from 0 to 2.
    • red the intensity of the red channel
    • green the intensity of the green channel
    • blue the intensity of the blue channel

texrefract float k float red float green float blue

  • Sets the refractive properties of the texture (alpha mat only)
  • All four parameters will be clamped from 0 to 1.
    • k the refractive index
    • red the intensity of the red channel
    • green the intensity of the green channel
    • blue the intensity of the blue channel

texsmooth int id bool angle

  • Sets the lerp smooth angle for the texture.
    • id the id of the smoothgroup
    • angle the angle to lerp at

decaldepth float depth float fade

  • Attempts to set the decal depth of the current decal. Silently fails to do anything if this is not possible.
    • depth the depth to set the decal
    • fade the fade intensity of the decal

reloadtex string name

  • Attempts to reload the texture with the given name. Prints an error message if this is not successful.

screenshot string filename

  • Prints a PNG screenshot to the file name indicated. If no file is specified, an automatically generated one is created.

◆ inituicmds()

void UI::inituicmds ( )

Binds the UI commands to the command parser.

Places into the CubeScript interpreter a series of UI commands, required before it is possible to use CubeScript to create UI elements.

Commands defined:

showui

hideui

hidetopui

hideallui

toggleui

holdui

uivisiblecmd

uiname

uihover

uihover?

uihover+

uihover+?

uipress

uipress?

uipress+

uipress+?

uihold

uihold?

uihold+

uihold+?

uirelease

uirelease?

uirelease+

uirelease+?

uialthold

uialthold?

uialthold+

uialthold+?

uialtpress

uialtpress?

uialtpress+

uialtpress+?

uialtrelease

uialtrelease?

uialtrelease+

uialtrelease+?

uieschold

uieschold?

uieschold+

uieschold+?

uiescpress

uiescpress?

uiescpress+

uiescpress+?

uiescrelease

uiescrelease?

uiescrelease+

uiescrelease+?

uiscrollup

uiscrollup?

uiscrollup+

uiscrollup+?

uiscrolldown

uiscrolldown?

uiscrolldown+

uiscrolldown+?

uifocus

uifocus?

uifocus+

uifocus+?

uialign

uialign-

uialign*

uiclamp

uiclamp-

uiclamp*

uigroup

uihlist

uivlist

uilist

uigrid

uitableheader

uitablerow

uitable

uispace

uioffset

uifill

uitarget

uiclip

uiscroll

uihscrolloffset

uivscrolloffset

uihscrollbar

uivscrollbar

uiscrollarrow

uiscrollbutton

uihslider

uivslider

uisliderarrow

uisliderbutton

uicolor

uimodcolor

uivgradient

uimodvgradient

uihgradient

uimodhgradient

uioutline

uiline

uitriangle

uitriangleoutline

uimodtriangle

uicircle

uicircleoutline

uimodcircle

uicolortext

uitext

uitextfill

uiwrapcolortext

uiwraptext

uicolorcontext

uicontext

uicontextfill

uiwrapcolorcontext

uiwrapcontext

uitexteditor

uifont

uiabovehud

uiconsole

uifield

uikeyfield

uiimage

uistretchedimage

uicroppedimage

uiborderedimage

uitiledimage

uimodelpreview

uiprefabpreview

uislotview

uivslotview

uicontextscale

newui

uiallowinput

uieschide

◆ initworldiocmds()

void initworldiocmds ( )
extern

Initializes worldio Cubescript commands.

mapcfgname

  • Returns the current map configuration file path.

mapversion

  • Returns the current map version.

◆ insideworld()

bool insideworld ( const vec & o)
extern

Queries whether the given vector lies inside the octree world.

Returns truth value for whether the vector given has coordinates which lie within the space occupied by the worldroot cube. If the dimension passed is exactly equal to a boundary, the function returns true (this is considered as being inside the world).

Returns
true if the vector is inside the world boundaries
false if the vector is outside the world

◆ intersectmodel()

int intersectmodel ( std::string_view mdl,
int anim,
const vec & pos,
float yaw,
float pitch,
float roll,
const vec & o,
const vec & ray,
float & dist,
dynent * d = nullptr,
modelattach * a = nullptr,
int basetime = 0,
int basetime2 = 0,
float size = 1 )
extern

Returns the intersection status of a model.

Parameters
mdlname of the model to load
animanimation status (Anim_ enum)
posposition of the model
yawyaw of the model
pitchpitch of the model
rollroll of the model
oorigin of intersecting ray
raydirection of intersecting ray
distlength of the ray
ddynent associated with this model
aarray of modelattach objects
basetimeanimation basetime
basetime2if Anim_SetSpeed, speed factor
sizescale factor of model

◆ isheightmap()

bool isheightmap ( int o,
bool empty,
const cube & c )
extern

Determines if a heightmap is active for the current selection.

Returns
true if there is a heightmap active
false if no heightmap is active

◆ iterdynents()

dynent * iterdynents ( int i)
extern

Returns the dynent at index i.

Returns a pointer to the dynent object stored at index i of the dynents vector. Returns nullptr if index i is out of bounds.

Parameters
ithe index to get the dynent at
Returns
a pointer to the dynent object at index i

◆ keyrepeat()

void keyrepeat ( bool on,
int mask = ~0 )
extern

Sets the key repeat mask for SDL.

If on is true, sets keyrepeatmask to the OR of the existing mask and the passed mask; if on is false, sets keyrepeat mask to the AND of the existing mask and the inverse of the passed mask.

The keyrepeat enum is defined in consts.h with the appropriate masks to pass.

Parameters
onthe mode for the mask to be combined
maskthe bitmask to apply

◆ limitfps()

void limitfps ( int & millis,
int curmillis )
extern

delays a frame by a specified amount

Delays rendering of a frame.

Uses SDL_Delay to delay a frame, given the time the last frame was rendered and the current time. Takes into account the global fps cap global variable (maxfps) to calculate delay.

Parameters
millisthe time (in ms) since program started
curmillisthe last registered frame time

Uses SDL_Delay to delay a frame, given the time the last frame was rendered and the current time. The amount of delay is calculated from the global maxfps and menufps variables.

Parameters
millisthe time (in ms) since program started
curmillisthe last registered frame time

◆ linkedpush()

void linkedpush ( cube & c,
int d,
int x,
int y,
int dc,
int dir )
extern

Pushes cubes linked with the passed cube.

Parameters
cthe cube to push
ddimension of the selection's orient
xselection bounds x
yselection bounds y
dcdimension coordinate of the selection's orient
dirdirection to push

◆ loadmapmodel()

model * loadmapmodel ( int n)
extern

Loads the mapmodel assigned to the specified index.

Loads the mapmodel assigned to the specified model index into a model object. If a model object already exists, a new model is not created and a pointer to that model is returned instead; otherwise, returns a pointer to the new model object. If the index is out of bounds, nullptr is returned.

Returns
a pointer to the model object

◆ loadmodel()

model * loadmodel ( const char * name,
int i = -1,
bool msg = false )
extern

Loads the model with the associated name.

Parameters
namethe name of the model to load
ithe number of models to search through before giving up
msgtoggles rendering a loading progress meter while loading the model

◆ loadshaders()

void loadshaders ( )
extern

Loads a series of shaders hardcoded into the engine.

The shaders loaded are:

null

hud

hudtext

hudnotexture

stdworld

nocolor

fogged

foggednotexture

ldr

ldrnotexture

If the shaders null...stdworld are not found, the engine exits by calling fatal. setupshaders creates these textures and adds them to the shader global hashtable.

◆ logoutf()

void logoutf ( const char * fmt,
... )

Prints a line to the log file.

This function behaves the same way as printf(), except it prints to the output specified in getlogfile().

Parameters
fmtThe string to print
...the names of variables to substitute into the string, in order

◆ makeundo() [1/2]

void makeundo ( )
extern

Adds an undo entry to the undos vector given the current selection.

Uses the current global selection to add a new undo object to the global undos vector.

◆ makeundo() [2/2]

void makeundo ( selinfo & s)
extern

Adds an undo entry to the undos vector given the passed selection.

Uses the passed selection to add a new undo object to the global undos vector.

Parameters
theselection to use

◆ mapmodelname()

const char * mapmodelname ( int i)
extern

Returns the mapmodel name at the given index.

If the passed index corresponds to a valid mapmodel, the function returns a C string with its name; if not, the function returns a nullptr.

Returns
a C string with the name of the model

◆ movecursor()

bool UI::movecursor ( int dx,
int dy )

Moves the UI cursor by the amount perscribed.

Moves the UI cursor by the amount described (positive or negative), scaled by the UI sensitivity variable. Values are capped in both dimensions between 0 and 1, thereby preventing the cursor from completely leaving the screen.

Parameters
dxamount to move the cursor in the x direction
dyamount to move the cursor in the y direction

◆ moveragdoll()

void moveragdoll ( dynent * d)
extern

Update a ragdoll's position and physics.

If the dynent pointed to does not have a valid ragdoll object as a member, nothing happens.

Parameters
da dynent pointer.

◆ multiplayerwarn()

void multiplayerwarn ( )
extern

Prints a warning message to the console.

This function prints a message warning the user that the operation is not possible in multiplayer. It does nothing else.

◆ newundocube()

undoblock * newundocube ( const selinfo & s)
extern

Creates an undoblock object given a cube selection.

Parameters
sthe selection information to give to the undoblock object
Returns
a pointer to a new heap-allocated undoblock object

◆ packvslot() [1/2]

void packvslot ( std::vector< uchar > & buf,
const VSlot * vs )
extern

Packs into the passed char vector the contents of a VSlot.

Parameters
bufthe vector to pack information into
vsa pointer to the slot to pack

◆ packvslot() [2/2]

void packvslot ( std::vector< uchar > & buf,
int index )
extern

Packs into the passed char vector the contents of a VSlot.

Parameters
bufthe vector to pack information into
indexthe index in the vslot list to pack

◆ pasteblock()

void pasteblock ( const block3 & b,
selinfo & sel,
bool local )
extern

Pastes the block3 passed to the volume in the selinfo object.

Parameters
bthe block3 to paste
selthe selection to paste into
localwhether the command was local

◆ pastecube()

void pastecube ( const cube & src,
cube & dst )
extern

Copies and pastes a single cube (with its children).

Copies the cube located at src, along with its child cubes, and pastes it into the cube node located at dst. If the dst cube is of a smaller grid size than the source cube, the extra child levels are truncated.

Parameters
srca reference to the source cube to copy
dsta reference to the destination cube where the selection is pasted

◆ pasteundoblock()

void pasteundoblock ( block3 * b,
const uchar * g )
extern

Pastes an undo block associated with the passed block3 object.

Parameters
bthe block3 to use to paste
gthe gridscale array to pass

◆ pointinsel()

bool pointinsel ( const selinfo & sel,
const vec & o )
extern

Determines whether selection contains location at specified location.

Returns whether the location of the vector passed falls within the selection information object's volume. If the passed vector is exactly along the boundary, the function still returns true.

Parameters
selselinfo object corresponding to a world volume
originvector corresponding to a world location
Returns
true if the vector is inside the selinfo object
false if the vector is outside the selinfo object

◆ preloadmodel()

void preloadmodel ( std::string name)
extern

Adds a model to the cache of models to load.

When flushpreloadedmodels() is called, the entries added to the preloadedmodels vector by this function are loaded. Silently fails and does nothing if the model name passed is not valid or already exists in the vector.

◆ preloadusedmapmodels()

void preloadusedmapmodels ( bool msg = false,
bool bih = false )
extern

Preloads mapmodels corresponding to the world's mapmodel entities.

Parameters
msgtoggles printing warning messages
bihtoggles preloading the bounding interval hierarchy (BIH) for the model

◆ raycubepos()

float raycubepos ( const vec & o,
const vec & ray,
vec & hit,
float radius = 0,
int mode = Ray_ClipMat,
int size = 0 )
extern

Returns the distance before a ray hits a cube.

This function behaves the same as raycube() execept also returning the location where the hit happened.

Parameters
othe starting location of the ray to be drawn
raynormalized direction vector for the ray to point
hitoutput parameter for the vector location the hit happened at
radiusregion around ray that counts as a hit
modeflags which determine what counts as a hit
sizesize of cube which registers a hit
tentity to check against

◆ recalcdir()

void recalcdir ( const physent * d,
const vec & oldvel,
vec & dir )
extern

Recalculates dir based on the provided physent, normalized to oldvel.

The magnitude of the dir vec passed in is used to multiply the output by (magnitude of oldvel)/(magnitude of dir). The direction of the output is not determined by the input; this is equal to the physnent's vel and falling fields added together.

Parameters
dthe physent to use the fall velocity of
oldvelthe velocity to use the magnitude of to scale
[in,out]dirthe dynent's direction scaled to the oldvel and input dir

◆ regular_particle_flame()

void regular_particle_flame ( int type,
const vec & p,
float radius,
float height,
int color,
int density = 3,
float scale = 2.0f,
float speed = 200.0f,
float fade = 600.0f,
int gravity = -15 )
extern

Spawns a flame particle.

Parameters
typethe type of particle to spawn
plocation to spawn at
radiusspawning radius of the particle
colorthe color of the particle (web hex color)
densitythe density of particle spawns
scalethe scale factor for the particle
speedinitial speed of particles after spawning
fadetime in ms before the particle fades
gravitygravity factor for particles after spawning

◆ regular_particle_splash()

void regular_particle_splash ( int type,
int num,
int fade,
const vec & p,
int color = 0xFFFFFF,
float size = 1.0f,
int radius = 150,
int gravity = 2,
int delay = 0 )
extern

Spawns a splash particle with the designated properties.

dir: (where dir%3 is similar to offsetvec with 0=up)
0..2 circle
3.. 5 cylinder shell
6..11 cone shell
12..14 plane volume
15..20 line volume, i.e. wall
21 sphere
24..26 flat plane
+32 to inverse direction
Parameters
typethe type of particle to spawn
numthe number indicating the spawning direction/pattern
fadethe number of ms before the particle fades
pthe location for the particle
colorthe color of the particle (web hex color)
sizethe size factor for the particle
radiusthe spawn area radius for the particle
gravitythe gravity factor for particles after spawning
delaythe delay in milliseconds between particle spawns

◆ rendermodel()

void rendermodel ( std::string_view mdl,
int anim,
const vec & o,
float yaw = 0,
float pitch = 0,
float roll = 0,
int cull = Model_CullVFC|Model_CullDist|Model_CullOccluded,
dynent * d = nullptr,
modelattach * a = nullptr,
int basetime = 0,
int basetime2 = 0,
float size = 1,
const vec4< float > & color = vec4< float >(1, 1, 1, 1) )
extern

Renders a world model.

This function renders a model inside the world, given the following parameters. If the model is not found, the function fails silently.

Parameters
mdlname of the model to load
animindex of the animation to use
olocation of the model
yawyaw orientation
pitchpitch orientation
rollroll orientation
cullocclusion culling flags
ddynent to associate model with
aattached models to load
basetimeanimation interpolation factor
basetime2animation interpolation factor
sizescale factor for model
colorrgba color of the model

◆ renderprogress()

void renderprogress ( float bar,
const char * text,
bool background = false )
extern

Renders a loading progress bar at the bottom center of the window.

Intended for indicating asset loading or similar technical holding of the game state.

Parameters
barfrom 0...1, indicates how full the progress bar should be
textthe string to overlay on the progress bar
togglesrendering a background for the loading bar

◆ reorient()

void reorient ( )
extern

Reorients sel to point in the direction of orient.

See the cube faces in octa.h to interpret what the value of orient means in dimensions.

◆ resetcursor()

void UI::resetcursor ( )

Sets the cursor to the middle of the screen.

Sets the location of the UI cursor to the middle of the screen; that is, the cursor's x and y values are both set to 0.5.

◆ resetfpshistory()

void resetfpshistory ( )
extern

Sets the entirety of the fps history buffer (used for averaging the FPS readout) to 1.

Sets the fps history buffer values all to 1.

◆ resethudshader()

void resethudshader ( )
extern

Binds the HUD shader via glUseProgram()

Also sets the color of the gle system to white (1,1,1).

◆ rotatebb()

void rotatebb ( vec & center,
vec & radius,
int yaw,
int pitch,
int roll = 0 )
extern

Rotates the center and radius vectors using the given Euler angles.

Parameters
centerthe center of the bounding box
radiusthe size of the bounding box
yawthe yaw amount to modify by
pitchthe pitch amount to modify by
rollthe roll amount to modify by

◆ setfont()

bool setfont ( const char * name)
extern

Sets the currently used font.

This function sets the current font to use to the one associated with the name passed. If the function does not find the font requestion, the function returns false.

Returns
true if the font was found and changed
false if the font was not found and not changed

◆ setupscreen()

void setupscreen ( )
extern

Sets up the SDL window the application runs in.

Should only be called once in the lifetime of the program. This function opens a window onscreen that the application runs in.

◆ showui()

bool UI::showui ( const char * name)

Shows a UI window with the specified name.

If the specified window does not exist or already is shown, no action is taken. Otherwise, displays the window specified.

Parameters
namethe name of the UI to show
Returns
true if the window was shown
false if the window was hidden, or if no window exists

◆ slideagainst()

void slideagainst ( physent * d,
vec & dir,
const vec & obstacle,
bool foundfloor,
bool slidecollide )
extern

Re-projects a physent's velocity according to a given wall normal.

Parameters
dthe dynent to velocity project
dirthe direction to recalcdir() using the dynent's velocity
obstaclethe normal of the wall
foundfloortoggles whether to omit the z coordinate of the given wall normal
slidecollidetoggles whether to omit the z-coord of the given wall normal (if foundfloor==false)

◆ swapbuffers()

void swapbuffers ( bool overlay = true)
extern

Refreshes the rendered screenbuffer.

This function refreshes the display buffer. The paramater has no effect.

Parameters
overlayHas no effect.

◆ toggleui()

bool UI::toggleui ( const char * name)

Toggles the open/closed state of a window.

If the speficied window is open, closes the window; if it is closed, opens it. If the window does not exist, does nothing.

Parameters
namethe name of the window to toggle
Returns
true if the window was shown
false if the window was hidden, or if no window exists

◆ uivisible()

bool UI::uivisible ( const char * name)

Gets the open/close status of a UI window.

Returns whether the specified window is open or closed (displayed onscreen or hidden).

Returns
true if the window is open
false if the window does not exist or is closed

◆ unpackundocube()

void unpackundocube ( ucharbuf & buf,
uchar * outbuf )
extern

Unpacks a buffer containing an undo action into a unsigned char array.

This function does not preserve the original buffer.

Parameters
bufthe buffer to unpack
outbufthe buffer to unpack into.

◆ updatefpshistory()

void updatefpshistory ( int millis)
extern

Adds an entry to the fps history.

The value millis passed is added to the fps history array, at a position greater one greater than the previous entry.

Parameters
millisthe timestamp to add to the fps history

◆ vecfromyawpitch()

void vecfromyawpitch ( float yaw,
float pitch,
int move,
int strafe,
vec & m )
extern

Modifies a vector based on passed movement modifiers.

Given a vector and a series of movement parameters, the passed vector is modified by the values of move (forward and backward) and strafe (side to side). These axes are independent of the vec to be modified, and are oriented relative to the yaw and pitch parameters passed.

Parameters
yawthe angle the player is pointing
pitchthe angle at which the player is ascending
movethe quantity of forwards to backwards motion to add
strafethe quantity of side to side motion to add
mthe vector to modify

◆ vectoryawpitch()

void vectoryawpitch ( const vec & v,
float & yaw,
float & pitch )
extern

Returns 2 Euler angles for a given vector.

Given a vector v, yaw and pitch are assigned to the orientation of the vector in 3D space. Roll is not assigned, as it is ambiguous for a vector.

Parameters
vvector to be used to calc yaw & pitch
yawoutput parameter v's yaw is assigned to
pitchoutput parameter v's pitch is assigned to

Variable Documentation

◆ animnames

std::vector<std::string> animnames
extern

A list of anim names to be loaded into the engine by the game.

◆ camera1

physent* camera1
extern

Camera location for the renderer to render at

◆ detachedcamera

bool detachedcamera
extern

read only variable corresponding to camera at ent location (1p) or away from it (3p)

◆ elapsedtime

int elapsedtime
extern

last time

◆ entnames

std::vector<std::string> entnames
extern

The names of the map entities, set by the application code.

◆ fovy

float fovy
extern

Field of view in degrees in the vertical direction (normal fov is X dimension).

◆ fullscreen

int fullscreen
extern

Toggles fullscreen, behaves like bool; 0 for windowed and 1 for fullscreen.

◆ havesel

bool havesel
extern

true if there is a set of cubes in selection, false otherwise

◆ hmapedit

int hmapedit
extern

used as boolean, 0 if not heightmapping, 1 otherwise

◆ lastmillis

int lastmillis
extern

current frame time

◆ lasttex

int lasttex
extern

index for the most recently used texture

◆ logfile

FILE* logfile
extern

total elapsed time

◆ mainmenu

int mainmenu
extern

toggles if the main menu is shown, bool-like int

◆ minimized

bool minimized

Set to 1 if the window is minimized.

◆ redos

std::deque<undoblock *> redos

list of cube operations available to redo

◆ showmat

int showmat
extern

treat as bool, determines whether material outlines are rendered

◆ texpaneltimer

int texpaneltimer
extern

Sets the length before the texture scroll panel turns off.

◆ totalmillis

int totalmillis
extern

elapsed frame time

◆ undos

std::deque<undoblock *> undos
extern

list of cube undo operations