Skyline Lua API  Version 1.0
Lua Script Reference for Skyline Game Engine.
draw Class Reference

#include <LUA_API_Draw.h>

Public Member Functions

void autoClear (int state)
 Enables the update loop drawing clear routine. This is active by default. More...
 
void line (newType.vec3 lineStartV3, newType.vec3 lineEndV3, newType.color lineColour)
 Draws a simple colored line between 2 vec3 vars. More...
 
void clear ()
 Forces the drawing to be cleared. More...
 
void circle (vec3 position, float radius, float segment, color col)
 Draws a circle. More...
 
void circleFilled (vec3 position, float radius, float segment, color col)
 Draws a filled circle. More...
 
void cylinder (vec3 position, float radius, float segment, float height, color col)
 Draws a cylinder. More...
 
void cylinderFilled (vec3 position, float radius, float segment, float height, color col)
 Draws a filled cylinder. More...
 
void tetra (vec3 position, float scale, color col)
 Draws a tetra. More...
 
void tetraFilled (vec3 position, float scale, color col)
 Draws a filled tetra. More...
 
void sphere (vec3 position, float radius, float smooth, color col)
 Draws a sphere. More...
 
void sphereFilled (vec3 position, float radius, float smooth, color col)
 Draws a filled sphere. More...
 
void cube (vec3 position, float scale, color col)
 Draws a cube. More...
 
void cubeFilled (vec3 position, float scale, color col)
 Draws a filled cube. More...
 

Detailed Description

Debug drawing related functions can be found in this class. There are many times where you require some type of visual
feedback when coding.This library provides a handy set of commands to provide you with visual feedback.
Use as game.function()

posS    = newType.vec3();
posE    = newType.vec3();
col     = newType.color(1,0,0,0.5);
obj     = 0;
x,y,z   = 0;
rx      = 0;
radius  = 5;

function onInit(objID)
    sky.lprint("LUA: Demo - Debug Drawing script Active!"); 
    obj = objID;
    draw.autoClear(0); -- Stop the built in clearing on update so we can manage it ourselves
    x,y,z = entity.getPosition(obj);
    drawStack();
end
 
function onKeyDown( key )
    posS  = newType.vec3(entity.getPosition(obj));
    posE  = newType.vec3(posS.x,posS.y+20,posS.z);
    col   = newType.color(1,0,0,0.5);
    
    radius      = 10;
    segment     = 50;
    height      = 10;
    scale       = 7;

    draw.clear();   
    
    if (key == "1") then draw.circle(posS,radius,segment,col); end
    if (key == "2") then draw.circleFilled(posS,radius,segment,col); end
    if (key == "3") then draw.cylinder(posS,radius,segment,height,col); end
    if (key == "4") then draw.cylinderFilled(posS,radius,segment,height,col); end
    if (key == "5") then draw.tetra(posS,scale,col); end
    if (key == "6") then draw.tetraFilled(posS,scale,col); end
    if (key == "7") then draw.sphere(posS,radius,1,col); end
    if (key == "8") then draw.sphereFilled(posS,radius,1,col); end
    if (key == "9") then draw.cube(posS,scale,col); end
    if (key == "0") then draw.cubeFilled(posS,scale,col); end
    if (key == "b") then drawStack() end
end

function drawStack()
    for i=0,5 do
        for j=0,5 do
            for k=0,5 do
                posS.x = x - i * 10 
                posS.y = y - j * 10
                posS.z = k * 10 + z
                col.r = 51 * i / 255
                col.g = 51 * j / 255
                col.b = 51 * k / 255
                
                col.a = 0.3;
                draw.cubeFilled(posS,3,col);
                
                col.a = 0.7;
                draw.cube(posS,3,col);
            end
        end
    end 
end

Note: To create a transparent drawing such as a box for bounds you can pass a low value to the color.a variable

For more information on how these functions can be used please visit the User Manual - https://home.aurasoft-skyline.co.uk

Member Function Documentation

void draw::autoClear ( int  state)

Enables the update loop drawing clear routine. This is active by default.

Parameters
intthe arg int state can be either 1 or 0

There may be times when you require the drawn objects to be persistant between frames. Disable this option and
manually call draw.clear before doing any drawing.
The following is a Small Example on how to use this function:

function onInit(objID)
    obj = objID;
    draw.autoClear(0); -- Stop the built in clearing on update so we can manage it ourselves
    pos = newType.vec3(entity.getPosition(obj));
end
void draw::circle ( vec3  position,
float  radius,
float  segment,
color  col 
)

Draws a circle.

Parameters
vec3vector position
floatradius of circle
floatthe segments or smoothness of curve
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.circle(posS,radius,segment,col); end
end
void draw::circleFilled ( vec3  position,
float  radius,
float  segment,
color  col 
)

Draws a filled circle.

Parameters
vec3vector position
floatradius of circle
floatthe segments or smoothness of curve
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.circleFilled(posS,radius,segment,col); end
end
void draw::clear ( )

Forces the drawing to be cleared.

Clears any drawing and must be called before calling any draw commands.
The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.circle(posS,radius,segment,col); end
end
void draw::cube ( vec3  position,
float  scale,
color  col 
)

Draws a cube.

Parameters
vec3vector position
floatscale of cylinder
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    scale       = 7;
    draw.clear();   
    if (key == "1") then draw.cube(posS,scale,col); end
end
void draw::cubeFilled ( vec3  position,
float  scale,
color  col 
)

Draws a filled cube.

Parameters
vec3vector position
floatscale of cylinder
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    scale       = 7;
    draw.clear();   
    if (key == "1") then draw.cubeFilled(posS,scale,col); end
end
void draw::cylinder ( vec3  position,
float  radius,
float  segment,
float  height,
color  col 
)

Draws a cylinder.

Parameters
vec3vector position
floatradius of cylinder
floatthe segments or smoothness of curve
floatthe height of the cylinder
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.cylinder(posS,radius,segment,height,col); end
end
void draw::cylinderFilled ( vec3  position,
float  radius,
float  segment,
float  height,
color  col 
)

Draws a filled cylinder.

Parameters
vec3vector position
floatradius of cylinder
floatthe segments or smoothness of curve
floatthe height of the cylinder
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.cylinderFilled(posS,radius,segment,height,col); end
end
void draw::line ( newType.vec3  lineStartV3,
newType.vec3  lineEndV3,
newType.color  lineColour 
)

Draws a simple colored line between 2 vec3 vars.

Parameters
newType.vec3lineStartV3: the vec3 of the line start position
newType.vec3lineEndV3: the vec3 of the line end position
newType.colorlineColour: the color to use to draw the line

The following is a Small Example on how to use this function:

function onInit(objID)
    obj = objID;
    draw.line(lineStartV3, lineEndV3, lineColour);
    pos = newType.vec3(entity.getPosition(obj));
end
void draw::sphere ( vec3  position,
float  radius,
float  smooth,
color  col 
)

Draws a sphere.

Parameters
vec3vector position
floatradius of cylinder
floatthe smooth value or smoothness of curve
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    smooth      = 1;
    draw.clear();   
    if (key == "1") then draw.sphere(posS,radius,smooth,col); end
end
void draw::sphereFilled ( vec3  position,
float  radius,
float  smooth,
color  col 
)

Draws a filled sphere.

Parameters
vec3vector position
floatradius of cylinder
floatthe smooth value or smoothness of curve
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    smooth      = 1;
    draw.clear();   
    if (key == "1") then draw.sphereFilled(posS,radius,smooth,col); end
end
void draw::tetra ( vec3  position,
float  scale,
color  col 
)

Draws a tetra.

Parameters
vec3vector position
floatscale of tetra
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.tetra(posS,scale,col); end
end
void draw::tetraFilled ( vec3  position,
float  scale,
color  col 
)

Draws a filled tetra.

Parameters
vec3vector position
floatscale of tetra
colora color vector for rgba value

The following is a Small Example on how to use this function:

function onKeyDown( key )
    posS        = newType.vec3(entity.getPosition(obj));
    col         = newType.color(1,0,0,0.5);
    radius      = 10;
    segment     = 50;
    draw.clear();   
    if (key == "1") then draw.tetraFilled(posS,scale,col); end
end

The documentation for this class was generated from the following file: