Ejemplo n.º 1
0
void
dmz::NetExtPacketCodecObjectNative::_init (Config &local) {

   RuntimeContext *context (get_plugin_runtime_context ());
   Definitions defs (context, &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
   _lnvHandle = defs.create_named_handle (ObjectAttributeLastNetworkValueName);

   Config adapters;
   ObjectAttributeAdapter *current (0);

   if (local.lookup_all_config ("adapter", adapters)) {

      ConfigIterator it;
      Config data;

      while (adapters.get_next_config (it, data)) {

         ObjectAttributeAdapter *next (create_object_adapter (data, context, _log));

         if (next) {

            if (current) { current->next = next; current = next; }
            else { _adapterList = current = next; }
         }
      }
   }
}
void
dmz::EntityPluginPortalFollow3D::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   Boolean foundOffset (False);

   Config cameraParams;

   if (local.lookup_config ("offset", cameraParams)) {

      foundOffset = True;

      _offset = config_to_vector (cameraParams, _offset);
   }

   init_input_channels (local, InputEventChannelStateMask, &_log);

   _log.info << "Using " << (foundOffset ? "" : "default ") << "camera offset: "
      << _offset << endl;
}
Ejemplo n.º 3
0
void
dmz::EntityPluginFreeFly::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _move.moveSpeed = config_to_float64 ("movement.speed", local, _move.moveSpeed);
   _move.turnRate = config_to_float64 ("movement.turn-rate", local, _move.turnRate);

   init_input_channels (
      local,
      InputEventButtonMask | InputEventAxisMask | InputEventChannelStateMask,
      &_log);

   _isectParameters.set_test_result_type (IsectClosestPoint);
   _isectParameters.set_calculate_normal (False);
   _isectParameters.set_calculate_object_handle (False);
   _isectParameters.set_calculate_distance (True);
   _isectParameters.set_calculate_cull_mode (False);
}
Ejemplo n.º 4
0
void
dmz::EventModuleCommonBasic::_init (Config &local) {

   RuntimeContext *context (get_plugin_runtime_context ());
   Definitions defs (context, &_log);

   _defaultObjectHandle = defs.create_named_handle (ObjectAttributeDefaultName);
   _defaultEventHandle = defs.create_named_handle (EventAttributeDefaultName);

   _sourceHandle = defs.create_named_handle (EventAttributeSourceName);
   _targetHandle = defs.create_named_handle (EventAttributeTargetName);
   _munitionsHandle = defs.create_named_handle (EventAttributeMunitionsName);

   defs.lookup_event_type (EventLaunchName, _launchType);
   defs.lookup_event_type (EventDetonationName, _detonationType);
   defs.lookup_event_type (EventCollisionName, _collisionType);
}
Ejemplo n.º 5
0
void
dmz::RenderModuleCoreOgreBasic::_init (Config &local, Config &global) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultAttributeHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   Config pluginList;

   if (local.lookup_all_config ("plugins.plugin", pluginList)) {

      RuntimeContext *context (get_plugin_runtime_context ());
      dmz::load_plugins (context, pluginList, local, global, _extensions, &_log);
   }
   else {

   }

   Config ogreLocal;

   if (local.lookup_config ("ogre", ogreLocal)) {

      try {

         _init_root (ogreLocal);
         _init_resources (ogreLocal);
         _init_render_system (ogreLocal);
         _init_render_windows ();

         Ogre::ResourceGroupManager::getSingleton ().initialiseAllResourceGroups ();

         _init_scene_manager (ogreLocal);
      }
      catch (Ogre::Exception e) {

         if (_root) {

            if (_sceneManager) {

               _root->destroySceneManager (_sceneManager);
               _sceneManager = 0;
            }

            delete _root;
            _root = 0;
         }

         _log.error << e.getFullDescription ().c_str () << endl;
      }
   }
   else {

   }

   _extensions.discover_plugins ();
}
Ejemplo n.º 6
0
void
dmz::LuaExtObject::_init (Config &local) {

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   Definitions defs (get_plugin_runtime_context ());

   _obj.defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
}
void
dmz::EntityPluginRestoreHealth::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context ());

   defs.lookup_state (DefaultStateNameDead, _dead);

   _healthAttrHandle = defs.create_named_handle (EntityAttributeHealthName);

   _defaultAttrHandle = activate_default_object_attribute (ObjectStateMask);

   _health = config_to_float64 ("health.value", local, _health);
}
void
dmz::StarfighterPluginSpaceBoxOSG::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context ());

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   _imgRc = config_to_string ("image.resource", local, _imgRc);
   _offset = config_to_float64 ("box.offset", local, _offset);

   activate_object_attribute (ObjectAttributeHumanInTheLoopName, ObjectFlagMask);

   _create_box ();
}
Ejemplo n.º 9
0
void
dmz::RenderExtViewerOSG::discover_plugin (
      const PluginDiscoverEnum Mode,
      const Plugin *PluginPtr) {

   if (Mode == PluginDiscoverAdd) {

      if (!_core) {

         _core = RenderModuleCoreOSG::cast (PluginPtr);
         if (_core) {

            osg::ref_ptr<osg::Group> scene = _core->get_scene ();

            if (scene.valid ()) { _viewer->setSceneData (scene.get ()); }

            _core->add_viewer (_viewerName, _viewer.get ());
         }
      }

      if (!_channels) {

         _channels = InputModule::cast (PluginPtr);
         if (_channels) {

            Definitions defs (get_plugin_runtime_context (), &_log);
            const Handle SourceHandle = defs.create_named_handle (_viewerName);
            _eventHandler->set_input_module_channels (_channels, SourceHandle);
         }
      }
   }
   else if (Mode == PluginDiscoverRemove) {

      if (_core && (_core == RenderModuleCoreOSG::cast (PluginPtr))) {

         _core->remove_viewer (_viewerName);
         osg::ref_ptr<osg::Group> scene = new osg::Group;
         if (scene.valid ()) { _viewer->setSceneData (scene.get ()); }
         _core = 0;
      }

      if (_channels && (_channels == InputModule::cast (PluginPtr))) {

         _eventHandler->set_input_module_channels (0, 0);
         _channels = 0;
      }
   }
}
Ejemplo n.º 10
0
void
dmz::EntityPluginDamage::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _targetHandle = defs.create_named_handle (EventAttributeTargetName);

   const String StateNames = config_to_string ("state.name", local, DefaultStateNameDead);

   defs.lookup_state (StateNames, _deadState);

   _defaultObjectHandle = activate_default_object_attribute (ObjectDestroyMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _detonationType = activate_event_callback (EventDetonationName, EventCloseMask);
}
Ejemplo n.º 11
0
/*!

\brief Converts Config to name Handle.
\details Defined in dmzRuntimeConfigToNamedHandle.h.
This function converts the named attribute to a named Handle It is assumed that the
last part of the \a Name variable specifies the attribute name. If the String
"type.name" is passed in as \a Name, it will try to find a  config context called
"type" and the attribute "name" stored in the "type" config context.
\code
dmz::Handle handle = dmz::config_to_named_handle ("dmz.handle.name", global, get_plugin_runtime_context (), "DefaultHandleName");
\endcode
\param[in] Name String containing name of the attribute in the config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] DefaultValue String containing name of handle if not found in the Config.
\param[in] context Pointer to the runtime context.
\return Returns dmz::Handle containing the named Handle. Returns a zero handle if no
name is given.

*/
dmz::Handle
dmz::config_to_named_handle (
      const String &Name,
      const Config &Source,
      const String &DefaultValue,
      RuntimeContext *context) {

   Handle result (0);

   const String HandleName (config_to_string (Name, Source, DefaultValue));

   if (HandleName) {

      Definitions defs (context);

      result = defs.create_named_handle (HandleName);
   }

   return result;
}
Ejemplo n.º 12
0
void
dmz::CyclesPluginWallOSG::_init (Config &local) {

   activate_default_object_attribute (
      ObjectDestroyMask |
      ObjectPositionMask |
      ObjectVelocityMask |
      ObjectStateMask);

   Definitions defs (get_plugin_runtime_context ());

   defs.lookup_state (
      config_to_string ("state.dead", local, DefaultStateNameDead),
      _deadState);

   defs.lookup_state (
      config_to_string ("state.engine_on", local, "Engine_On"),
      _engineOnState);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
}
Ejemplo n.º 13
0
void
dmz::InputPluginChannelSwitch::_init (Config &local) {

   Config list;

   if (local.lookup_all_config ("channel", list)) {

      Definitions defs (get_plugin_runtime_context (), &_log);

      const Mask EmptyMask;

      ConfigIterator it;

      Config data;

      ChannelStruct *current (0);

      Boolean found (list.get_first_config (it, data));

      while (found)  {

         const String Name = config_to_string ("name", data);

         if (Name) {

            ChannelStruct *next (new ChannelStruct (defs.create_named_handle (Name)));

            if (next) {

               if (current) { current->next = next; current = next; }
               else { _list = current = next; }
            }
         }

         found = list.get_next_config (it, data);
      }

      activate_default_input_channel (InputEventKeyMask);
   }
}
void
dmz::ForgePluginScreenCaptureMulti::_init (Config &local) {

   RuntimeContext *context = get_plugin_runtime_context ();

   Definitions defs (context, &_log);

   _defaultAttrHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   _attachMsg = config_create_message (
      "attach-message.name",
      local,
      "DMZ_Entity_Attach_Message",
      context);

   subscribe_to_message (_attachMsg);

   _startCaptureMsg = config_create_message (
      "start-screen-capture-message.name",
      local,
      "Start_Screen_Capture_Message",
      context);

   subscribe_to_message (_startCaptureMsg);

   _doCaptureMsg = config_create_message (
      "screen-capture-message.name",
      local,
      "Capture_Render_Screen_Message",
      context);

   _finishedCaptureMsg = config_create_message (
      "finished-screen-capture-message.name",
      local,
      "Finished_Screen_Capture_Message",
      context);

   _maxFiles = config_to_int32 ("max-files.value", local, _maxFiles);
   _maxLength = String::number (_maxFiles).get_length ();
}
Ejemplo n.º 15
0
void
dmz::ArchivePluginAutoSave::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context ());

   _saveFile = config_to_string ("save.file", local, _appState.get_autosave_file ());

   if (_saveFile) {

      set_time_slice_interval (
         config_to_float64 ("save.rate", local, get_time_slice_interval ()));

      _archiveHandle = defs.create_named_handle (
         config_to_string ("archive.name", local, ArchiveDefaultName));
   }
   else {

      _log.warn << "No auto save file specified. Auto save disabled." << endl;
      stop_time_slice ();
   }

}
Ejemplo n.º 16
0
/*!

\brief Converts Config to a HandleContainer.
\details Defined in dmzRuntimeConfigToNamedHandle.h.
\code
dmz::HandleContainer value = dmz::config_to_handle_container ("dmz.handle", global);
\endcode
The Config for the above example would be formatted as follows:
\code
<dmz>
   <handle name="dmzToolPluginFoo"/>
   <handle name="dmzToolPluginBar"/>
</dmz>
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] context Pointer to the runtime context.
\return Returns dmz::HandleContainer of the named Handle values.

*/
dmz::HandleContainer
dmz::config_to_handle_container (
      const String &Name,
      const Config &Source,
      RuntimeContext *context) {

   HandleContainer result;
   Definitions defs (context);

   Config nameList;

   if (Name) { Source.lookup_all_config (Name, nameList); }
   else { Source.lookup_all_config ("handle", nameList); }

   ConfigIterator it;
   Config name;

   while (nameList.get_next_config (it, name)) {

      result.add (defs.create_named_handle (config_to_string ("name", name)));
   }

   return result;
}
Ejemplo n.º 17
0
void
dmz::NetModuleLocalDRBasic::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);

   Config defaultList;

   _log.info << "Creating default network transmission rules." << endl;

   if (local.lookup_all_config_merged ("default", defaultList)) {

      _defaultTest = _create_update_list (defaultList);
   }
   else {

      _log.info << "Using default rules set." << endl;

      const Handle LNVHandle (defs.create_named_handle (
            ObjectAttributeLastNetworkValueName));

      const Handle AttributeHandle (defs.create_named_handle (
            ObjectAttributeDefaultName));

      ObjectUpdate *current = _defaultTest = new heartbeatTest (
         LNVHandle,
         _time,
         5.0);

      if (current) {

         const Mask EmptyState;

         current->next = new stateTest (
            LNVHandle,
            AttributeHandle,
            EmptyState);

         if (current->next) { current = current->next; }

         current->next = new zeroVelocityTest (
            LNVHandle,
            AttributeHandle);

         if (current->next) { current = current->next; }

         current->next = new limitRateTest (
            LNVHandle,
            _time,
            0.066666666667); // 1/15 of a second max update rate

         if (current->next) { current = current->next; }

         current->next = new posSkewTest (
            LNVHandle,
            AttributeHandle,
            _time,
            0.25);

         if (current->next) { current = current->next; }

         current->next = new oriTest (
            LNVHandle,
            AttributeHandle,
            Pi64 / 60.0); // 0.05235987756 == 3 degrees

         if (current->next) { current = current->next; }

         current->next = new scalarTest (
            defs.create_named_handle (
               create_last_network_value_name (ObjectAttributeScalarThrottleName)),
            defs.create_named_handle (ObjectAttributeScalarThrottleName),
            0.01);
      }
   }
}
Ejemplo n.º 18
0
void
dmz::NetExtPacketCodecObjectBasic::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultHandle = defs.create_named_handle (ObjectAttributeDefaultName);
   _lnvHandle = defs.create_named_handle (ObjectAttributeLastNetworkValueName);

   defs.lookup_state (
      config_to_string ("deactivate.name", local, DefaultStateNameDeactivate),
      _deactivateState);

   Config scalarData;

   if (local.lookup_all_config ("scalar", scalarData)) {

      ConfigIterator it;

      Config data;

      Boolean found (scalarData.get_first_config (it, data));

      while (found) {

         const String Name (config_to_string ("name", data));

         const String LNVName (
            config_to_string (
               "lnvname",
                data,
                create_last_network_value_name (Name)));

         const UInt32 Value (config_to_uint32 ("value", data));

         if (Name) {

            ScalarStruct *ss (new ScalarStruct (
               Value,
               defs.create_named_handle (Name),
               defs.create_named_handle (LNVName)));

            if (ss && !_scalarTable.store (ss->NetHandle, ss)) {

               delete ss; ss = 0;
            }
         }
         else {

         }

         found = scalarData.get_next_config (it, data);
      }
   }
   else {

      ScalarStruct *ss (
         new ScalarStruct (
            1,
            defs.create_named_handle (ObjectAttributeScalarThrottleName),
            defs.create_named_handle (
               create_last_network_value_name (ObjectAttributeScalarThrottleName))));

      if (ss && !_scalarTable.store (ss->NetHandle, ss)) { delete ss; ss = 0; }
   }
}
Ejemplo n.º 19
0
dmz::NetModuleLocalDRBasic::ObjectUpdate *
dmz::NetModuleLocalDRBasic::_create_update_list (Config &listData) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   ObjectUpdate *head (0), *current (0);

   ConfigIterator it;
   Config cd;

   while (listData.get_next_config (it, cd)) {

      ObjectUpdate *next (0);

      const String Type (config_to_string ("type", cd).to_lower ());

      const String AttributeName (
         config_to_string ("attribute", cd, ObjectAttributeDefaultName));

      const Handle AttributeHandle (defs.create_named_handle (AttributeName));

      const Handle LNVHandle (defs.create_named_handle (
         config_to_string (
            "lnv-attribute",
            cd,
            create_last_network_value_name (AttributeName))));

      if (Type == "position") {

         next = new vectorTest (
            TestPosition,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "velocity") {

         next = new vectorTest (
            TestVelocity,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "acceleration") {

         next = new vectorTest (
            TestAcceleration,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "vector") {

         next = new vectorTest (
            TestVector,
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "orientation") {

         next = new oriTest (
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "scalar") {

         next = new scalarTest (
            AttributeHandle,
            LNVHandle,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "counter") {

         next = new counterTest (AttributeHandle, LNVHandle);
      }
      else if (Type == "state") {

         Definitions defs (get_plugin_runtime_context (), &_log);

         Mask state;

         defs.lookup_state (config_to_string ("value", cd), state);

         next = new stateTest (AttributeHandle, LNVHandle, state);
      }
      else if (Type == "skew") {

         next = new posSkewTest (
            AttributeHandle,
            LNVHandle,
            _time,
            config_to_float64 ("value", cd, 0.25));
      }
      else if (Type == "heartbeat") {

         next = new heartbeatTest (
            LNVHandle,
            _time,
            config_to_float64 ("value", cd, 5.0));
      }
      else if (Type == "rate-limit") {

         next = new limitRateTest (
            LNVHandle,
            _time,
            // 1/15 of a second max update rate is the default.
            config_to_float64 ("value", cd, 0.066666666667));
      }

      if (next) {

         _log.info << "Adding rule: " << Type << endl;
         if (current) { current->next = next; current = next; }
         else { head = current = next; }
      }
   }

   return head;
}
Ejemplo n.º 20
0
void
dmz::AudioPluginEventSimple::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   _defaultEventHandle = defs.create_named_handle (EventAttributeDefaultName);

   Config eventList;

   if (local.lookup_all_config ("event-type", eventList)) {

      ConfigIterator it;
      Config event;

      while (eventList.get_next_config (it, event)) {

         const String EventTypeName = config_to_string ("name", event);
         const String FileName = _rc.find_file (config_to_string ("resource", event));

         if (FileName && EventTypeName) {

            EventStruct *es = new EventStruct (FileName);

            if (es) {

               es->event = activate_event_callback (EventTypeName, EventCloseMask);

               if (es->event) {

                  const Handle EventHandle (es->event.get_handle ());

                  if (!_eventTable.store (EventHandle, es)) {

                     delete es; es = 0;
                     es = _eventTable.lookup (EventHandle);

                     _log.error << "Unable to bind sound: " << FileName << " to event: "
                        << EventTypeName << " because file: "
                        << (es ? es->File : "<Unknown File>")
                        << " has already been bound to the event type" << endl;
                  }
               }
               else {

                  delete es; es = 0;

                  _log.error << "Unknown event type: " << EventTypeName << endl;
               }
            }
         }

         if (!FileName) {

            _log.error << "No audio file specified for event type: "
               << (EventTypeName ? EventTypeName : "<Unknown Type>") << endl;
         }

         if (!EventTypeName) {

            _log.error << "No event type specified for audio file: "
               << (FileName ? FileName : "<Unknown File>") << endl;
         }
      }
   }
}
Ejemplo n.º 21
0
/*!

\brief Converts Config to Data.
\details The named config context
will have children config contexts named "attribute". Each child config context
will have two attributes, one called "name" containing the name of the Data's attribute
and one called "type" containing the BaseTypeEnum of the Data's attribute.
Each "attribute" config context may contain one or more child config contexts.
Each one of these config contexts should have an attribute named "value" that contains
the value of the Data attribute. The order of these attributes is used to determine
the Data attributes element number. A Data object described in XML may look something
like this:
\code
<dmz>
<data>
   <attribute name="id" type="uint32">
      <element value="1"/>
      <element value="5"/>
      <element value="9"/>
      <element value="5"/>
   </attribute>
   <attribute name="position" type="float64">
      <element value="104.5"/>
      <element value="2045.4"/>
      <element value="5.1"/>
   </attribute>
</data>
</dmz>
\endcode
The Data object defined by the above XML may be created as follows:
\code
dmz::Data value;
dmz::config_to_data ("dmz.data", global, get_plugin_runtime_context (), value, &_log);
\endcode
\param[in] Name String containing name of the attribute in the config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] context Pointer to the runtime context.
\param[out] target Data object for to store the result.
\param[in] log Pointer to the dmz::Log to use for log reporting.
\return Returns dmz::True if the config context was successfully converted to a Data
object.
\sa dmz::runtime_init()

*/
dmz::Boolean
dmz::config_to_data (
      const String &Name,
      const Config &Source,
      RuntimeContext *context,
      Data &target,
      Log *log) {

   Boolean result (False);

   Config config (Source);

   if (Name) {

      if (!Source.lookup_config (Name, config)) {

         config.set_config_context (0);

         if (log) {

            log->error << "Unable to find Config definition of Data with name: "
               << Name << " while converting from Config to Data" << endl;
         }
      }
   }

   if (config) {

      result = True;

      Definitions defs (context);

      Config attrConfig;

      config.lookup_all_config ("attribute", attrConfig);

      ConfigIterator it;

      Config attr;

      Boolean found = attrConfig.get_first_config (it, attr);

      while (found) {

         String attrName;

         if (attr.lookup_attribute ("name", attrName)) {

            const UInt32 Handle (defs.create_named_handle (attrName));
            const BaseTypeEnum Type (
               config_to_base_type_enum ("type", attr, BaseTypeUnknown));

            if (Handle) {

               ConfigIterator attrIt;

               Config element;

               Boolean attrFound = attr.get_first_config (attrIt, element);

               UInt32 offset (0);

               while (attrFound) {

                  target.store_string (
                     Handle,
                     offset,
                     Type,
                     config_to_string ("value", element));

                  offset++;

                  attrFound = attr.get_next_config (attrIt, element);
               }
            }
            else if (log) {

               log->error << "Unable to create named handle: " << attrName
                  << " while converting form Config to Data" << endl;
            }
         }
         else if (log) {

            log->error << "Named handle not defined "
               << "while converting form Config to Data" << endl;
         }

         found = attrConfig.get_next_config (it, attr);
      }
   }

   return result;
}
Ejemplo n.º 22
0
   State (RuntimeContext *context) : handle (0)  {

      Definitions defs (context);
      handle = defs.create_named_handle ("handle");
   }
Ejemplo n.º 23
0
   State (RuntimeContext *context) : handle (0)  {

      Definitions defs (context);

      handle = defs.create_named_handle (base_type_enum_to_string (BaseTypeString));
   }