void
dmz::ObjectModuleGridBasic::_init (Config &local) {

   _xCoordMax = config_to_int32 ("grid.cell.x", local, _xCoordMax);
   _yCoordMax = config_to_int32 ("grid.cell.y", local, _yCoordMax);
   _minGrid = config_to_vector ("grid.min", local, _minGrid);
   _maxGrid = config_to_vector ("grid.max", local, _maxGrid);

   _log.info << "grid: " << _xCoordMax << "x" << _yCoordMax << endl;
   _log.info << "extents:" << endl
      << "\t" << _minGrid << endl
      << "\t" << _maxGrid << endl;

   Vector vec (_maxGrid - _minGrid);
   _xCellSize = vec.get (_primaryAxis) / (Float64)(_xCoordMax);
   _yCellSize = vec.get (_secondaryAxis) / (Float64)(_yCoordMax);

   _log.info << "cell count: " << _xCoordMax * _yCoordMax << endl;

   if (is_zero64 (_xCellSize)) { _xCellSize = 1.0; }
   if (is_zero64 (_yCellSize)) { _yCellSize = 1.0; }

   _grid = new GridStruct[_xCoordMax * _yCoordMax];

   activate_default_object_attribute (
      ObjectCreateMask | ObjectDestroyMask | ObjectPositionMask);
}
void
dmz::RenderModuleCoreOSGBasic::_init (Config &local, Config &global) {

   const String UpStr = config_to_string ("osg-up.value", local, "y").to_lower ();
   if (UpStr == "y") { set_osg_y_up (); _log.info << "OSG render Y is up." << endl; }
   else if (UpStr == "z") { set_osg_z_up (); _log.info << "OSG render Z is up" << endl; }
   else {

      _log.warn << "Unknown osg up type: " << UpStr << ". Defaulting to Y up." << endl;
   }

   Config pluginList;

   if (local.lookup_all_config ("plugin-list.plugin", pluginList)) {

      RuntimeContext *context (get_plugin_runtime_context ());

      if (dmz::load_plugins (context, pluginList, local, global, _extensions, &_log)) {

         _extensions.discover_plugins ();
         _extensions.discover_external_plugin (this);
      }
   }

   osgDB::Registry *reg = osgDB::Registry::instance ();
   Config pathList;

   if (reg && local.lookup_all_config ("loader.path", pathList)) {

      osgDB::FilePathList &fpl = reg->getLibraryFilePathList ();

      ConfigIterator it;
      Config path;

      while (pathList.get_next_config (it, path)) {

         String pathStr = config_to_string ("value", path);

         if (get_absolute_path (pathStr, pathStr)) {

            fpl.push_back (pathStr.get_buffer ());
         }
      }

   }

   if(reg) {

      reg->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
   }

   _defaultHandle = activate_default_object_attribute (
      ObjectDestroyMask | ObjectPositionMask | ObjectScaleMask | ObjectOrientationMask);

   _bvrHandle = config_to_named_handle (
      "bounding-volume-radius-attribute.name",
      local,
      ObjectAttributeBoundingVolumeRaidusName,
      get_plugin_runtime_context ());
}
void
dmz::QtPluginCanvasObjectBasic::_init (Config &local) {

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

   _defaultAttributeHandle = activate_default_object_attribute (
      ObjectCreateMask | ObjectDestroyMask);

   const String StateAttrName (
      config_to_string ("attribute.state.name", local, ObjectAttributeDefaultName));

   _stateAttributeHandle = activate_object_attribute (StateAttrName, ObjectStateMask);
   _zValue = config_to_int32 ("defaults.zValue", local, _zValue);

   _itemIgnoresTransformations = config_to_boolean (
      "defaults.itemIgnoresTransformations",
      local,
      _itemIgnoresTransformations);

   Config templ;
   if (local.lookup_all_config ("template", templ)) {

      ConfigIterator it;
      Config objTemplate;
      while (templ.get_next_config (it, objTemplate)) {

         String templateName = config_to_string ("name", objTemplate, "");
         Config *config = new Config (objTemplate);
         if (templateName != "" && config && *config &&
            _templateConfigTable.store (templateName, config)) {}
         else { delete config; config = 0; }
      }
   }
}
void
dmz::RenderPluginObjectLoaderOSG::_init (Config &local) {

   activate_default_object_attribute (ObjectDestroyMask);

   _modelAttrHandle = activate_object_attribute (
      config_to_string ("attribute.model.name", local, "Object_Model_Attribute"),
      ObjectTextMask |
      ObjectRemoveAttributeMask);
}
void
dmz::QtPluginCanvasObject::_init (Config &local, Config &global) {

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

   Config pluginList;

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

      RuntimeContext *context (get_plugin_runtime_context ());

      if (dmz::load_plugins (context, pluginList, local, global, _extensions, &_log)) {

         _extensions.discover_plugins ();
      }
   }

   _defaultAttributeHandle = activate_default_object_attribute (
      ObjectCreateMask |
      ObjectDestroyMask |
      ObjectPositionMask |
      ObjectOrientationMask);

   _linkAttributeHandle = activate_object_attribute (
      ObjectAttributeLayerLinkName,
      ObjectLinkMask | ObjectUnlinkMask);

#if 0
   Config preLoadList;

   if (local.lookup_all_config ("preload", preLoadList)) {

      Config data;
      ConfigIterator it;

      Boolean done (!preLoadList.get_first_config (it, data));

      while (!done) {

         ObjectType objType;
         Mask objState;

         if (_defs.lookup_object_type (config_to_string ("type", data), objType)) {

            _defs.lookup_state (config_to_string ("state", data), objState);

            _log.info << "Pre-Loading object of type: " << objType.get_name () << endl;
            _get_model_struct (objType, objState);
         }

         done = !preLoadList.get_next_config (it, data);
      }
   }
#endif
}
void
dmz::MBRAPluginArchiveSupport::_init (Config &local) {

    RuntimeContext *context = get_plugin_runtime_context ();

    init_archive (local);

    _defaultAttrHandle = activate_default_object_attribute (ObjectCreateMask);

    _ecAttrHandle = activate_object_attribute (
                        config_to_string ("elimination-cost.name", local, "NA_Node_Elimination_Cost"),
                        ObjectScalarMask);

    _typeSet = config_to_object_type_set ("object-type-list", local, context);

    if (_typeSet.get_count () == 0) {

        _typeSet.add_object_type ("na_node", context);
    }

    _toggleMapMessage = config_create_message (
                            "message.toggle-map.name",
                            local,
                            "ToggleMapMessage",
                            context,
                            &_log);

    _threatAttrHandle = config_to_named_handle (
                            "threat.name",
                            local,
                            "NA_Node_Threat",
                            context);

    _vulAttrHandle = config_to_named_handle (
                         "vulnerability.name",
                         local,
                         "NA_Node_Vulnerability",
                         context);

    _pcAttrHandle = config_to_named_handle (
                        "prevention-cost.name",
                        local,
                        "NA_Node_Prevention_Cost",
                        context);


    _toggleHandle = config_to_named_handle ("toggle.name", local, "toggle", context);

    _toggleTargetHandle = config_to_named_handle (
                              "toggle-target.name",
                              local,
                              "dmzQtPluginMapProperties",
                              context);
}
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);
}
Exemple #8
0
void
dmz::RenderPluginObjectOSG::_init (Config &local) {

   activate_default_object_attribute (
      ObjectCreateMask |
      ObjectDestroyMask |
      ObjectStateMask);

   activate_object_attribute (
      config_to_string ("hide-object-flag.name", local, ObjectAttributeHideName),
      ObjectFlagMask);

}
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::EntityPluginDetach::_init (Config &local) {

   _attachMsg = config_create_message (
      "attach-message.name",
      local,
      EntityMessageAttachName,
      get_plugin_runtime_context ());

   subscribe_to_message (_attachMsg);

   activate_default_object_attribute (ObjectDestroyMask);
}
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 ()));
}
void
dmz::EntityPluginOverlayDead::_init (Config &local) {

   Definitions defs (get_plugin_runtime_context (), &_log);

   defs.lookup_state (DefaultStateNameDead, _deadState);

   activate_default_object_attribute (ObjectStateMask);

   _hilAttrHandle = activate_object_attribute (
      ObjectAttributeHumanInTheLoopName,
      ObjectFlagMask);

   _overlaySwitchName =
      config_to_string ("overlay.switch.name", local, _overlaySwitchName);

   _overlayScaleName = config_to_string ("overlay.scale.name", local, _overlayScaleName);
}
Exemple #13
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);
}
Exemple #14
0
dmz::AudioPluginObject::AudioPluginObject (
      const PluginInfo &Info,
      Config &local) :
      Plugin (Info),
      TimeSlice (Info),
      ObjectObserverUtil (Info, local),
      _log (Info),
      _defs (Info, &_log),
      _rc (Info),
      _audioMod (0),
      _defaultHandle (0) {

   _init (local);

   _defaultHandle = activate_default_object_attribute (
      ObjectCreateMask |
         ObjectDestroyMask |
         ObjectStateMask |
         ObjectPositionMask |
         ObjectVelocityMask);
}
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);
}
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);
}
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);
}
dmz::RenderModuleCoreOgreBasic::RenderModuleCoreOgreBasic (
      const PluginInfo &Info,
      Config &local,
      Config &global) :
      Plugin (Info),
      TimeSlice (Info),
      ObjectObserverUtil (Info, local),
      OSMSceneCallbacks (),
      RenderModuleCoreOgre (Info),
      _log (Info),
      _extensions (),
      _objectModule (0),
      _defaultAttributeHandle (0),
      _ogreLogger (get_plugin_runtime_context ()),
      _root (0),
      _sceneManager (0),
      _osmSceneLoader (0),
      _portalTable (),
      _dynamicObjectTable () {

   _init (local, global);

   activate_default_object_attribute (ObjectPositionMask | ObjectOrientationMask);
}
Exemple #19
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);

}
Exemple #20
0
void
dmz::QtPluginGraph::_init (Config &local) {

    RuntimeContext *context (get_plugin_runtime_context ());
    Definitions defs (context);

    _scene = new QGraphicsScene;
    _view = new QGraphicsView (_scene);
    _view->setAlignment (Qt::AlignLeft); // | Qt::AlignBottom);

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

    if (_typeSet.get_count () == 0) {

        _log.info << "No object types specified. Using root type." << endl;
        _typeSet.add_object_type (defs.get_root_object_type ());
    }

    activate_default_object_attribute (ObjectCreateMask | ObjectDestroyMask);

    Config attrList;

    if (local.lookup_all_config ("attribute", attrList)) {

        ConfigIterator it;

        Config attr;

        while (attrList.get_next_config (it, attr)) {

            const String Type = config_to_string ("type", attr).get_lower ();
            const String AttrName = config_to_string ("name", attr);

            if (AttrName) {

                if (Type == "link") {

                    activate_object_attribute (AttrName, ObjectLinkMask | ObjectUnlinkMask);
                }
                else if (Type == "counter") {

                    activate_object_attribute (AttrName, ObjectCounterMask);
                }
                else {

                    _log.error << "Unknown attribute type: " << Type << endl;
                }
            }
            else {

                _log.error << "Attribute missing name." << endl;
            }
        }
    }

    _ascendingOrder = config_to_boolean ("ascending.value", local, _ascendingOrder);

    _maxCount = config_to_int32 ("start.value", local, _maxCount);

    _showPowerLaw = config_to_boolean ("power-law.show", local, _showPowerLaw);
    _powerStroke = config_to_qpen ("power-law.stroke", local, _powerStroke);
    _barStroke = config_to_qpen ("bar.stroke", local, _barStroke);
    _barFill = config_to_qbrush ("bar.fill", local, _barFill);
    _barWidth = config_to_int32 ("bar.width", local, _barWidth);
    _barHeight = config_to_int32 ("bar.height", local, _barHeight);
    _spaceWidth = config_to_int32 ("bar.space", local, _spaceWidth);
    _steps = config_to_int32 ("bar.steps", local, _steps);

    _yDivisions = config_to_int32 ("bar.divisions", local, _yDivisions);

    _yLabels = new QGraphicsTextItem*[_yDivisions];

    for (Int32 ix = 0; ix < _yDivisions; ix++) {

        const Float32 Offset (-_barHeight * ((Float32)(ix + 1)) / (Float32)_yDivisions);

        _yLabels[ix] = new QGraphicsTextItem;

        _yLabels[ix]->setPlainText (
            QString::number (100 * (ix +1) / _yDivisions) + QString ("%"));
        _yLabels[ix]->setZValue (1.0f);

        QRectF rect = _yLabels[ix]->boundingRect ();

        _yLabels[ix]->setPos (-5.0 - rect.width (), Offset - (rect.height () * 0.5f));

        _scene->addItem (_yLabels[ix]);

        QGraphicsLineItem *line = new QGraphicsLineItem (-4.0, Offset, 0.0f, Offset);
        line->setZValue (1.0f);

        _scene->addItem (line);
    }
}
void
dmz::RenderPluginDisableObjectIsect::_init (Config &local) {

   activate_default_object_attribute (ObjectCreateMask);
}
void
dmz::QtPluginCanvasLink::_init (Config &local) {

   RuntimeContext *context = get_plugin_runtime_context ();

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

   const String PosAttrName (
      config_to_string ("attribute.position.name", local, ObjectAttributeDefaultName));

   _defaultAttrHandle = activate_default_object_attribute (ObjectStateMask);

   _positionAttrHandle = activate_object_attribute (
      PosAttrName,
      ObjectPositionMask);

   const String FlowAttrName = config_to_string ("flow-attribute.name", local);

   if (FlowAttrName) {

      _flowAttrHandle = activate_object_attribute (FlowAttrName, ObjectStateMask);
   }

   _defs.lookup_state (
      config_to_string ("forward-flow-state.name", local),
      _forwardState);

   _defs.lookup_state (
      config_to_string ("reverse-flow-state.name", local),
      _reverseState);

   _flowStateMask = _forwardState | _reverseState;

   Handle attrHandle = activate_object_attribute (
     config_to_string ("link.name", local, ObjectAttributeNodeLinkName),
     ObjectLinkMask | ObjectUnlinkMask | ObjectLinkAttributeMask);

   _linkAttrTable.store (attrHandle, this);

   Config colorList;

   if (local.lookup_all_config ("state-color-list.state-color", colorList)) {

      QColor defaultColor (Qt::black);
      defaultColor.setAlphaF (0.75);

      ConfigIterator it;
      Config color;

      while (colorList.get_prev_config (it, color)) {

         const Mask State = config_to_state ("name", color, context);
         const QColor Value = config_to_qcolor (color, defaultColor);

         if (State) {

            ColorStruct *cs = new ColorStruct (State, Value);
            if (cs) { cs->next = _stateList; _stateList = cs; }
         }
      }
   }

   _penWidth = config_to_float32 ("pen-width.value", local, _penWidth);
   _arrowMultiplier = config_to_int32 ("arrow-multiplier.value", local, _arrowMultiplier);
}