aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/phys
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-10-31 12:39:50 -0400
committerAlexander Pickering <alex@cogarr.net>2018-10-31 12:39:50 -0400
commit6df9cb0de3e457788808b485b8b34bd8f0d6e42b (patch)
treede15337ea18f28f8643aedabfe2c34448a1b45fe /src/client/lua_api/phys
parent133e620665037ea2b66da65c67716b290711bfde (diff)
downloadbrokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.tar.gz
brokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.tar.bz2
brokengine-6df9cb0de3e457788808b485b8b34bd8f0d6e42b.zip
Added more documentation
Added documentation for luadoc for * io.* * phys.* * video.*
Diffstat (limited to 'src/client/lua_api/phys')
-rw-r--r--src/client/lua_api/phys/bphysgeneric.cpp95
1 files changed, 77 insertions, 18 deletions
diff --git a/src/client/lua_api/phys/bphysgeneric.cpp b/src/client/lua_api/phys/bphysgeneric.cpp
index e4e8ab0..91b4c21 100644
--- a/src/client/lua_api/phys/bphysgeneric.cpp
+++ b/src/client/lua_api/phys/bphysgeneric.cpp
@@ -5,21 +5,25 @@ extern "C" {
#include <lualib.h>
}
#include <btBulletDynamicsCommon.h>
-//#include <irrlicht.h>
#include <shared/lua_api/common.hpp>
-//extern IrrlichtDevice* device;
+/***
+@module phys
+*/
-//extern btDiscreteDynamicsWorld* World;
-//extern std::list<btRigidBody*> Objects;
-/*Physics things have the form of:
+/*Physics things from lua have the form of:
{
rigidbody = btRigidBody,
node = ISceneNode,
}
*/
+/***
+Sets the direction of gravity on this object.
+@function rigidbody:setgravity({x,y,z})
+@tparam vector3d direction The direction to make gravity point
+*/
//rigidbody:setgravity({x,y,z})
int setgravity(lua_State *L){
double x,y,z;
@@ -36,7 +40,29 @@ int setgravity(lua_State *L){
return 0;
}
-//apply force at a reletive offset
+/***
+Gets the direction of gravity on this object.
+@function rigidbody:getgravity()
+@treturn vector3d The direction of gravity on this object.
+*/
+//rigidbody:getgravity()
+int getgravity(lua_State *L){
+ lua_getfield(L,-1,"rigidbody");//{rigidbody},ud_rigidbody
+ btRigidBody *r = (btRigidBody*)lua_touserdata(L,-1);
+ lua_pop(L,2);//
+
+ btVector3 v = r->getGravity();
+ pushvector3d(L,v.x(),v.y(),v.z());
+
+ return 0;
+}
+
+/***
+Apply force at a reletive offset.
+@function rigidbody:applyforce(direction, offset = {0,0,0})
+@tparam vector3d direction The direction of the force to apply
+@tparam vector3d offset The offset from the center of gravity to apply the force
+*/
//rigidbody:applyforce({x,y,z}[,{rx,ry,rz}])
int applyforce(lua_State *L){
double rx,ry,rz;
@@ -62,6 +88,11 @@ int applyforce(lua_State *L){
return 0;
}
+/***
+Gets the damping applied to this rigidbody
+@function rigidbody:getldamping()
+@treturn number damping The ammount of damping applied to the object's momentum
+*/
//rigidbody:getldamping()
int getlineardamping(lua_State *L){
lua_getfield(L,-1,"rigidbody");
@@ -74,6 +105,28 @@ int getlineardamping(lua_State *L){
return 1;
}
+/***
+Gets the angular damping applied to this rigidbody
+@function rigidbody:getadamping()
+@treturn number damping The ammount of damping applied to angular momentum
+*/
+//rigidbody:getadamping()
+int getangulardamping(lua_State *L){
+ lua_getfield(L,-1,"rigidbody");
+ btRigidBody *r = (btRigidBody*)lua_touserdata(L,-1);
+ lua_pop(L,2);
+
+ double damp = r->getAngularDamping();
+ lua_pushnumber(L,damp);
+
+ return 1;
+}
+
+/***
+Gets the velocity of this object
+@function rigidbody:getvelocity()
+@treturn vector3 The velocity in each direction
+*/
//rigidbody:getvelocity()
int getvelocity(lua_State *L){
btVector3 vel;
@@ -86,6 +139,11 @@ int getvelocity(lua_State *L){
return 1;
}
+/***
+Sets the velocity of this object
+@function rigidbody:setvelocity()
+@tparam vector3d direction The ammount on each axis to set the velocity of this object.
+*/
//rigidbody:setvelocity({x,y,z})
int setvelocity(lua_State *L){
double x,y,z;
@@ -101,18 +159,13 @@ int setvelocity(lua_State *L){
return 0;
}
-//rigidbody:getadamping()
-int getangulardamping(lua_State *L){
- lua_getfield(L,-1,"rigidbody");
- btRigidBody *r = (btRigidBody*)lua_touserdata(L,-1);
- lua_pop(L,2);
-
- double damp = r->getAngularDamping();
- lua_pushnumber(L,damp);
-
- return 1;
-}
-
+/***
+Activates this object.
+If this object was sleeping, it will move again. If you are using
+applyforce or setvelocity, you will need to activate() the rigidbody for it
+to move.
+@function rigidbody:activate()
+*/
//rigidbody:activate()
int activate(lua_State *L){
lua_getfield(L,-1,"rigidbody");
@@ -124,6 +177,12 @@ int activate(lua_State *L){
return 0;
}
+/***
+Sets the damping of this object.
+@function rigidbody:setdamping(damping,angular_damping)
+@tparam number damping The ammount of damping the object should put on it's movement.
+@tparam number angular_damping The ammount of damping the object should put on it's angular momentum
+*/
//rigidbody:setdamping(lineardamping, angulardamping)
int setdamping(lua_State *L){
double adamp,ldamp;