From 2009501214f3c2e3f8d8b1a06432afdf39276bd5 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 7 Nov 2018 14:49:35 -0500 Subject: Added Kinematic Character Controllers --- src/shared/lua_api/phys/bhingeconstraint.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/shared/lua_api/phys/bhingeconstraint.cpp') diff --git a/src/shared/lua_api/phys/bhingeconstraint.cpp b/src/shared/lua_api/phys/bhingeconstraint.cpp index 168d1b6..ab6fb50 100644 --- a/src/shared/lua_api/phys/bhingeconstraint.cpp +++ b/src/shared/lua_api/phys/bhingeconstraint.cpp @@ -7,6 +7,7 @@ extern "C" { #include #include } +#include #include #include #include @@ -19,7 +20,23 @@ using namespace video; extern btDiscreteDynamicsWorld* World; extern std::list Objects; +//newhingeconstraint(phys1,v3 axis, refrencephys1) int newbhingeconstraint(lua_State *L){ + bool phys1 = lua_toboolean(L,-1) == 1; + lua_pop(L,1); + + double x,y,z; + popvector3d(L,&x,&y,&z); + + lua_getfield(L,-1,"rigidbody"); + btRigidBody *p1 = (btRigidBody*)lua_touserdata(L,-1); + btTransform frame = p1->getCenterOfMassTransform(); + frame.setRotation(btQuaternion(x,y,z,0)); + lua_pop(L,2); + + btHingeConstraint(*p1,frame,phys1); + printf("Done makeing new hinge constraint\n"); + return 0; } -- cgit v1.2.3-70-g09d2