mirror of https://github.com/bjornbytes/lovr.git
Body:getLinearVelocity; Body:setLinearVelocity;
This commit is contained in:
parent
798b09eb0d
commit
891db00bc9
|
@ -41,10 +41,31 @@ int l_lovrBodySetOrientation(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_lovrBodyGetLinearVelocity(lua_State* L) {
|
||||||
|
Body* body = luax_checktype(L, 1, Body);
|
||||||
|
float x, y, z;
|
||||||
|
lovrBodyGetLinearVelocity(body, &x, &y, &z);
|
||||||
|
lua_pushnumber(L, x);
|
||||||
|
lua_pushnumber(L, y);
|
||||||
|
lua_pushnumber(L, z);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l_lovrBodySetLinearVelocity(lua_State* L) {
|
||||||
|
Body* body = luax_checktype(L, 1, Body);
|
||||||
|
float x = luaL_checknumber(L, 2);
|
||||||
|
float y = luaL_checknumber(L, 3);
|
||||||
|
float z = luaL_checknumber(L, 4);
|
||||||
|
lovrBodySetLinearVelocity(body, x, y, z);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const luaL_Reg lovrBody[] = {
|
const luaL_Reg lovrBody[] = {
|
||||||
{ "getPosition", l_lovrBodyGetPosition },
|
{ "getPosition", l_lovrBodyGetPosition },
|
||||||
{ "setPosition", l_lovrBodySetPosition },
|
{ "setPosition", l_lovrBodySetPosition },
|
||||||
{ "getOrientation", l_lovrBodyGetOrientation },
|
{ "getOrientation", l_lovrBodyGetOrientation },
|
||||||
{ "setOrientation", l_lovrBodySetOrientation },
|
{ "setOrientation", l_lovrBodySetOrientation },
|
||||||
|
{ "getLinearVelocity", l_lovrBodyGetLinearVelocity },
|
||||||
|
{ "setLinearVelocity", l_lovrBodySetLinearVelocity },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
|
@ -118,3 +118,14 @@ void lovrBodySetOrientation(Body* body, float angle, float x, float y, float z)
|
||||||
quat_fromAngleAxis(quaternion, angle, axis);
|
quat_fromAngleAxis(quaternion, angle, axis);
|
||||||
dBodySetQuaternion(body->id, quaternion);
|
dBodySetQuaternion(body->id, quaternion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lovrBodyGetLinearVelocity(Body* body, float* x, float* y, float* z) {
|
||||||
|
const dReal* velocity = dBodyGetLinearVel(body->id);
|
||||||
|
*x = velocity[0];
|
||||||
|
*y = velocity[1];
|
||||||
|
*z = velocity[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
void lovrBodySetLinearVelocity(Body* body, float x, float y, float z) {
|
||||||
|
dBodySetLinearVel(body->id, x, y, z);
|
||||||
|
}
|
||||||
|
|
|
@ -33,3 +33,5 @@ void lovrBodyGetPosition(Body* body, float* x, float* y, float* z);
|
||||||
void lovrBodySetPosition(Body* body, float x, float y, float z);
|
void lovrBodySetPosition(Body* body, float x, float y, float z);
|
||||||
void lovrBodyGetOrientation(Body* body, float* angle, float* x, float* y, float* z);
|
void lovrBodyGetOrientation(Body* body, float* angle, float* x, float* y, float* z);
|
||||||
void lovrBodySetOrientation(Body* body, float angle, float x, float y, float z);
|
void lovrBodySetOrientation(Body* body, float angle, float x, float y, float z);
|
||||||
|
void lovrBodyGetLinearVelocity(Body* body, float* x, float* y, float* z);
|
||||||
|
void lovrBodySetLinearVelocity(Body* body, float x, float y, float z);
|
||||||
|
|
Loading…
Reference in New Issue