Пример #1
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);
}
Пример #2
0
void
dmz::CyclesPluginGridOSG::_init (Config &local) {

    _imageResource = config_to_string ("image.resource", local, "grid");

    _tileSize = config_to_float64 ("tile.size", local, _tileSize);
    _minGrid = config_to_float64 ("tile.min", local, _minGrid);
    _maxGrid = config_to_float64 ("tile.max", local, _maxGrid);
}
Пример #3
0
/*!

\brief Converts Config to Matrix.
\details Defined in dmzRuntimeConfigToMatrix.h.
This function assumes that the Matrix will be defined by nine attributes stored
in the config context. The nine attributes should be named "v0" to "v8".
This function \b is case sensitive. The \a Name value may be scoped. For example:
\code
const dmz::Matrix DefaultValue; // Identity matrix.
dmz::Matrix value = dmz::config_to_matrix ("dmz.values.rotation", global, DefaultValue);
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] DefaultValue Matrix containing default value to use if config context is
not found.
\return Returns dmz::Matrix containing value.

*/
dmz::Matrix
dmz::config_to_matrix (
      const String &Name,
      const Config &Source,
      const Matrix &DefaultValue) {

   Config cd;

   if (Name) { Source.lookup_config (Name, cd); }
   else { cd = Source; }

   Float64 inPack[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
   DefaultValue.to_array (inPack);

   Float64 outPack[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};

   outPack[0] = config_to_float64 ("v0", cd, inPack[0]),
   outPack[1] = config_to_float64 ("v1", cd, inPack[1]);
   outPack[2] = config_to_float64 ("v2", cd, inPack[2]);
   outPack[3] = config_to_float64 ("v3", cd, inPack[3]);
   outPack[4] = config_to_float64 ("v4", cd, inPack[4]);
   outPack[5] = config_to_float64 ("v5", cd, inPack[5]);
   outPack[6] = config_to_float64 ("v6", cd, inPack[6]);
   outPack[7] = config_to_float64 ("v7", cd, inPack[7]);
   outPack[8] = config_to_float64 ("v8", cd, inPack[8]);

   const Matrix Result (outPack);
   return Result;
}
Пример #4
0
/*!

\brief Converts Config to Vector.
\details Defined in dmzRuntimeConfigToVector.h.
This function assumes that the Vector will be defined by three attributes stored
in the config context. The three attributes should be named "x", "y", and "z".
This function \b is case sensitive. The name value may be scoped. For example:
\code
const dmz::Vector DefaultValue;
dmz::Vector value = dmz::config_to_vector ("dmz.values.vector", global, DefaultValue);
\endcode
\param[in] Name String containing name of config context to convert.
\param[in] Source Config containing config context to convert.
\param[in] DefaultValue Vector containing default value to use if the config context is
not found.
\return Returns dmz::Vector containing value.

*/
dmz::Vector
dmz::config_to_vector (
      const String &Name,
      const Config &Source,
      const Vector &DefaultValue) {

   Config cd;

   if (Name) { Source.lookup_config (Name, cd); }
   else { cd = Source; }

   const Vector Result (
      config_to_float64 ("x", cd, DefaultValue.get_x ()),
      config_to_float64 ("y", cd, DefaultValue.get_y ()),
      config_to_float64 ("z", cd, DefaultValue.get_z ()));

   return Result;
}
Пример #5
0
void
dmz::AudioPluginObject::_init_sound_struct (Config &data, SoundDefStruct &ss) {

   ss.activateName = _rc.find_file (config_to_string ("activate-resource", data));
   ss.deactivateName = _rc.find_file (config_to_string ("deactivate-resource", data));
   ss.loopName = _rc.find_file (config_to_string ("looped-resource", data));

   _lookup_sound_handles (ss);

   const String ScalarName (config_to_string ("scalar", data));

   if (ScalarName) {

      ss.scalarAttributeHandle = activate_object_attribute (ScalarName, ObjectScalarMask);
   }

   ss.offset = config_to_float64 ("offset", data, ss.offset);
   ss.scale = config_to_float64 ("scale", data, ss.scale);
   ss.relative = config_to_boolean ("relative", data, ss.relative);
}
Пример #6
0
void
dmz::WeaponPluginGravityBullet::_init (Config &local) {

   RuntimeContext *context (get_plugin_runtime_context ());

   _defaultHandle = activate_default_object_attribute (
      ObjectCreateMask | ObjectDestroyMask);

   _typeSet = config_to_object_type_set ("munitions", local, context);

   _defaultSpeed = config_to_float64 ("speed.value", local, _defaultSpeed);
}
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 ();
}
void
dmz::MBRAPluginFaultTreeAutoLayout::_init (Config &local) {

   const Mask EmptyMask;
   RuntimeContext *context = get_plugin_runtime_context ();

   _canvasModuleName = config_to_string ("module.canvas.name", local);

   _defaultAttrHandle = activate_default_object_attribute (EmptyMask);

   _activeAttrHandle = activate_object_attribute (
      config_to_string ("attribute.activate.name", local, "FT_Active_Fault_Tree"),
      ObjectFlagMask);

   _linkAttrHandle = activate_object_attribute (
      config_to_string ("attribute.link.name", local, "FT_Link"),
      ObjectLinkMask | ObjectUnlinkMask);

   _logicAttrHandle = config_to_named_handle (
      "attribute.logic.name", local, "FT_Logic_Link", context);

   _nameAttrHandle = config_to_named_handle (
      "attribute.threat.name", local, "FT_Name", context);

   _hideAttrHandle = config_to_named_handle (
      "attribute.hide.name", local, ObjectAttributeHideName, context);

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_object_type (
      config_to_string ("root.type", local, "ft_component_root"), _rootType);

   _rootText = config_to_string ("root.text", local, _rootText);

   _hOffset = config_to_float64 ("offset.horizontal", local, _hOffset);
   _vOffset = config_to_float64 ("offset.vertical", local, _vOffset);
}
Пример #10
0
void
dmz::EntityPluginDeadTimer::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);

   _defaultHandle =
      activate_default_object_attribute (ObjectDestroyMask | ObjectStateMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   set_time_slice_interval (
      config_to_float64 ("timer.value", local, get_time_slice_interval ()));
}
Пример #11
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 ();
   }

}
Пример #12
0
void
dmz::WeaponPluginFixedLauncher::_init (Config &local) {

   RuntimeContext *context (get_plugin_runtime_context ());

   Definitions defs (context, &_log);

   _defaultHandle = activate_default_object_attribute (
      ObjectStateMask);

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _deadState = config_to_state (
      "state.dead.value",
      local,
      DefaultStateNameDead,
      context);

   _delay = config_to_float64 ("delay.value", local, _delay);
   _launcherOffset = config_to_vector ("offset", local);
   const Vector HPR = config_to_vector ("rotation", local);

   _launcherRotation.roll_in_place (HPR.get_z ());
   _launcherRotation.pitch_in_place (HPR.get_x ());
   _launcherRotation.yaw_in_place (HPR.get_y ());

   _launchButton = config_to_uint32 ("button.value", local, _launchButton);

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

}
void
dmz::EntityPluginGroundSimple::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);
   defs.lookup_state (DefaultStateNameAirBorn, _airBornState);

   _defaultHandle = activate_default_object_attribute (ObjectStateMask);

   _hilHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _throttleHandle = activate_object_attribute (
      ObjectAttributeScalarThrottleName,
      ObjectScalarMask);

   _move.maxSpeed = config_to_float64 ("movement.speed", local, _move.maxSpeed);
   _move.maxAccel = config_to_float64 ("movement.acceleration", local, _move.maxAccel);
   _move.maxDecel = config_to_float64 ("movement.deceleration", local, _move.maxDecel);
   _move.turnRate = config_to_float64 ("movement.turn", local, _move.turnRate);
   _move.brakeRate = config_to_float64 ("movement.brake", local, _move.brakeRate);
   _move.whiskerLength = config_to_float64 ("whisker.length", local, _move.whiskerLength);
   _move.whiskerHeight = config_to_float64 ("whisker.height", local, _move.whiskerHeight);

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

   _isectParameters.set_test_result_type (IsectAllPoints);
   _isectParameters.set_calculate_normal (True);
   _isectParameters.set_calculate_object_handle (True);
   _isectParameters.set_calculate_distance (False);
   _isectParameters.set_calculate_cull_mode (True);
}
Пример #14
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;
}
Пример #15
0
void
dmz::RenderPluginWavesOSG::_init (Config &local) {

   activate_object_attribute (
      config_to_string ("wave-time.attribute", local, "DMZ_Wave_State_Time_Seed"),
      ObjectTimeStampMask);

   _waveSpeedAttributeHandle = activate_object_attribute (
      config_to_string ("wave-speed.attribute", local, "DMZ_Wave_State_Speed"),
      ObjectScalarMask);

   _waveAmplitudeAttributeHandle = activate_object_attribute (
      config_to_string ("wave-amplitude.attribute", local, "DMZ_Wave_State_Amplitude"),
      ObjectScalarMask);

   _waveNumberAttributeHandle = activate_object_attribute (
      config_to_string ("wave-number.attribute", local, "DMZ_Wave_State_Number"),
      ObjectScalarMask);

   _imageResource = config_to_string ("image.resource", local, "water");

   _tileCountX = config_to_int32 ("count.x", local, _tileCountX);
   _tileCountY = config_to_int32 ("count.y", local, _tileCountY);

   if (_tileCountX < 1) {

      _log.error << "Tile count in the X axis is: " << _tileCountX
         << " Value must be greater than zero. Setting to 1." << endl;

      _tileCountX = 1;
   }

   if (_tileCountY < 1) {

      _log.error << "Tile count in the Y axis is: " << _tileCountY
         << " Value must be greater than zero. Setting to 1." << endl;

      _tileCountY = 1;
   }

   _minGrid = config_to_float64 ("grid.min", local, _minGrid);
   _maxGrid = config_to_float64 ("grid.max", local, _maxGrid);

   if (_minGrid >= _maxGrid) {

      _log.error << "Minimum grid value must be less than the maximum grid value."
         << endl;

      _maxGrid = _minGrid + 1.0f;
   }

   _tileSizeX = (_maxGrid - _minGrid) / Float32 (_tileCountX);
   _tileSizeY = (_maxGrid - _minGrid) / Float32 (_tileCountY);

   Float32 &texA = (_tileCountY > _tileCountX ? _texFactorX : _texFactorY);
   Float32 &texB = (_tileCountY > _tileCountX ? _texFactorY : _texFactorX);

   texA = 1.0f;
   texB = ((_tileCountY > _tileCountX) ?
      (Float32 (_tileCountY) / Float32 (_tileCountX)) :
      (Float32 (_tileCountY) / Float32 (_tileCountX)));

   const Float32 FloorValue = floor (texB);
   if ((texB - FloorValue) > 0.5f) { texB = FloorValue + 1; }
   else { texB = FloorValue; }
}
Пример #16
0
void
dmz::EventModuleBasic::_init (Config &local) {

   _eventTTL = config_to_float64 ("ttl.value", local, 1.0);
   _maxEvents = config_to_int32 ("max.value", local, 0);
}
Пример #17
0
dmz::RenderPluginEventOSG::TypeStruct *
dmz::RenderPluginEventOSG::_create_type (
      const Handle EventHandle,
      const EventType &Event,
      const ObjectType &Object,
      TypeTable &table) {

   TypeStruct *result (0);

   Config info;

   Config list;

   if (Object.get_config ().lookup_all_config ("render.event", list)) {

      ConfigIterator it;
      Config next;

      const String EventName = Event.get_name ();

      while (!info && list.get_next_config (it, next)) {

         if (EventName == config_to_string ("name", next)) { info = next; }
      }
   }

   if (info) {

      const String ImageRc = config_to_string ("image.resource", info);
      const Float64 Offset = config_to_float64 ("offset.value", info, 10);
      const Float64 Scale = config_to_float64 ("scale.value", info, 1.1);
      const Float64 Rate = config_to_float64 ("rate.value", info, 0.1);

      if (ImageRc) {

         const String ImageName = _rc.find_file (ImageRc);

         if (ImageName) {

            result = new TypeStruct (Offset, Scale, Rate);

            if (result) {

               result->image = osgDB::readImageFile (ImageName.get_buffer ());

               if (result->image.valid ()) {

                  if (table.table.store (Object.get_handle (), result)) {

                     _create_model (*result);
                     table.map.store (Object.get_handle (), result);
                  }
                  else { delete result; result = 0; }
               }
               else {

                  _log.error << "Failed to load image resource: " << ImageRc
                     << " -> " << ImageName << endl;
                  _ignore.add (Object.get_handle ());
               }
            }
         }
         else {

            _log.error << "Failed to find image resource: " << ImageRc << endl;
            _ignore.add (Object.get_handle ());
         }
      }
   }

   return result;
}