示例#1
0
// Event Observer Interface
void
dmz::AudioPluginEventSimple::close_event (
      const Handle EventHandle,
      const EventType &Type,
      const EventLocalityEnum Locality) {

   EventType current (Type);
   EventStruct *es (0);

   while (!es && current) {

      es = _eventTable.lookup (current.get_handle ());

      if (!es) { current.become_parent (); }
   }
  
   if (es && es->sound) {

      EventModule *eventMod (get_event_module ());

      if (_audioMod && eventMod) {

         Vector pos;

         if (eventMod->lookup_position (EventHandle, _defaultEventHandle, pos)) {

            SoundInit init;
            SoundAttributes attributes;
            attributes.set_position (pos);
            _audioMod->play_sound (es->sound, init, attributes);
         }
      }
   }
}
void
dmz::RenderPluginEventOSG::_create_event (const Handle EventHandle, TypeStruct &ts) {

   EventStruct *event = new EventStruct (ts);

   if (event) {

      event->root = new osg::AutoTransform ();
      event->root->setAutoRotateMode (osg::AutoTransform::ROTATE_TO_SCREEN);
      event->scale = new osg::MatrixTransform;
      event->root->addChild (event->scale);

      UInt32 mask = event->root->getNodeMask ();
      mask &= ~(_isectMask);
      event->root->setNodeMask (mask);

      EventModule *module = get_event_module ();

      if (module) {

         Vector pos;
         module->lookup_position (EventHandle, _defaultHandle, pos);
         event->root->setPosition (to_osg_vector (pos));
      }

      event->scale->addChild (ts.model.get ());

      if (_eventTable.store (EventHandle, event)) {

         osg::Group *group = _core ? _core->get_dynamic_objects () : 0;

         if (group) { group->addChild (event->root.get ()); }
         else { _log.error << "Failed to add geode!" << endl; }
      }
      else { delete event; event = 0; }
   }
}