added initial documentation (in progress), renamed ag:: functions with "Static" in the middle to have "Static" at the end

git-svn-id: svn://anubis/anaglym/trunk@191 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-11-23 02:24:30 +00:00
parent 459b3704d6
commit 6b62b9d00f
10 changed files with 476 additions and 87 deletions

3
.todo
View File

@ -1 +1,2 @@
- fix bug with wfobj objects changing appearance of managed objects - finish bowling demo
- finish ag and std documentation

View File

@ -165,6 +165,7 @@ bool Engine::load(const char * program)
if (path == "") if (path == "")
{ {
cerr << "Couldn't locate " FONT_NAME << endl; cerr << "Couldn't locate " FONT_NAME << endl;
return false;
} }
else else
{ {
@ -387,23 +388,23 @@ int Engine::getCamera(lua_State * L)
int Engine::registerEventHandler(lua_State * L) int Engine::registerEventHandler(lua_State * L)
{ {
int argc = lua_gettop(L); int argc = lua_gettop(L);
if (argc == 2 && lua_isfunction(L, 1) && lua_isstring(L, 2)) if (argc == 2 && lua_isstring(L, 1) && lua_isfunction(L, 2))
{ {
string event = lua_tostring(L, 2); string event = lua_tostring(L, 1);
if (event == "update") if (event == "update")
doRegisterHandler(1, update); doRegisterHandler(2, update);
else if (event == "update_overlay") else if (event == "update_overlay")
doRegisterHandler(1, update_overlay); doRegisterHandler(2, update_overlay);
else if (event == "key_down") else if (event == "key_down")
doRegisterHandler(1, key_down); doRegisterHandler(2, key_down);
else if (event == "key_up") else if (event == "key_up")
doRegisterHandler(1, key_up); doRegisterHandler(2, key_up);
else if (event == "mousebutton_down") else if (event == "mousebutton_down")
doRegisterHandler(1, mousebutton_down); doRegisterHandler(2, mousebutton_down);
else if (event == "mousebutton_up") else if (event == "mousebutton_up")
doRegisterHandler(1, mousebutton_up); doRegisterHandler(2, mousebutton_up);
else if (event == "mouse_motion") else if (event == "mouse_motion")
doRegisterHandler(1, mouse_motion); doRegisterHandler(2, mouse_motion);
} }
return 0; return 0;
} }
@ -527,6 +528,51 @@ void Engine::getScreenSize(int * width, int * height)
void Engine::drawText(const char * text, GLfloat r, GLfloat g, GLfloat b, void Engine::drawText(const char * text, GLfloat r, GLfloat g, GLfloat b,
int ptsize, float x, float y) int ptsize, float x, float y)
{ {
{ // sanity check framebuffer and env info
printf("GL err was %04x\n", glGetError());
GLint r, g, b, a, depth, sten, aux, dbl;
glGetIntegerv(GL_RED_BITS, &r);
glGetIntegerv(GL_GREEN_BITS, &g);
glGetIntegerv(GL_BLUE_BITS, &b);
glGetIntegerv(GL_ALPHA_BITS, &a);
glGetIntegerv(GL_DEPTH_BITS, &depth);
glGetIntegerv(GL_STENCIL_BITS, &sten);
glGetIntegerv(GL_AUX_BUFFERS, &aux);
glGetIntegerv(GL_DOUBLEBUFFER, &dbl);
printf("framebuffer: rgba %d %d %d %d, depth %d, stencil %d, aux bfr %d, double bfr %d\n",
r, g, b, a, depth, sten, aux, dbl);
GLint a_test, a_func; float a_ref;
glGetIntegerv(GL_ALPHA_TEST, &a_test);
glGetIntegerv(GL_ALPHA_TEST_FUNC, &a_func);
glGetFloatv(GL_ALPHA_TEST_REF, &a_ref);
printf("alpha testing: %d, func %04x ref %f\n", a_test, a_func, a_ref);
GLint blend, b_src, b_equ, b_dst;
GLfloat b_c[4];
glGetIntegerv(GL_BLEND, &blend);
glGetIntegerv(GL_BLEND_SRC, &b_src);
glGetIntegerv(GL_BLEND_EQUATION, &b_equ);
glGetIntegerv(GL_BLEND_DST, &b_dst);
glGetFloatv(GL_BLEND_COLOR, b_c);
printf("blending: %d, src %04x equ %04x dst %04x color %.2f %.2f %.2f %.2f\n",
blend, b_src, b_equ, b_dst, b_c[0], b_c[1], b_c[2], b_c[3]);
GLint logic, logmode, mask[4], cull, cullmode, front, draw;
glGetIntegerv(GL_COLOR_LOGIC_OP, &logic);
glGetIntegerv(GL_LOGIC_OP_MODE, &logmode);
glGetIntegerv(GL_COLOR_WRITEMASK, mask);
glGetIntegerv(GL_CULL_FACE, &cull);
glGetIntegerv(GL_CULL_FACE_MODE, &cullmode);
glGetIntegerv(GL_FRONT_FACE, &front);
glGetIntegerv(GL_DRAW_BUFFER, &draw);
printf("draw env: logic %d logmode %04x, mask %d %d %d %d, cull %d cullmode %04x frontface %04x, drawbuffer %04x\n",
logic, logmode, mask[0], mask[1], mask[2], mask[3], cull, cullmode, front, draw);
printf("GL err was %04x\n", glGetError());
printf("***\n");
}
checkGLError(); checkGLError();
m_font->FaceSize(ptsize); m_font->FaceSize(ptsize);
glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT); glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT);

77
ag.cc
View File

@ -21,46 +21,41 @@ namespace ag
void register_functions(lua_State * L) void register_functions(lua_State * L)
{ {
static const luaL_Reg functions[] = { static const luaL_Reg functions[] = {
{ "print", print }, { "clearEventHandler", clearEventHandler },
{ "println", println },
{ "loadModel", loadModel },
{ "loadStaticModel", loadStaticModel },
{ "sleep", sleep },
{ "startFrame", startFrame },
{ "endFrame", endFrame },
{ "setCamera", setCamera },
{ "getCamera", getCamera },
{ "elapsedTime", elapsedTime },
{ "doPhysics", doPhysics }, { "doPhysics", doPhysics },
{ "drawObjects", drawObjects }, { "drawObjects", drawObjects },
{ "elapsedTime", elapsedTime },
{ "endFrame", endFrame },
{ "exit", exit },
{ "getCamera", getCamera },
{ "getScreenSize", getScreenSize },
{ "import", import },
{ "isKeyDown", isKeyDown },
{ "loadModel", loadModel },
{ "loadModelStatic", loadModelStatic },
{ "loadTexture", loadTexture },
{ "print", print },
{ "println", println },
{ "registerEventHandler", registerEventHandler },
{ "setAutoDrawObjects", setAutoDrawObjects },
{ "setAutoEndFrame", setAutoEndFrame },
{ "setAutoPhysics", setAutoPhysics }, { "setAutoPhysics", setAutoPhysics },
{ "setAutoStartFrame", setAutoStartFrame }, { "setAutoStartFrame", setAutoStartFrame },
{ "setAutoEndFrame", setAutoEndFrame }, { "setCamera", setCamera },
{ "setAutoDrawObjects", setAutoDrawObjects }, // { "sleep", sleep },
{ "isKeyDown", isKeyDown }, { "startFrame", startFrame },
{ "registerEventHandler", registerEventHandler },
{ "clearEventHandler", clearEventHandler },
{ "exit", exit },
{ "import", import },
{ "loadTexture", loadTexture },
{ "getScreenSize", getScreenSize },
{ "drawText", drawText},
{ "getTextSize", getTextSize},
{ "drawLine", drawLine},
{ "drawRect", drawRect},
{ "fillRect", fillRect},
{ "drawImage", drawImage},
{ "createBox", createBox}, /* managed object functions */
{ "createStaticBox", createStaticBox}, { "createBox", createBox },
{ "createSphere", createSphere}, { "createBoxStatic", createBoxStatic },
{ "createStaticSphere", createStaticSphere}, { "createCapsule", createCapsule },
{ "createPlane", createPlane}, { "createCapsuleStatic", createCapsuleStatic },
{ "createStaticPlane", createStaticPlane}, { "createCylinder", createCylinder },
{ "createCylinder", createCylinder}, { "createCylinderStatic", createCylinderStatic },
{ "createStaticCylinder", createStaticCylinder}, { "createPlane", createPlane },
{ "createCapsule", createCapsule}, { "createPlaneStatic", createPlaneStatic },
{ "createStaticCapsule", createStaticCapsule}, { "createSphere", createSphere },
{ "createSphereStatic", createSphereStatic },
{ NULL, NULL } { NULL, NULL }
}; };
@ -197,7 +192,7 @@ namespace ag
return loadModelSpecify(L, false); return loadModelSpecify(L, false);
} }
int loadStaticModel(lua_State * L) int loadModelStatic(lua_State * L)
{ {
return loadModelSpecify(L, true); return loadModelSpecify(L, true);
} }
@ -543,7 +538,7 @@ namespace ag
return createBoxSpecify(L, false); return createBoxSpecify(L, false);
} }
int createStaticBox(lua_State * L) int createBoxStatic(lua_State * L)
{ {
return createBoxSpecify(L, true); return createBoxSpecify(L, true);
} }
@ -567,7 +562,7 @@ namespace ag
return createSphereSpecify(L, false); return createSphereSpecify(L, false);
} }
int createStaticSphere(lua_State * L) int createSphereStatic(lua_State * L)
{ {
return createSphereSpecify(L, true); return createSphereSpecify(L, true);
} }
@ -604,7 +599,7 @@ namespace ag
return createPlaneSpecify(L, false); return createPlaneSpecify(L, false);
} }
int createStaticPlane(lua_State * L) int createPlaneStatic(lua_State * L)
{ {
return createPlaneSpecify(L, true); return createPlaneSpecify(L, true);
} }
@ -629,7 +624,7 @@ namespace ag
return createCylinderSpecify(L, false); return createCylinderSpecify(L, false);
} }
int createStaticCylinder(lua_State * L) int createCylinderStatic(lua_State * L)
{ {
return createCylinderSpecify(L, true); return createCylinderSpecify(L, true);
} }
@ -654,7 +649,7 @@ namespace ag
return createCapsuleSpecify(L, false); return createCapsuleSpecify(L, false);
} }
int createStaticCapsule(lua_State * L) int createCapsuleStatic(lua_State * L)
{ {
return createCapsuleSpecify(L, true); return createCapsuleSpecify(L, true);
} }

62
ag.h
View File

@ -7,49 +7,51 @@
namespace ag namespace ag
{ {
void register_functions(lua_State * L); void register_functions(lua_State * L);
int print(lua_State * L);
int println(lua_State * L); /* Lua interfaces */
int loadModel(lua_State * L); int clearEventHandler(lua_State * L);
int loadStaticModel(lua_State * L);
int sleep(lua_State * L);
int startFrame(lua_State * L);
int endFrame(lua_State * L);
int setCamera(lua_State * L);
int getCamera(lua_State * L);
int elapsedTime(lua_State * L);
int doPhysics(lua_State * L); int doPhysics(lua_State * L);
int drawObjects(lua_State * L); int drawObjects(lua_State * L);
int elapsedTime(lua_State * L);
int endFrame(lua_State * L);
int exit(lua_State * L);
int getCamera(lua_State * L);
int getScreenSize(lua_State * L);
int import(lua_State * L);
int isKeyDown(lua_State * L);
int loadModel(lua_State * L);
int loadModelStatic(lua_State * L);
int loadTexture(lua_State * L);
int print(lua_State * L);
int println(lua_State * L);
int registerEventHandler(lua_State * L);
int setAutoDrawObjects(lua_State * L);
int setAutoEndFrame(lua_State * L);
int setAutoPhysics(lua_State * L); int setAutoPhysics(lua_State * L);
int setAutoStartFrame(lua_State * L); int setAutoStartFrame(lua_State * L);
int setAutoEndFrame(lua_State * L); int setCamera(lua_State * L);
int setAutoDrawObjects(lua_State * L); int sleep(lua_State * L);
int isKeyDown(lua_State * L); int startFrame(lua_State * L);
int registerEventHandler(lua_State * L);
int clearEventHandler(lua_State * L);
int exit(lua_State * L);
int import(lua_State * L);
int loadTexture(lua_State * L);
int getScreenSize(lua_State * L);
/* 2D overlay functions */ /* 2D overlay functions */
int drawText(lua_State * L); int drawImage(lua_State * L);
int getTextSize(lua_State * L);
int drawLine(lua_State * L); int drawLine(lua_State * L);
int drawRect(lua_State * L); int drawRect(lua_State * L);
int drawText(lua_State * L);
int fillRect(lua_State * L); int fillRect(lua_State * L);
int drawImage(lua_State * L); int getTextSize(lua_State * L);
/* managed object creation functions */ /* managed object creation functions */
int createBox(lua_State * L); int createBox(lua_State * L);
int createStaticBox(lua_State * L); int createBoxStatic(lua_State * L);
int createSphere(lua_State * L);
int createStaticSphere(lua_State * L);
int createPlane(lua_State * L);
int createStaticPlane(lua_State * L);
int createCylinder(lua_State * L);
int createStaticCylinder(lua_State * L);
int createCapsule(lua_State * L); int createCapsule(lua_State * L);
int createStaticCapsule(lua_State * L); int createCapsuleStatic(lua_State * L);
int createCylinder(lua_State * L);
int createCylinderStatic(lua_State * L);
int createPlane(lua_State * L);
int createPlaneStatic(lua_State * L);
int createSphere(lua_State * L);
int createSphereStatic(lua_State * L);
namespace object namespace object
{ {

346
doc/index.html Normal file
View File

@ -0,0 +1,346 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Anaglym Documentation</title>
<style type="text/css">
</style>
</head>
<body>
<h1>Anaglym Documentation</h1>
<p>
Anaglym exposes a Lua library named <tt>ag</tt> which contains functions
for interfacing with the Engine.
In addition to the <tt>ag</tt> library, there is a <tt>std</tt> library
which contains a "standard library" of Lua functions that do not directly
interface with the Anaglym engine.
The library functions are documented below.
</p>
<ul>
<li><a href="#ag"><tt>ag</tt> library</a></li>
<li><a href="#std"><tt>std</tt> library</a></li>
</ul>
<hr />
<a name="ag" />
<h2><tt>ag</tt> library</h2>
<a name="ag_clearEventHandler" />
<h3>clearEventHandler</h3>
<p><tt>ag.clearEventHandler(event_name)</tt><p>
<p>
This function removes a Lua callback function from being associated
with the engine event specified.
<tt>event_name</tt> should be one of the following strings:
<ul>
<li>update</li>
<li>update_overlay</li>
<li>key_down</li>
<li>key_up</li>
<li>mousebutton_down</li>
<li>mousebutton_up</li>
<li>mouse_motion</li>
</ul>
</p>
<a name="ag_doPhysics" />
<h3>doPhysics</h3>
<p><tt>ag.doPhysics()</tt></p>
<p>
This function invokes the physics processing part of the engine.
It is invoked automatically every update step if the "AutoPhysics"
mode is enabled; this mode is enabled by default.
See <a href="#ag_setAutoPhysics">setAutoPhysics</a> for more information.
</p>
<a name="ag_drawObjects" />
<h3>drawObjects</h3>
<p><tt>ag.drawObjects()</tt></p>
<p>
This function instructs the engine to draw all visible objects.
It is invoked automatically every update step if the "AutoDrawObjects"
mode is enabled; this mode is enabled by default.
See <a href="#ag_setAutoDrawObjects">setAutoDrawObjects</a>
for more information.
</p>
<a name="ag_elapsedTime" />
<h3>elapsedTime</h3>
<p><tt>elapsed_msec = ag.elapsedTime()</tt></p>
<p>
This function returns the number of milliseconds that have elapsed
since the beginning of the program.
</p>
<a name="ag_endFrame" />
<h3>endFrame</h3>
<p><tt>ag.endFrame()</tt></p>
<p>
This function signals the engine that all drawing is complete for the
current update frame.
It is invoked automatically if the "AutoEndFrame" mode is enabled;
this mode is enabled by default.
See <a href="#ag_setAutoEndFrame">setAutoEndFrame</a> for more
information.
</p>
<a name="ag_exit" />
<h3>exit</h3>
<p><tt>ag.exit()</tt></p>
<p>
This function instructs the engine to exit.
Internally, this function enqueues an "exit" event on the event
queue to be processed by the engine.
This means that Lua code following the call to <tt>exit()</tt>
will be executed and callbacks to other events may still be called.
The engine should exit within one update step.
</p>
<a name="ag_getCamera" />
<h3>getCamera</h3>
<p><tt>eye_x, eye_y, eye_z, center_x, center_y, center_z, up_x, up_y, up_z = ag.getCamera()</tt></p>
<p>
This function returns the camera position (eye coordinates),
focus position (center coordinates), and up vector for the current
camera settings.
</p>
<a name="ag_getScreenSize" />
<h3>getScreenSize</h3>
<p><tt>width, height = ag.getScreenSize()</tt></p>
<p>
This function returns the dimensions of the engine window, in pixels.
</p>
<a name="ag_import" />
<h3>import</h3>
<p><tt>ag.import(lua_source_name)</tt></p>
<p>
This function instructs the engine to import a Lua source file named
<tt>lua_source_name</tt>, which should be a string specifying the
name of the Lua library without the ".lua" extension.
Source files are searched for relative to the folder containing the
hosted script first, then relative to the engine library folder.
The <tt>import()</tt> function can be used to load Lua code that
is broken into separate source files.
</p>
<a name="ag_isKeyDown" />
<h3>isKeyDown</h3>
<p><tt>result = ag.isKeyDown(key)</tt></p>
<p>
This function returns a boolean value for whether or not the key
given by <tt>key</tt> is currently pressed or not.
<tt>key</tt> should be a string corresponding to a key name.
See <a href="#keys">keys</a> for key names.
</p>
<a name="ag_loadModel" />
<h3>loadModel</h3>
<p><tt>object = ag.loadModel(model_name [, scale])</tt></p>
<p>
This function loads an object file and returns the object loaded.
If the returned value is <tt>nil</tt>, loading of the object failed.
<tt>model_name</tt> should be a string specifying the base name of
the model file, without the ".obj" extension.
Models are searched for relative to the folder containing the
hosted script first, then relative to the engine library folder.
<tt>scale</tt> is an optional parameter that defaults to 1.0.
</p>
<a name="ag_loadModelStatic" />
<h3>loadModelStatic</h3>
<p><tt>object = ag.loadModelStatic(model_name [, scale])</tt></p>
<p>
<tt>loadModelStatic()</tt> is the same as <tt>loadModel()</tt>, with
the exception that the object loaded is created as a static object.
A static object can still be placed with
<a href="#model_setPosition">setPosition()</a> and
<a href="#model_setRotation">setRotation()</a>.
A static object will participate in collision detection when
physics computations are performed, however a static object will not
be moved by any colliding objects.
</p>
<a name="ag_loadTexture" />
<h3>loadTexture</h3>
<p><tt>texture = ag.loadTexture(texture_name)</tt></p>
<p>
This function loads a texture file from the file system and returns
a Lua reference to the loaded texture.
<tt>nil</tt> is returned if loading the texture fails.
The <tt>texture_name</tt> should contain the file extension, since
multiple formats are supported (.jpg, .png, .bmp, etc...).
Textures are searched for relative to the folder containing the
hosted script first, then relative to the engine library folder.
</p>
<a name="ag_print" />
<h3>print</h3>
<p><tt>ag.print(args...)</tt></p>
<p>
This function prints its arguments to the standard output.
On Windows, this output stream may be redirected to a file (stdout.txt).
Example usage:
<pre>local x, y, z = my_obj:getPosition()
ag.print("my_obj position: (", x, ", ", y, ", ", z, ")")
</pre>
</p>
<a name="ag_println" />
<h3>println</h3>
<p><tt>ag.println(args...)</tt></p>
<p>
Identical to <tt>print()</tt> but automatically prints a newline ("\n")
after printing the arguments.
</p>
<a name="ag_registerEventHandler" />
<h3>registerEventHandler</h3>
<p><tt>ag.registerEventHandler(event_name, handler)</tt></p>
<p>
This function registers a Lua callback function (<tt>handler</tt>)
to be called when the engine event specified by <tt>event_name</tt>
occurs.
There can be only one registered handler per event, so if a previous
Lua function was registered for <tt>event_name</tt>, it will be
overwritten to call the new handler.
<tt>event_name</tt> should be one of:
<ul>
<li>update</li>
<li>update_overlay</li>
<li>key_down</li>
<li>key_up</li>
<li>mousebutton_down</li>
<li>mousebutton_up</li>
<li>mouse_motion</li>
</ul>
</p>
<a name="ag_setAutoDrawObjects" />
<h3>setAutoDrawObjects</h3>
<p><tt>ag.setAutoDrawObjects(enable_flag)</tt></p>
<p>
This function sets the "AutoDrawObjects" mode.
<tt>enable_flag</tt> should be <tt>true</tt> or <tt>false</tt>.
If AutoDrawObjects mode is enabled, then all visible objects in the
engine will be drawn automatically every update step.
If it is not enabled, one can call
<a href="#ag_drawObjects"><tt>ag.drawObjects()</tt></a>
to draw all visible objects in the scene.
</p>
<a name="ag_setAutoEndFrame" />
<h3>setAutoEndFrame</h3>
<p><tt>ag.setAutoEndFrame(enable_flag)</tt></p>
<p>
This function sets the "AutoEndFrame" mode.
<tt>enable_flag</tt> should be <tt>true</tt> or <tt>false</tt>.
If AutoEndFrame mode is enabled, then
<a href="#ag_endFrame"><tt>ag.endFrame()</tt></a>
will be invoked automatically after executing the update
and update_overlay Lua callback functions.
</p>
<a name="ag_setAutoPhysics" />
<h3>setAutoPhysics</h3>
<p><tt>ag.setAutoPhysics(enable_flag)</tt></p>
<p>
This function sets the "AutoPhysics" mode.
<tt>enable_flag</tt> should be <tt>true</tt> or <tt>false</tt>.
If AutoPhysics mode is enabled, then collision detection and
physics processing is performed automatically on every update step.
If it is not enabled, one can call
<a href="#ag_doPhysics"><tt>ag.doPhysics()</tt></a>
to perform physics updates.
</p>
<a name="ag_setAutoStartFrame" />
<h3>setAutoStartFrame</h3>
<p><tt>ag.setAutoStartFrame(enable_flag)</tt></p>
<p>
This function sets the "AutoStartFrame" mode.
<tt>enable_flag</tt> should be <tt>true</tt> or <tt>false</tt>.
If AutoStartFrame mode is enabled, then
<a href="ag_startFrame"><tt>ag.startFrame()</tt></a>
will be invoked automatically prior to executing the update and
update_overlay Lua callback functions.
</p>
<a name="ag_setCamera" />
<h3>setCamera</h3>
<p><tt>ag.setCamera(eye_x, eye_y, eye_z [, center_x, center_y, center_z [, up_x, up_y, up_z] ])</tt></p>
<p>
This function sets the camera position (eye coordinates), focus point
(center coordinates), and up vector.
If the center coordinates or up vector are not specified, their values
are unchanged from the previous invocation of <tt>setCamera()</tt>.
The default center point is (0, 0, 0).
The default up vector is (0, 0, 1).
</p>
<a name="ag_startFrame" />
<h3>startFrame</h3>
<p><tt>ag.startFrame()</tt></p>
<p>
This function instructs the engine to begin drawing a frame.
It is not necessary to call this function if the "AutoStartFrame"
mode is enabled.
See <a href="#ag_setAutoStartFrame">ag.setAutoStartFrame()</a>.
</p>
<hr />
<a name="std" />
<h2><tt>std</tt> library</h2>
<hr />
<a name="object_creation" />
<h2>Object creation functions</h2>
<a name="ag_createBox" />
<h3><tt>createBox</tt></h3>
<a name="ag_createBoxStatic" />
<h3><tt>createBoxStatic</tt></h3>
<a name="ag_createCapsul" />
<h3><tt>createCapsule</tt></h3>
<a name="ag_createCapsuleStatic" />
<h3><tt>createCapsuleStatic</tt></h3>
<a name="ag_createCylinder" />
<h3><tt>createCylinder</tt></h3>
<a name="ag_createCylinderStatic" />
<h3><tt>createCylinderStatic</tt></h3>
<a name="ag_createPlane" />
<h3><tt>createPlane</tt></h3>
<a name="ag_createPlaneStatic" />
<h3><tt>createPlaneStatic</tt></h3>
<a name="ag_createSphere" />
<h3><tt>createSphere</tt></h3>
<a name="ag_createSphereStatic" />
<h3><tt>createSphereStatic</tt></h3>
<hr />
<a name="object" />
<h2>Object member functions</h2>
<a name="object_setPosition" />
<h3><tt>obj:setPosition(x, y, z)</tt></h3>
</body>
</html>

View File

@ -1,6 +1,6 @@
function init() function init()
arena = ag.loadStaticModel("boxarena") arena = ag.loadModelStatic("boxarena")
ball = ag.loadModel("checkerball") ball = ag.loadModel("checkerball")
ball:setPosition(-7, 7.4, 12) ball:setPosition(-7, 7.4, 12)
ball2 = ball:clone() ball2 = ball:clone()

View File

@ -13,7 +13,6 @@ function init()
end end
end end
--local ground = ag.loadStaticModel("crate", 10)
local ground = ag.createPlane(0, 0, 1, 0) local ground = ag.createPlane(0, 0, 1, 0)
ground:setColor(0.8, 0.5, 0.0) ground:setColor(0.8, 0.5, 0.0)
ground:setPosition(0, 0, -10) ground:setPosition(0, 0, -10)
@ -29,7 +28,7 @@ function init()
-- local crate = ag.loadModel("crate") -- local crate = ag.loadModel("crate")
-- crate:setPosition(0, 20, 10) -- crate:setPosition(0, 20, 10)
crate_texture = ag.loadTexture("crate.png") -- crate_texture = ag.loadTexture("crate.png")
end end
function mousebutton_down_event(button) function mousebutton_down_event(button)

View File

@ -12,7 +12,7 @@ function init()
end end
end end
local ground = ag.loadStaticModel("crate", 10) local ground = ag.loadModelStatic("crate", 10)
ground:setPosition(0, 0, -10) ground:setPosition(0, 0, -10)
ag.setCamera(levels/2, -2*levels, levels, 0, 0, levels/2, 0, 0, 1) ag.setCamera(levels/2, -2*levels, levels, 0, 0, levels/2, 0, 0, 1)
camx, camy, camz, cx, cy, cz = ag.getCamera() camx, camy, camz, cx, cy, cz = ag.getCamera()

View File

@ -18,7 +18,7 @@ function init()
end end
end end
ground = ag.loadStaticModel("crate", 10) ground = ag.loadModelStatic("crate", 10)
ground:setPosition(0, 0, -10) ground:setPosition(0, 0, -10)
ag.setCamera(2, -12, 8, 0, 0, 2, 0, 0, 1) ag.setCamera(2, -12, 8, 0, 0, 2, 0, 0, 1)
end end

View File

@ -1,7 +1,7 @@
function init() function init()
local crate_texture = ag.loadTexture("checker.jpg") local crate_texture = ag.loadTexture("checker.jpg")
local ground = ag.createStaticPlane(0, 0, 1, 0) local ground = ag.createPlaneStatic(0, 0, 1, 0)
ground:setColor(0.2, 1.0, 0.2) ground:setColor(0.2, 1.0, 0.2)
ground:setTexture(crate_texture) ground:setTexture(crate_texture)
ag.setCamera(10, -10, 10, 0, 0, 0) ag.setCamera(10, -10, 10, 0, 0, 0)