All Functions Modules Pages
amg 3D

Functions

NIL amg.init ()
 Initializes the 3D engine. More...
 
NIL amg.quality (NUMBER quality)
 Sets the quality used to load textures. More...
 
NIL amg.begin ()
 Begins 3D rendering. More...
 
NIL amg.mode2d (NUMBER state)
 Enables/Disables the 2D mode. More...
 
NIL amg.update ()
 Refreshes the screen and draws 3D content. More...
 
NIL amg.renderstyle (NUMBER type)
 Change the 3D render mode. More...
 
NIL amg.perspective (NUMBER value)
 Sets the FOV (Field of view). More...
 
NIL amg.light (NUMBER light, NUMBER state)
 Enables/Disables 1 of the 4 available light sources. More...
 
NIL amg.poslight (NUMBER light, TABLE pos)
 Changes a light position. More...
 
NIL amg.typelight (NUMBER light, NUMBER type)
 Sets the light type. More...
 
NIL amg.colorlight (NUMBER light, COLOR diffuse, COLOR ambient, COLOR specular)
 Sets the light color. More...
 
NIL amg.spotlight (NUMBER light, TABLE pos, NUMBER spotexp, NUMBER spotcut)
 Configures a focal light (as a lighthouse): SPOTLIGHT. More...
 
NIL amg.setlightmap (STRING path)
 Changes the light map for Cel-Shading. More...
 
NIL amg.fog (NUMBER near, NUMBER far, COLOR color)
 Enables the fog. More...
 
NIL amg.fog ()
 Disables the fog. More...
 
BOOLEAN amg.raytracing (TABLE pos, TABLE vector)
 Makes a Ray Tracing test (checks for colisions between a straight line and 3D objects) More...
 
NIL amg.gravity (NUMBER x, NUMBER y, NUMBER z)
 Sets the 3D world gravity. More...
 
NIL amg.screenshot (STRING path)
 Save an image to the specified path (it should include the filename and its extension, only png). More...
 
NIL amg.finish ()
 Finishes the 3D engine. More...
 

Detailed Description

3D world properties.

Function Documentation

NIL amg.init ( )

Initializes the 3D engine.

Note
Once 3D engine has been initialized, each of the onelua's graphics functions must be called inside amg.mode2d().
Returns
Nothing.
NIL amg.quality ( NUMBER  quality)

Sets the quality used to load textures.

Parameters
qualityThe texture quality. Can one of these constants:
  • __8888 (32 bits RGBA)
  • __4444 (16 bits R4G4B4A4)
  • __5551 (16 bits R5G5B5A1)
  • __5650 (16 bits R5G5B5, no alpha channel)
Returns
Nothing.
NIL amg.begin ( )

Begins 3D rendering.

Note
You need to call this function before drawing any 3D object.
Returns
Nothing.
NIL amg.mode2d ( NUMBER  state)

Enables/Disables the 2D mode.

Parameters
statePass 1 to enable, 0 to disable.
Note
If the 2D mode is enabled you can draw images or text, but you should disable it before call screen.flip() to process images or text drawn.
Returns
Nothing.
NIL amg.update ( )

Refreshes the screen and draws 3D content.

Note
This function is equivalent to screen.flip(), but for 3D content (you should call both functions if you're mixing 2D and 3D contents).
Returns
Nothing.
NIL amg.renderstyle ( NUMBER  type)

Change the 3D render mode.

Parameters
typeOne of the following constants:
  • __POINTS (Draws only vertices as points)
  • __LINES (Draws lines between vertices)
  • __TRIANGLES (Draws faces and lighting)
Note
Default value is __TRIANGLES.
Returns
Nothing.
NIL amg.perspective ( NUMBER  value)

Sets the FOV (Field of view).

Parameters
valuePerspective FOV in degrees (75.0 by default). Must be in degrees.
Note
3D programs usually have a value of 35 by default, this is the value which seems better according to the real world.
Returns
Nothing.
NIL amg.light ( NUMBER  light,
NUMBER  state 
)

Enables/Disables 1 of the 4 available light sources.

Parameters
lightThe light to enable (any value between 1 to 4).
statePass 1 to enable, 0 to disable.
Returns
Nothing.
NIL amg.poslight ( NUMBER  light,
TABLE  pos 
)

Changes a light position.

Parameters
lightThe light to move (any value between 1 to 4).
posA table with the position values for the 3 axes (x,y,z).
Returns
Nothing.
NIL amg.typelight ( NUMBER  light,
NUMBER  type 
)

Sets the light type.

Parameters
lightThe light to edit (any value between 1 to 4).
typeThe light type, one of these constants:
  • __DIRECTIONAL (Directional lights)
  • __POINT (Pointlight lights)
  • __SPOT (Spot lights)
Returns
Nothing.
NIL amg.colorlight ( NUMBER  light,
COLOR  diffuse,
COLOR  ambient,
COLOR  specular 
)

Sets the light color.

Parameters
lightThe light to edit (any value between 1 to 4).
diffuseThe color for the diffuse component.
ambientThe color for the ambiental component.
specularThe color for the specular component.
Returns
Nothing.
NIL amg.spotlight ( NUMBER  light,
TABLE  pos,
NUMBER  spotexp,
NUMBER  spotcut 
)

Configures a focal light (as a lighthouse): SPOTLIGHT.

Parameters
lightThe light to edit (any value between 1 to 4).
posA table with the position values for the 3 axes (x,y,z).
spotexpSets the light size.
spotcutSets the angle of aperture of the light (in degrees).
Returns
Nothing.
NIL amg.setlightmap ( STRING  path)

Changes the light map for Cel-Shading.

Parameters
pathPath to the light map (an image, the smaller the better).
Returns
Nothing.
NIL amg.fog ( NUMBER  near,
NUMBER  far,
COLOR  color 
)

Enables the fog.

Parameters
nearValue where the fog starts (Z axis).
farValue where the fog ends (Z axis).
colorFog color.
Returns
Nothing.
NIL amg.fog ( )

Disables the fog.

Returns
Nothing.
BOOLEAN amg.raytracing ( TABLE  pos,
TABLE  vector 
)

Makes a Ray Tracing test (checks for colisions between a straight line and 3D objects)

Parameters
posA table with the ray position values for the 3 axes (x,y,z).
vectorA table with the ray direction vector values for the 3 axes (x,y,z).
Returns
true/false If the ray colided with an object.
NIL amg.gravity ( NUMBER  x,
NUMBER  y,
NUMBER  z 
)

Sets the 3D world gravity.

Parameters
xX component if the gravity vector.
yY component if the gravity vector.
zZ component if the gravity vector.
Returns
Nothing.
NIL amg.screenshot ( STRING  path)

Save an image to the specified path (it should include the filename and its extension, only png).

Parameters
pathThe path, filename and extension png of the image.
Returns
Nothing.
NIL amg.finish ( )

Finishes the 3D engine.

Returns
Nothing.