static ERL_NIF_TERM new_btDiscreteDynamicsWorld(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { return wrap_pointer(env, btDynamicsWorld_resource, new btDiscreteDynamicsWorld( (btCollisionDispatcher*)unwrap_pointer( env, btCollisionDispatcher_resource, argv[0] ), (btBroadphaseInterface*)unwrap_pointer( env, btBroadphaseInterface_resource, argv[1] ), (btSequentialImpulseConstraintSolver*)unwrap_pointer( env, btSequentialImpulseConstraintSolver_resource, argv[2] ), (btDefaultCollisionConfiguration*)unwrap_pointer( env, btDefaultCollisionConfiguration_resource, argv[3] ) )); }
static ERL_NIF_TERM new_btRigidBodyConstructionInfo(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { double mass; btVector3 inertia = get_vector(env,argv[3]); enif_get_double(env, argv[0], &mass); return wrap_pointer(env,btRigidBodyConstructionInfo_resource, new btRigidBody::btRigidBodyConstructionInfo( mass, (btMotionState*)unwrap_pointer(env,btMotionState_resource,argv[1]), (btCollisionShape*)unwrap_pointer(env,btCollisionShape_resource,argv[2]), inertia )); }
static ERL_NIF_TERM btRigidBody_setDamping(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { double lin_damping,and_damping; enif_get_double(env, argv[1], &lin_damping); enif_get_double(env, argv[2], &and_damping); ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setDamping(lin_damping,and_damping); return enif_make_atom(env, "ok"); }
std::string string_format(value_t value) { std::stringstream sstream; double_storage_t* storage = (double_storage_t*) unwrap_pointer(value); std::string* string_pointer = (std::string*) storage->first_slot; sstream << "\"" << *string_pointer << "\""; return sstream.str(); }
static ERL_NIF_TERM btCollisionShape_calculateLocalInertia(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { btVector3 ret; double mass; enif_get_double(env, argv[1], &mass); ((btCollisionShape*)unwrap_pointer(env,btCollisionShape_resource,argv[0]))->calculateLocalInertia((btScalar)mass,ret); return vector_to_tuple(env,ret); }
static ERL_NIF_TERM btDynamicsWorld_stepSimulation(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btDynamicsWorld*)unwrap_pointer( env, btDynamicsWorld_resource, argv[0] ))->stepSimulation(0.0166667f, 0); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btDynamicsWorld_setGravity(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btDynamicsWorld*)unwrap_pointer( env, btDynamicsWorld_resource, argv[0] ))->setGravity(get_vector(env,argv[1])); return enif_make_atom(env, "ok"); }
// Menu Screen Shot JNIEXPORT JHANDLE JNICALL OS_NATIVE(_1fetchPopupMenuVisualData)(JNIEnv *env, jclass that, JHANDLE jshell, JHANDLE jmenu, jintArray jsizes) { // initializing HWND oldFocused = GetFocus(); hCallWndHook = NULL; hwndPopupMenu = NULL; hdefaultDC = NULL; hDC = NULL; hBitmap = NULL; wpOrigEditProc = NULL; calcSizeDone = false; hWnd = (HWND)unwrap_pointer(env, jshell); hMenu = (HMENU)unwrap_pointer(env, jmenu); // install hook // DWORD ourThreadID = GetWindowThreadProcessId(hWnd, NULL); DWORD ourThreadID = GetCurrentThreadId(); hCallWndHook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)CallWndProc, NULL, ourThreadID); if (hCallWndHook == NULL) { return NULL; } // prepare dimensions array elements jsize sizesSize = env->GetArrayLength(jsizes); sizes = new jint[sizesSize]; // display menu window SetForegroundWindow(hWnd); TrackPopupMenuEx(hMenu, TPM_HORIZONTAL | TPM_LEFTALIGN | TPM_NOANIMATION, 100, 100, hWnd, NULL); // copy dimensions into java array env->SetIntArrayRegion(jsizes, 0, sizesSize, sizes); // remove hook and clean up UnhookWindowsHookEx(hCallWndHook); hCallWndHook = NULL; if (hdefaultDC) { ReleaseDC(NULL, hdefaultDC); } if (hDC) { DeleteDC(hDC); } delete []sizes; // restore focus if (oldFocused != NULL) { SetFocus(oldFocused); } // return bitmap (may be NULL) return wrap_pointer(env, hBitmap); }
static ERL_NIF_TERM new_btCollisionDispatcher(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { return wrap_pointer( env, btCollisionDispatcher_resource, new btCollisionDispatcher( (btDefaultCollisionConfiguration*)unwrap_pointer( env, btDefaultCollisionConfiguration_resource, argv[0] ) ) ); }
JNIEXPORT jboolean JNICALL OS_NATIVE(_1getMenuBarOrItemBounds)(JNIEnv *env, jclass that, JHANDLE jshell, jint jitemIndex, jintArray jbounds) { HWND hwnd = (HWND)unwrap_pointer(env, jshell); MENUBARINFO info; info.cbSize = sizeof(MENUBARINFO); if (GetMenuBarInfo(hwnd, OBJID_MENU, jitemIndex, &info)) { // prepare buffer jsize boundsSize = env->GetArrayLength(jbounds); jint *bounds = new jint [boundsSize * sizeof(jint)]; *(bounds + 0) = info.rcBar.left; *(bounds + 1) = info.rcBar.right; *(bounds + 2) = info.rcBar.top; *(bounds + 3) = info.rcBar.bottom; // copy dimensions into java array env->SetIntArrayRegion(jbounds, 0, boundsSize, bounds); delete []bounds; return JNI_TRUE; } return JNI_FALSE; }
static ERL_NIF_TERM btRigidBody_setAngularFactor(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { double angular_factor; enif_get_double(env, argv[1], &angular_factor); ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setAngularFactor(angular_factor); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btRigidBody_setWorldTransform(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setWorldTransform(get_transform(env,argv[1])); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btRigidBody_getOrientation(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { return quaternion_to_tuple(env,((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->getOrientation()); }
static ERL_NIF_TERM btRigidBody_getCenterOfMassPosition(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { return vector_to_tuple(env,((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->getCenterOfMassPosition()); }
static WebWindow* getWebWindow(JNIEnv *env, jobject jwnd) { return (WebWindow*)unwrap_pointer(env, jwnd); }
static ERL_NIF_TERM btRigidBody_getLinearVelocity(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { return vector_to_tuple(env, ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->getLinearVelocity()); }
static ERL_NIF_TERM new_btRigidBody(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { btRigidBody::btRigidBodyConstructionInfo *rbCI = (btRigidBody::btRigidBodyConstructionInfo*)unwrap_pointer(env,btRigidBodyConstructionInfo_resource,argv[0]); btRigidBody *bady = new btRigidBody(*rbCI); return wrap_pointer(env,btRigidBody_resource, new btRigidBody(*rbCI)); }
void string_finalize(value_t value) { double_storage_t* storage = (double_storage_t*) unwrap_pointer(value); std::string* string_pointer = (std::string*) storage->first_slot; delete string_pointer; }
static ERL_NIF_TERM btRigidBody_setActivationState(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { int state; enif_get_int(env, argv[1], &state); ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setActivationState(state); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btRigidBody_setLinearVelocity(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setLinearVelocity(get_vector(env, argv[1])); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btRigidBody_setFriction(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { double friction; enif_get_double(env, argv[1], &friction); ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->setFriction(friction); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btRigidBody_applyCentralImpulse(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[0]))->applyCentralImpulse(get_vector(env, argv[1])); return enif_make_atom(env, "ok"); }
static ERL_NIF_TERM btDynamicsWorld_removeRigidBody(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { ((btDynamicsWorld*)unwrap_pointer(env,btDynamicsWorld_resource,argv[0]))->removeRigidBody((btRigidBody*)unwrap_pointer(env,btRigidBody_resource,argv[1])); return enif_make_atom(env, "ok"); }
std::string* unwrap_internal_string(value_t value) { double_storage_t* storage = (double_storage_t*) unwrap_pointer(value); return ((std::string*) storage->first_slot); }
JNIEXPORT void JNICALL OS_NATIVE(_1showAsPreview) (JNIEnv *env, jclass that, jobject jwnd, jobject jshell) { WebWindow* wnd = getWebWindow(env, jwnd); wnd->showAsPreview((HWND)unwrap_pointer(env, jshell)); }