void HLCALLBACK buttonCB(HLenum event, HLuint object, HLenum thread, HLcache *cache, void *userdata) { if (event == HL_EVENT_1BUTTONDOWN) { HLuint spring = *((HLuint *) userdata); HDdouble anchor[3]; hlCacheGetDoublev(cache, HL_PROXY_POSITION, anchor); hlEffectd(HL_EFFECT_PROPERTY_GAIN, 0.8); hlEffectd(HL_EFFECT_PROPERTY_MAGNITUDE, 1.0); hlEffectdv(HL_EFFECT_PROPERTY_POSITION, anchor); hlStartEffect(HL_EFFECT_SPRING, spring); } else if (event == HL_EVENT_1BUTTONUP) { HLuint spring = *((HLuint *) userdata); hlStopEffect(spring); } else if (event == HL_EVENT_2BUTTONDOWN) { static const HDdouble direction[3] = { 0, 0, 1 }; static const HDdouble duration = 100; /* ms */ /* Trigger an impulse by commanding a force with a direction and magnitude for a small duration. */ hlEffectd(HL_EFFECT_PROPERTY_DURATION, duration); hlEffectd(HL_EFFECT_PROPERTY_MAGNITUDE, 0.8); hlEffectdv(HL_EFFECT_PROPERTY_DIRECTION, direction); hlTriggerEffect(HL_EFFECT_CONSTANT); } }
//******************************************************************************* void HapticEffect::triggerEffect( double duration ) { // Effekt für die Dauer duration (msec) anstoßen renderProperties(); hlEffectd(HL_EFFECT_PROPERTY_DURATION, duration); hlTriggerEffect(m_EffectType); }