Share

Image and display objects

OGLRendering object

[Desktop Automation]

A render context for previews. The OGLRendering object is created with system:createoglcontext(). The rendering object itself works with:

  • models: individual meshes
  • scenes: arrangements of models

Properties

None.

Back to top

Methods

Name Syntax Description
addmodeltoscene oglcontext:addmodeltoscene(modelid:integer); Adds the model of 'modelID' to the current scene.
createmodel Modelid:integer = oglcontext:createmodel (mesh:mesh object, loadcolors: Boolean, loadtextures: Boolean, matrix: tluamatrix) Puts a mesh object into the oglrender context, returns the modelID. loadcolors: optional, default true. Flag to allow loading of vertex colors. Setting this to false allows the setting of a uniform display color using setmodelcolor(). loadtextures: optional, default true. Enable loading of vertex textures. matrix: optional, transforms the model and sets the transformed bounding box when set.
freemodel oglcontext:freemodel(modelid:integer); Removes model from scene and deletes reference
lookatmodelfromsurroundingsphere oglcontext:lookatmodelfromsurroundingsphere(modelid, eyex, eyey, eyez, upx, upy, upz, offset: float); Sets the camera position. eyexupz are vector components to describe position and orientation of the camera. Values get normalized and reduced to the necessary components, so, it is not necessary to calculate and specify a vector for up that is perfectly orthogonal to the resulting view ray from eye to the target. offset: distance to mesh object in multiples of bounding-box-enclosing sphere radii. For more information, search externally for OpenGL and eye and up vector.
render oglcontext:render(); Renders the scene
rotate oglcontext:rotate(modelid:integer, angle:float radians); Rotates the model under the camera (must be set up first with lookatmodelfromsurroundingsphere()). Positive values produce rotations that make the part surface pass in opposite direction to the Up vector of the camera.
savetobmp oglcontext:savetobmp (filename:string, threaded:Boolean); Saves current scene to BMP file as 'filename'. threaded: optional; when true, runs export in a separate thread.
savetojpeg oglcontext:savetojpeg(filename:string, quality:integer, threaded:Boolean); Saves current scene to JPEG file as 'filename'. Quality: JPEG quality, default: 90. threaded: optional; when true, runs export in a separate thread.
savetopng oglcontext:savetopng(filename:string, threaded:Boolean); Saves current scene to PNG file as 'filename'. threaded: optional; when true, runs export in a separate thread.
setbackgroundcolor oglcontext:setbackgroundcolor(r, g, b: integer 0-255); Sets background color to RGB value
setbackgroundgradient oglcontext:setbackgroundgradient(ar, ag, ab, br, bg, bb, cr, cg, cb, dr, dg, db: integer 0-255); ardb: RBG values for bottom left, bottom right, top right, and top left corner of the OGL context, respectively
setmodelcolor oglcontext:setmodelcolor(modelid:integer, r, g, b, a:float) Changes the uniform color of a model. To use this method, vertex colors must be disabled in the createmodel() call.
setmodeltextureenabled oglcontext:setmodeltextureenabled(textureenabled:Boolean) Changes the textureendabled property
setlightpos oglcontext:setlightpos(x, y, z:float, type:integer); Sets the position of lightsource, type 1 = point lightsource, otherwise unidirectional
setreflectivity oglcontext:setreflectivity (modelid: integer, reflectivity:float); Sets the reflectivity factor (e.g. 0.6) for the model
swapbuffers oglcontext:swapbuffers(); OpenGL glutswapbuffers function
removemodelfromscene oglcontext:removemodelfromscene (modelid:integer); Removes model from scene

Back to top

Image processing

[Desktop Automation]

The Lua Image Processing Interface provides functionality for simple image processing and algorithms.

Properties

None.

Back to top

Methods

Name Syntax Description
loadimage Imageobject = Ip:loadimage(file: string) Loads image from specified file and returns a Lua image object

Back to top

Image object

[Desktop Automation]

All colors are encoded as Integer 0xBBGGRR

Properties

Property Read/write Type Description
height read-only Number Height of the image
width read-only Number Width of the image

Back to top

Methods

Name Syntax Description
colortotransparent img:colortotransparent(color:number) Converts given color to transparency.
compareto img:compareto(img:object) Compares the image to another specified image pixel by pixel. The result is the percentage of likeness (50% = random image, 100% = equal image).
comparebyfiltercolor Img:comparebyfiltercolor(img:object; color:number) Compares the image to another specified image pixel by pixel. Just respect pixels with given mask color. The result is the percentage of likeness.
deltato img:deltato(img:object) Calculates the difference between the two images. Same areas are black, differences are highlighted white
detectedges img:detectedges() Detects edges of the image by the Canny algorithm. The resulting image is black with white edges one pixel wide.
gausssmoothing img:gausssmoothing(sigma:number) Performs the gausssmoothing filter with specified sigma value
colormask img:colormask(mask:object; maskcolor:color; newcolor:number) Applies a mask operation on the image where every pixel of the image is replaced by "newcolor" where the color of the "mask" image is "maskcolor"[Desktop Automation]
imagemask Img:imagemask(mask:object; maskcolor:number) Applies a mask operation on the image where every pixel of the image is replaced by mask-pixel if the input-pixel equals maskcolor.
invert img:invert() Inverts colors of the image
laplace img:laplace() Performs the Laplace edge detection filter on the image
paint img:paint(img:object) Draw an image over another image. Transparent areas in the top image will be ignored.
saveto img:saveto(file:string) Saves image to specified path and file name. Image format is determined by suffix given in the file name. Supported suffixes are "jpg" or "jpeg", bmp", and "png". Suffixes are not case-sensitive.
setcolor img:setcolor(color:number) Override the color of the entire image. Transparency will stay the same.
tograyscale img:tograyscale() Converts colored image to grayscale

Back to top

Was this information helpful?