void BasicRobot::Register (PhysicsBullet* p) { height = 0.02 * p->scalingFactor; radius = 0.035 * p->scalingFactor; //create a few dynamic rigidbodies // Re-using the same collision is better for memory usage and performance shape = new btCylinderShapeZ(btVector3(radius, radius, height / 2.0)); p->m_collisionShapes.push_back(shape); btScalar mass(0.1); btVector3 localInertia(0.0, 0.0, 0.0); shape->calculateLocalInertia(mass,localInertia); btTransform startTransform; startTransform.setIdentity(); //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects btDefaultMotionState* myMotionState = new btDefaultMotionState(startTransform); btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia); rbInfo.m_friction = 0.05; rbInfo.m_linearDamping = 0.05; rbInfo.m_angularDamping = 0.05; body = new btRigidBody(rbInfo); body->setGravity(btVector3 (0, 0, -9.81 * p->scalingFactor)); body->setUserPointer((void*)(this)); p->m_dynamicsWorld->addRigidBody(body, collisionType, collisionFilter); AddDevices(p); }
InputHandler_MacOSX_HID::InputHandler_MacOSX_HID() : m_Sem( "Input thread started" ), m_ChangeLock( "Input handler change lock" ) { InputDevice id = DEVICE_KEYBOARD; // Set up the notify ports. m_NotifyPort = IONotificationPortCreate( kIOMasterPortDefault ); // Add devices. LOG->Trace( "Finding keyboards" ); AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, id ); LOG->Trace( "Finding mice" ); AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse, id ); LOG->Trace( "Finding joysticks" ); id = DEVICE_JOY1; AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, id ); AddDevices( kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, id ); LOG->Trace( "Finding pump" ); id = DEVICE_PUMP1; AddDevices( kHIDPage_VendorDefinedStart, 0x0001, id ); // Pump pads use the first vendor specific usage page. m_bChanged = false; if( PREFSMAN->m_bThreadedInput ) { m_InputThread.SetName( "Input thread" ); m_InputThread.Create( InputHandler_MacOSX_HID::Run, this ); // Wait for the run loop to start before returning. m_Sem.Wait(); } else { m_LoopRef = CFRunLoopRef( GetCFRunLoopFromEventLoop(GetMainEventLoop()) ); CFRetain( m_LoopRef ); StartDevices(); } }