void ForkLiftDemo::specialKeyboardUp(int key, int x, int y) { switch (key) { case GLUT_KEY_UP : { lockForkSlider(); gEngineForce = 0.f; gBreakingForce = defaultBreakingForce; break; } case GLUT_KEY_DOWN : { lockForkSlider(); gEngineForce = 0.f; gBreakingForce = defaultBreakingForce; break; } case GLUT_KEY_LEFT: case GLUT_KEY_RIGHT: { lockLiftHinge(); break; } default: DemoApplication::specialKeyboardUp(key,x,y); break; } }
bool Hinge2Vehicle::keyboardCallback(int key, int state) { bool handled = false; bool isShiftPressed = m_guiHelper->getAppInterface()->m_window->isModifierKeyPressed(B3G_SHIFT); if (state) { if (isShiftPressed) { switch (key) { case B3G_LEFT_ARROW : { m_liftHinge->setLimit(-M_PI/16.0f, M_PI/8.0f); m_liftHinge->enableAngularMotor(true, -0.1, maxMotorImpulse); handled = true; break; } case B3G_RIGHT_ARROW : { m_liftHinge->setLimit(-M_PI/16.0f, M_PI/8.0f); m_liftHinge->enableAngularMotor(true, 0.1, maxMotorImpulse); handled = true; break; } case B3G_UP_ARROW : { m_forkSlider->setLowerLinLimit(0.1f); m_forkSlider->setUpperLinLimit(3.9f); m_forkSlider->setPoweredLinMotor(true); m_forkSlider->setMaxLinMotorForce(maxMotorImpulse); m_forkSlider->setTargetLinMotorVelocity(1.0); handled = true; break; } case B3G_DOWN_ARROW : { m_forkSlider->setLowerLinLimit(0.1f); m_forkSlider->setUpperLinLimit(3.9f); m_forkSlider->setPoweredLinMotor(true); m_forkSlider->setMaxLinMotorForce(maxMotorImpulse); m_forkSlider->setTargetLinMotorVelocity(-1.0); handled = true; break; } } } else { switch (key) { case B3G_LEFT_ARROW : { handled = true; gVehicleSteering += steeringIncrement; if ( gVehicleSteering > steeringClamp) gVehicleSteering = steeringClamp; break; } case B3G_RIGHT_ARROW : { handled = true; gVehicleSteering -= steeringIncrement; if ( gVehicleSteering < -steeringClamp) gVehicleSteering = -steeringClamp; break; } case B3G_UP_ARROW : { handled = true; gEngineForce = maxEngineForce; gBreakingForce = 0.f; break; } case B3G_DOWN_ARROW : { handled = true; gEngineForce = -maxEngineForce; gBreakingForce = 0.f; break; } case B3G_F7: { handled = true; btDiscreteDynamicsWorld* world = (btDiscreteDynamicsWorld*)m_dynamicsWorld; world->setLatencyMotionStateInterpolation(!world->getLatencyMotionStateInterpolation()); printf("world latencyMotionStateInterpolation = %d\n", world->getLatencyMotionStateInterpolation()); break; } case B3G_F6: { handled = true; //switch solver (needs demo restart) useMCLPSolver = !useMCLPSolver; printf("switching to useMLCPSolver = %d\n", useMCLPSolver); delete m_solver; if (useMCLPSolver) { btDantzigSolver* mlcp = new btDantzigSolver(); //btSolveProjectedGaussSeidel* mlcp = new btSolveProjectedGaussSeidel; btMLCPSolver* sol = new btMLCPSolver(mlcp); m_solver = sol; } else { m_solver = new btSequentialImpulseConstraintSolver(); } m_dynamicsWorld->setConstraintSolver(m_solver); //exitPhysics(); //initPhysics(); break; } case B3G_F5: handled = true; m_useDefaultCamera = !m_useDefaultCamera; break; default: break; } } } else { switch (key) { case B3G_UP_ARROW: { lockForkSlider(); gEngineForce = 0.f; gBreakingForce = defaultBreakingForce; handled=true; break; } case B3G_DOWN_ARROW: { lockForkSlider(); gEngineForce = 0.f; gBreakingForce = defaultBreakingForce; handled=true; break; } case B3G_LEFT_ARROW: case B3G_RIGHT_ARROW: { lockLiftHinge(); handled=true; break; } default: break; } } return handled; }