-
Notifications
You must be signed in to change notification settings - Fork 1
DevNotes
lua Math Library Reference: http://lua-users.org/wiki/MathLibraryTutorial
lua Language Reference: http://www.lua.org/pil/
To convert old terrain format to new terrain format the light direction vector must be removed from the terrain definition file. (4th, 5th, and 6th values from beginning.)
C++ Programming Style Guidelines: http://geosoft.no/development/cppstyle.html
* a,A: move camera 4 left; move camera 2 and 3 along negative X-axis
* s,S: move camera 4 right; move camera 2 and 3 along positive X-axis
* d,D: move camera 4 backward; move camera 2 and 3 along positive Z-axis
* w,W: move camera 4 forward; move camera 2 and 3 along negative Z-axis
* r,R: move camera 4 up; move camera 2 and 3 along positive Y-axis
* f,F: move camera 4 down; move camera 2 and 3 along negative Y-axis
* z,Z: point camera 4 looking down negative Z-axis
* 1 : select camera 1 (main game camera)
* 2 : select camera 2 (overhead view, can only move along terrain editing grid)
* 3 : select camera 3 (normal view, can only move along terrain editing grid)
* 4 : select camera 4 (free roaming camera)
* o,O: output terrain file (save terrain to ./terrains/new_terrain.txt)
* u : undo last terrain color change only
* U : undo last terrain height, type and color change
* p : paint only the select terrain color
* P : paint terrain height, color, and type
* h : decrease terrain height at coordinates by .05 units
* H : increase terrain height at coordinates by .05 units
* 0 : set terrain height at coordinates to 0
* t,T: change terrain type (land or water)
* g,G: enable/disable grid
* l : load previous level
* L : load next level
* k,K: reload current level
* ; : assign previous loaded script to player
* : : assign next loaded script to player
* [ : decrease light direction's x value by .1 (normalizes and does not save)
* { : increase light direction's x value by .1 (normalizes and does not save)
* ] : decrease light direction's y value by .1 (normalizes and does not save)
* } : increase light direction's y value by .1 (normalizes and does not save)
* \ : decrease light direction's z value by .1 (normalizes and does not save)
* | : increase light direction's z value by .1 (normalizes and does not save)
* b,B: enable/disable object bounding boxes
* c,C: enable/disable object control triangles
To enable/disable terrain/level editing before building, set EDIT to 1/0 in constants.h
setModel(object_ref, model_name) - returns: n/a
setScript(object_ref, script_name) - returns: n/a
setScale(object_ref, x, y, z) - returns: n/a
getScale(object_ref) - returns: x, y, z - note: not implemented yet
setPosition(object_ref, x, y, z) - returns: n/a
getPosition(object_ref) - returns: x, y, z
setVelocity(object_ref, x, y, z) - returns: n/a
getVelocity(object_ref) - returns: x, y, z
setRotationVelocity(object_ref, x, y, z) - returns: n/a
getRotationVelocity(object_ref) - returns: x, y, z
setSpeed(object_ref, direction, speed) - returns: n/a
getSpeed(object_ref) - returns: direction, speed
setRotation(object_ref, x, y, z) - returns: n/a
getRotation(object_ref) - returns: x, y, z
getDirection(object_ref) - returns: x, y, z
getUp(object_ref) - returns: x, y, z
getOrthogonal(object_ref) - returns: x, y, z
addPosition(object_ref, x, y, z) - returns: n/a
addRotation(object_ref, x, y, z) - returns: n/a
addVelocity(object_ref, x, y, z) - returns: n/a
addSpeed(object_ref, speed) - returns: n/a
addRotationVelocity(object_ref, x, y, z) - returns: n/a
setInterpolationRotationStartAxis(object_ref, x, y, z) - returns: n/a
setInterpolationRotationEndAxis(object_ref, x, y, z) - returns: n/a
setInterpolationRotationStart(object_ref, x, y, z) - returns: n/a
setInterpolationRotationEnd(object_ref, x, y, z) - returns: n/a
setInterpolationEnable(object_ref, state) - returns: n/a
setInterpolationVariable(object_ref, interp_var, start_val, end_val) - returns: n/a
setRotationVelocityAxis(object_ref, x, y, z) - returns: n/a
setRotationAxis(object_ref, x, y, z) - returns: n/a
addRotationAxis(object_ref, x, y, z) - returns: n/a
getCamera() - returns: camera_ref
getPlayer() - returns: player_ref
getTimer(object_ref) - returns: timer
suspend(object_ref, delay) - returns: n/a - note: possibly will be removed/reworked
playSound(object_ref, sound_name) - returns: n/a
addObject(object_ref, script_name) - returns: object_ref
removeObject(object_Ref) - returns: n/a
addParticleSystem(object_ref, number) - returns: n/a - note: will be changed to use name
setBgMusic(song_name) - returns: n/a
setSkyBox(color1_red, color1_green, color1_blue,
color2_red, color2_green, color2_blue,
color3_red, color3_green, color3_blue) - returns: n/a
setLightDirection(x, y, z) - returns: n/a
setTerrain(terrain_name) - returns: n/a
* engine_testKeyPressed(object_ref, key_number) - returns: boolean result - note: should be tweaked to not take object_ref in future
* engine_testKeyReleased(object_ref, key_number) - returns: boolean result - note: should be tweaked to not take object_ref in future
Convert all get* lua functions that return 3 values to return 1 table (vector).
* setScaleRate(object_ref, x, y, z) - returns: n/a
* getScriptValue(object_ref, variable_name) - returns: value of specified global variable in object_ref's script
* getTypeId(object_ref) - returns: type id of specified object
* setTypeId(object_ref, type_id (int)) - returns: n/a
* vector_getScalar(vector, vector) - returns: float
* vector_normalize(vector, vector) - returns: vector
* vector_dotProduct(vector, vector) - returns: float
* vector_crossProduct(vector, vector) - returns: vector
Engine level script is used for loading levels and handling global user control. The engine level script controls the game's flow.
Added "vector" version of all existing set/add KRIG engine lua functions:
setScalev(object_ref, vector) - returns: n/a
setScaleRatev(object_ref, vector) - returns: n/a
setPositionv(object_ref, vector) - returns: n/a
setVelocityv(object_ref, vector) - returns: n/a
setRotationv(object_ref, vector) - returns: n/a
setRotationVelocityv(object_ref, vector) - returns: n/a
addPositionv(object_ref, vector) - returns: n/a
addVelocityv(object_ref, vector) - returns: n/a
addRotationv(object_ref, vector) - returns: n/a
addRotationVelocityv(object_ref, vector) - returns: n/a
setInterpolationRotationStartAxisv(object_ref, vector) - returns: n/a
setInterpolationRotationEndAxisv(object_ref, vector) - returns: n/a
setInterpolationRotationStartv(object_ref, vector) - returns: n/a
setInterpolationRotationEndv(object_ref, vector) - returns: n/a
setRotationVelocityAxisv(object_ref, vector) - returns: n/a
setRotationAxisv(object_ref, vector) - returns: n/a
addRotationAxisv(object_ref, vector) - returns: n/a
setLightDirectionv(vector) - returns: n/a
Added new KRIG Engine lua scripting functions:
loadLevel(fileName) - returns: n/a
shutdown() - returns: n/a
pause() - returns: n/a
playBgMusic(fileName, repeat) - returns: n/a
stopBgMusic() - returns: n/a
pauseBgMusic() - returns: n/a
getScale() - returns: vector
getScaleRate() - returns: vector
addScale() - returns: n/a
addScalev() - returns: n/a
addScaleRate() - returns: n/a
addScaleRatev() - returns: n/a
Removed KRIG Engine lua scripting functions:
setBgMusic()
OpenGL can now be used in lua scripts to draw objects on the screen. LuaGL Reference: http://luagl.wikidot.com/
getLightDirection() - returns: vector
getFps() - returns: value
displayText(string, x, y) - returns: n/a
getCameraId() - returns: currently set camera's ID
Install ATI driver on Ubuntu (9.04+): http://tan-com.com/posts/technology/fix-ubuntu-904-ati-driver-issue
engine_testSpecialKeyPressed(object_ref, key_number) - returns: boolean result - for use with GLUT special keys (ie arrow keys)
engine_testSpecialKeyReleased(object_ref, key_number) - returns: boolean result - for use with GLUT special keys (ie arrow keys)
setScriptValue(object_ref, variable_name, value) - sets variable_name to value in script for object_ref
enableAlwaysLit(object_ref) - object is always fully lit regardless of orientation or light position.
disableAlwaysLit(object_ref) - shading depends on object's orientation and light position.
orientOnTerrain(object_ref, x_rot, y_rot, z_rot) - set object's height to terrain's height at object's position; orient object sothat it is "setting" on the terrain. x/y/z_rot are used to specify a base rotation for the object. The base rotation is applied before the object is placed on the terrain.
setHeightFromTerrain(object_ref, offset) - set the object's height to terrain's height at object's position + offset.
Numeric values placed after the script path in calls to "addObject" will be passed to that object's on_load call after the "this" argument.
Example:
Level file;
addObject(terrain, "./scripts/object1.lua", 1, 2.0, 3)
./scripts/object1.lua:
function on_load(this, val1, val2, val3)
if val1 ~= nil and val2 ~= nil and val3 ~= nil then
print ("val1="..val1.." val2="..val2.." val3="..val3.."\n")
end
-- do object init
end
Output: val1=1 val2=2.0 val3=3
Note: Only 8 values can be sent into the on_load function. These values must be numeric. You currently cannot use strings or tables.
Note: Lua does not enforce that all parameters in the parameter list are defined, so you have to do it.
camera_getFrutumPlane(n) - return the definition of the specified plane (list containing a, b, c and d where Ax + By + Cz + D = 0).
n must be an integer in [0-6). n specifies the plan number (in relation to the camera) to return:
0 - left, 1 - right, 2 - down, 3 - up, 4 - far, 5 - near.