// Message Observer Interface void dmz::ObjectPluginHighlight::receive_message ( const Message &Type, const UInt32 MessageSendHandle, const Handle TargetObserverHandle, const Data *InData, Data *outData) { if (Type.is_of_type (_mouseMoveMsg)) { const Handle Object = _convert.to_handle (InData); if (Object != _current) { ObjectModule *module = get_object_module (); if (module) { module->store_flag (_current, _highlightAttr, False); if (Object) { if (module->is_object (Object)) { _current = Object; module->store_flag (_current, _highlightAttr, True); } else if (module->is_link (Object)) { Handle attrObj = module->lookup_link_attribute_object (Object); if (attrObj) { _current = attrObj; module->store_flag (_current, _highlightAttr, True); } } } else { _current = 0; } } } } else if (Type.is_of_type (_deactivateMsg)) { if (_current) { ObjectModule *module = get_object_module (); if (module) { module->store_flag (_current, _highlightAttr, False); } _current = 0; } } }
// Plugin Interface void dmz::MBRAPluginNACalculate::update_plugin_state ( const PluginStateEnum State, const UInt32 Level) { if (State == PluginStateInit) { ObjectModule *objMod = get_object_module (); if (objMod && !_simulatorHandle) { _simulatorHandle = objMod->create_object (_simulatorType, ObjectLocal); objMod->activate_object (_simulatorHandle); } } else if (State == PluginStateStart) { } else if (State == PluginStateStop) { } else if (State == PluginStateShutdown) { } }
// Time Slice Interface void dmz::RenderModuleCoreOSGBasic::update_time_slice (const Float64 DeltaTime) { ObjectModule *objMod (get_object_module ()); while (_dirtyObjects) { ObjectStruct *os (_dirtyObjects); _dirtyObjects = os->next; os->transform->setMatrix (to_osg_matrix (os->ori, os->pos, os->scale)); if (objMod) { const osg::BoundingSphere &Bvs = os->transform->getBound (); const Float64 Radius = Bvs.radius (); objMod->store_scalar (os->Object, _bvrHandle, Radius); } if (os->destroyed) { if (_dynamicObjects.valid ()) { _dynamicObjects->removeChild (os->transform.get ()); } delete os; os = 0; } else { os->next = 0; os->dirty = False; } } }
void dmz::RenderPluginHighlightOSG::update_object_flag ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Boolean Value, const Boolean *PreviousValue) { ObjectModule *objMod = get_object_module (); if (_core && objMod) { osg::Group *group = _core->lookup_dynamic_object (ObjectHandle); if (group) { HighlightStruct *current = _highlightList; Boolean done (False); while (!done && current) { if (objMod->lookup_flag (ObjectHandle, current->Attribute)) { done = True; } else { current = current->next; } } if (current) { group->setStateSet (current->color.get ()); } else { group->setStateSet (0); } } } }
void dmz::WeaponPluginGravityBullet::_store_speed ( const Handle ObjectHandle, const ObjectType &Type) { Float64 *ptr (_speedTable.lookup (Type.get_handle ())); if (!ptr) { ptr = new Float64 (_defaultSpeed); if (ptr && !_speedTable.store (Type.get_handle (), ptr)) { delete ptr; ptr = 0; } } if (ptr) { _objectTable.store (ObjectHandle, ptr); ObjectModule *objMod (get_object_module ()); if (objMod) { Matrix ori; objMod->lookup_orientation (ObjectHandle, _defaultHandle, ori); Vector vel (0.0, 0.0, -(*ptr)); ori.transform_vector (vel); objMod->store_velocity (ObjectHandle, _defaultHandle, vel); } } }
// Input Observer Interface void dmz::EntityPluginPortalFollow3D::update_channel_state ( const Handle Channel, const Boolean State) { _active += State ? 1 : -1; if (_active == 1) { if (_history) { delete []_history; _history = 0; } _history = new Matrix[_HistoryCount > 0 ? _HistoryCount : 1]; _which = 0; ObjectModule *module = get_object_module (); if (module && _hilAttrHandle) { Matrix ori; module->lookup_orientation (_hil, _defaultHandle, ori); for (Int32 ix = 0; ix < _HistoryCount; ix++) { _history[ix] = ori; } } start_time_slice (); } else if (_active == 0) { stop_time_slice (); } }
// TimeSlice Interface void dmz::EntityPluginPortalTether::update_time_slice (const Float64 TimeDelta) { if (_active > 0) { ObjectModule *objMod (get_object_module ()); if (objMod && _handle && _defaultHandle) { Vector pos, vel; Matrix ori; ori.set_identity (); objMod->lookup_position (_handle, _defaultHandle, pos); objMod->lookup_orientation (_handle, _defaultHandle, ori); objMod->lookup_velocity (_handle, _defaultHandle, vel); Vector forward (_offset); ori.transform_vector (forward); pos += forward; if (_renderPortal) { _renderPortal->set_view (pos, ori); } if (_audioPortal) { _audioPortal->set_view (pos, ori, vel); } } } }
// Event Observer Interface void dmz::EntityPluginDamage::close_event ( const Handle EventHandle, const EventType &Type, const EventLocalityEnum Locality) { if (_hil && Type.is_of_type (_detonationType)) { EventModule *eventMod (get_event_module ()); if (eventMod) { Handle target (0); if (eventMod->lookup_object_handle (EventHandle, _targetHandle, target)) { if (_hil == target) { ObjectModule *objMod (get_object_module ()); if (objMod) { Mask state; objMod->lookup_state (_hil, _defaultObjectHandle, state); state |= _deadState; objMod->store_state (_hil, _defaultObjectHandle, state); } } } } } }
void dmz::WeaponPluginFixedLauncher::_create_munition (const Handle SourceHandle) { ObjectModule *objMod (get_object_module ()); Boolean active (True); if ((SourceHandle == _hil) && !_hilActive) { active = False; } if (active && objMod) { const Handle AmmoHandle = _ammo.create_munition (SourceHandle, *objMod); if (AmmoHandle) { Matrix ori; Vector pos, vel; objMod->lookup_orientation (SourceHandle, _defaultHandle, ori); objMod->lookup_position (SourceHandle, _defaultHandle, pos); objMod->lookup_velocity (SourceHandle, _defaultHandle, vel); Vector offset (_launcherOffset); ori = ori * _launcherRotation; ori.transform_vector (offset); pos += offset; objMod->store_orientation (AmmoHandle, _defaultHandle, ori); objMod->store_position (AmmoHandle, _defaultHandle, pos); objMod->store_velocity (AmmoHandle, _defaultHandle, vel); objMod->activate_object (AmmoHandle); } } }
void dmz::CyclesPluginWallOSG::update_object_state ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Mask &Value, const Mask *PreviousValue) { const Boolean IsDead (Value.contains (_deadState)); const Boolean WasDead (PreviousValue ? PreviousValue->contains (_deadState) : False); const Boolean IsOn (Value.contains (_engineOnState)); const Boolean WasOn (PreviousValue ? PreviousValue->contains (_engineOnState) : False); if ((IsDead && !WasDead) || (!IsOn && WasOn)) { ObjectStruct *os (_objectTable.remove (ObjectHandle)); if (os && !_deadTable.store (ObjectHandle, os)) { _remove_wall (*os); delete os; os = 0; } } else if (IsOn && !WasOn) { ObjectModule *objMod (get_object_module ()); if (objMod) { _create_object_wall (ObjectHandle, objMod->lookup_object_type (ObjectHandle)); } } }
void dmz::QtPluginCanvasLink::_store_edge ( const Handle ObjectHandle, QtCanvasLink *item) { if (item) { NodeStruct *node (_nodeTable.lookup (ObjectHandle)); if (!node) { node = new NodeStruct (); if (!_nodeTable.store (ObjectHandle, node)) { delete node; node = 0; } } if (node) { node->edgeTable.store (item->get_link_handle (), item); } ObjectModule *objectModule (get_object_module ()); if (objectModule) { Vector pos; objectModule->lookup_position (ObjectHandle, _positionAttrHandle, pos); item->update (ObjectHandle, pos); } } }
void dmz::CyclesPluginWallOSG::_create_wall ( const Handle ObjectHandle, const WallStruct &Wall) { ObjectStruct *os (new ObjectStruct (Wall)); if (_core && os && _objectTable.store (ObjectHandle, os)) { ObjectModule *objMod (get_object_module ()); if (objMod) { objMod->lookup_position (ObjectHandle, _defaultHandle, os->lastCorner); os->pos = os->posPrev = os->lastCorner; objMod->lookup_velocity (ObjectHandle, _defaultHandle, os->dir); os->dirPrev = os->dir = os->dir.normalize (); } os->xform = new osg::MatrixTransform; os->xform->setUserData (new RenderObjectDataOSG (ObjectHandle)); os->geod = new osg::Geode; os->wall = new osg::Geometry; os->verts = new osg::Vec3Array; os->normals = new osg::Vec3Array; os->draw = new osg::DrawArrays (GL_TRIANGLE_STRIP, 0, 0); os->xform->addChild (os->geod.get ()); osg::ref_ptr<osg::StateSet> set = os->wall->getOrCreateStateSet (); osg::ref_ptr<osg::Material> mat = new osg::Material; mat->setEmission (osg::Material::FRONT_AND_BACK, Wall.Color); set->setAttributeAndModes (mat.get ()); os->wall->setNormalArray (os->normals.get ()); os->wall->setNormalBinding (osg::Geometry::BIND_PER_PRIMITIVE); osg::ref_ptr<osg::Vec4Array> color = new osg::Vec4Array; color->push_back (Wall.Color); os->wall->setColorArray (color.get ()); os->wall->setColorBinding (osg::Geometry::BIND_OVERALL); os->wall->setVertexArray (os->verts.get ()); os->wall->addPrimitiveSet (os->draw.get ()); os->geod->addDrawable (os->wall.get ()); osg::Group *dgroup (_core->get_dynamic_objects ()); if (dgroup) { dgroup->addChild (os->xform.get ()); } else { _log.error << "Failed to add geode!" << endl; } } else if (os) { delete os; os = 0; } }
void dmz::MBRAPluginFaultTreeAutoLayout::_update_tree ( const Handle SuperHandle, const Handle SubHandle, const Int32 Column, Int32 &count) { ObjectModule *objMod (get_object_module ()); if (objMod && SuperHandle && SubHandle) { Vector rootPos (0.0, 0.0, 0.0); Vector superPos; objMod->lookup_position (SuperHandle, _defaultAttrHandle, superPos); Vector offset ((Column * _hOffset), 0.0, (count * _vOffset)); Vector topPos (rootPos + offset); HandleContainer children; objMod->lookup_sub_links (SubHandle, _linkAttrHandle, children); if (children.get_count ()) { Int32 startCount (count); Handle current (children.get_first ()); while (current) { _update_tree (SubHandle, current, Column + 1, count); current = children.get_next (); } Int32 endCount (count); offset.set_xyz (0.0, 0.0, ((endCount - startCount - 1) * 0.5f * _vOffset)); objMod->store_position (SubHandle, _defaultAttrHandle, topPos + offset); _update_logic (SubHandle); _update_path (SubHandle); } else { offset.set_xyz ((Column * _hOffset), 0.0, (count * _vOffset)); objMod->store_position (SubHandle, _defaultAttrHandle, rootPos + offset); count++; } } }
void dmz::QtPluginCanvasObjectBasic::_lookup_object_type ( const Handle ObjectHandle, ObjectType &objType) { ObjectModule *objectModule (get_object_module ()); if (objectModule) { objType = objectModule->lookup_object_type (ObjectHandle); } }
void dmz::QtPluginCanvasObjectBasic::_lookup_object_state ( const Handle ObjectHandle, Mask &objState) { ObjectModule *objectModule (get_object_module ()); if (objectModule) { objectModule->lookup_state (ObjectHandle, _stateAttributeHandle, objState); } }
// TimeSlice Interface void dmz::EntityPluginDeadTimer::update_time_slice (const Float64 TimeDelta) { ObjectModule *objMod (get_object_module ()); if (objMod && _hil) { Mask state; objMod->lookup_state (_hil, _defaultHandle, state); state.unset (_deadState); objMod->store_state (_hil, _defaultHandle, state); } }
void dmz::EntityPluginGroundSimple::receive_button_event ( const Handle Channel, const InputEventButton &Value) { if ((Value.get_button_id () == 1) && Value.get_button_value ()) { const Float64 Time (_time.get_frame_time ()); if (!(_move.turboModifier > 0.0) && (Time > _move.turboRefillTime)) { _move.turboModifier = _move.turboBoost; _move.turboEndTime = Time + _move.turboDuration; } } else if ((Value.get_button_id () == 3) && Value.get_button_value ()) { ObjectModule *objMod (get_object_module ()); if (objMod) { Vector pos; Matrix ori; objMod->lookup_position (_hil, _defaultHandle, pos); objMod->lookup_orientation (_hil, _defaultHandle, ori); _log.out << "\n<position x=\"" << pos.get_x () << "\" y=\"" << pos.get_y () << "\" z=\"" << pos.get_z () << "\"/>\n"; _log.out << "<orientation\n"; Float64 array[9]; ori.to_array (array); for (Int32 ix = 0; ix < 9; ix++) { if (!(ix % 3)) { _log.out << " "; } _log.out << " v" << ix << "=\"" << array[ix] << "\""; if (!((ix + 1) % 3)) { _log.out << "\n"; } } _log.out << "/>" << endl; } } }
// TimeSlice Interface void dmz::StarfighterPluginSpaceBoxOSG::update_time_slice (const Float64 DeltaTime) { ObjectModule *module = get_object_module (); if (module && _hil && _box.valid ()) { Vector pos; if (module->lookup_position (_hil, _defaultHandle, pos)) { const osg::Vec3d BoxPos = to_osg_vector (pos); osg::Matrix mat; mat.makeTranslate (BoxPos); _box->setMatrix (mat); } } }
void dmz::MBRAPluginFaultTreeAutoLayout::_update_path (const Handle Object) { ObjectModule *objMod (get_object_module ()); if (objMod && Object) { Vector rootPos; objMod->lookup_position (Object, _defaultAttrHandle, rootPos); const QPointF RootPoint (rootPos.get_x (), rootPos.get_z ()); Vector logicPos ( rootPos.get_x () + (0.5f * _hOffset), rootPos.get_y (), rootPos.get_z ()); const QPointF LogicPoint (logicPos.get_x (), logicPos.get_z ()); _path.moveTo (RootPoint); _path.lineTo (LogicPoint); HandleContainer children; objMod->lookup_sub_links (Object, _linkAttrHandle, children); if (children.get_count ()) { Vector pos; Handle current (children.get_first ()); while (current) { Vector pos; objMod->lookup_position (current, _defaultAttrHandle, pos); QPointF end (pos.get_x (), pos.get_z ()); _path.moveTo (LogicPoint); _path.lineTo (LogicPoint.x (), end.y ()); _path.lineTo (end); current = children.get_next (); } } } }
// Input Observer Interface void dmz::EntityPluginGroundSimple::update_channel_state ( const Handle Channel, const Boolean State) { _active += (State ? 1 : -1); if (_active == 0) { _wasAirborn = False; if (_hil && _throttleHandle) { ObjectModule *objMod (get_object_module ()); if (objMod) { objMod->store_scalar (_hil, _throttleHandle, 0.0); } } } }
void dmz::MBRAPluginFaultTreeAutoLayout::update_object_flag ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Boolean Value, const Boolean *PreviousValue) { if (Value) { _root = ObjectHandle; } ObjectModule *objMod = get_object_module (); if (objMod) { _set_component_hide_state (ObjectHandle, Value ? False : True, *objMod); } _update_tree (); }
osg::Group * dmz::RenderModuleCoreOSGBasic::create_dynamic_object (const Handle ObjectHandle) { osg::Group *result (0); ObjectStruct *os (_objectTable.lookup (ObjectHandle)); if (!os) { os = new ObjectStruct (ObjectHandle); if (os && !_objectTable.store (ObjectHandle, os)) { delete os; os = 0; } if (os) { os->transform->setUserData (new RenderObjectDataOSG (ObjectHandle)); os->transform->setDataVariance (osg::Object::DYNAMIC); ObjectModule *objMod (get_object_module ()); if (objMod) { objMod->lookup_position (ObjectHandle, _defaultHandle, os->pos); objMod->lookup_scale (ObjectHandle, _defaultHandle, os->scale); objMod->lookup_orientation (ObjectHandle, _defaultHandle, os->ori); os->transform->setMatrix (to_osg_matrix (os->ori, os->pos, os->scale)); } os->dirty = True; os->next = _dirtyObjects; _dirtyObjects = os; if (_dynamicObjects.valid ()) { _dynamicObjects->addChild (os->transform.get ()); } } } if (os) { result = os->transform.get (); } return result; }
void dmz::MBRAPluginFaultTreeAutoLayout::_update_tree () { ObjectModule *objMod (get_object_module ()); if (objMod && _root) { HandleContainer children; objMod->lookup_sub_links (_root, _linkAttrHandle, children); _path = QPainterPath (); Int32 count (0); Handle current (children.get_first ()); while (current) { _update_tree (_root, current, 1, count); current = children.get_next (); } Vector offset (0.0, 0.0, 0.0); if (count) { offset.set_z ((count - 1) * 0.5f * _vOffset); } objMod->store_position (_root, _defaultAttrHandle, offset); _update_logic (_root); if (children.get_count ()) { _update_path (_root); } if (_pathItem) { _pathItem->setPath (_path); } } }
void dmz::MBRAPluginNACalculate::on_objectiveComboBox_currentIndexChanged (int id) { ObjectModule *objMod = get_object_module (); if (objMod && _simulatorHandle) { const Handle ActiveHandle (_ui.objectiveComboBox->itemData (id).toLongLong ()); foreach (Handle attrHandle, _objectiveFunctionHandles) { Boolean value (False); if (ActiveHandle == attrHandle) { value = True; } _ignoreUpdates = True; objMod->store_flag (_simulatorHandle, attrHandle, value); _ignoreUpdates = False; } }
void dmz::QtPluginCanvasLink::update_link_attribute_object ( const Handle LinkHandle, const Handle AttributeHandle, const UUID &SuperIdentity, const Handle SuperHandle, const UUID &SubIdentity, const Handle SubHandle, const UUID &AttributeIdentity, const Handle AttributeObjectHandle, const UUID &PrevAttributeIdentity, const Handle PrevAttributeObjectHandle) { if (AttributeObjectHandle) { LinkStruct *ls = _linkTable.lookup (LinkHandle); if (ls) { _attrObjTable.store (AttributeObjectHandle, ls); } if (_flowAttrHandle) { ObjectModule *objMod (get_object_module ()); if (objMod) { Mask state; if (objMod->lookup_state (AttributeObjectHandle, _flowAttrHandle, state)) { update_object_state ( UUID (), AttributeObjectHandle, _flowAttrHandle, state, 0); } } } } if (PrevAttributeObjectHandle) { _attrObjTable.remove (PrevAttributeObjectHandle); } }
void dmz::MBRAPluginNACalculate::_slot_weight_by_clicked (int id) { ObjectModule *objMod = get_object_module (); if (objMod && _simulatorHandle) { const Handle AttrHandle (id); QAbstractButton *button = _weightByGroup.button (id); if (button) { Boolean value = button->isChecked (); _ignoreUpdates = True; objMod->store_flag (_simulatorHandle, AttrHandle, value); _ignoreUpdates = False; } } }
void dmz::MBRAPluginFaultTreeAutoLayout::_update_logic (const Handle Parent) { ObjectModule *objMod (get_object_module ()); if (objMod) { HandleContainer logic; objMod->lookup_sub_links (Parent, _logicAttrHandle, logic); if (logic.get_count ()) { Vector pos; objMod->lookup_position (Parent, _defaultAttrHandle, pos); pos.set_x (pos.get_x () + (_hOffset * 0.5f)); objMod->store_position (logic.get_first (), _defaultAttrHandle, pos); } } }
void dmz::MBRAPluginArchiveSupport::update_object_scalar ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Float64 Value, const Float64 *PreviousValue) { if (AttributeHandle == _ecAttrHandle) { ObjectModule *objMod = get_object_module (); if (objMod && _pcAttrHandle) { objMod->store_scalar (ObjectHandle, _pcAttrHandle, Value); objMod->remove_attribute (ObjectHandle, _ecAttrHandle, ObjectScalarMask); _ecObjects.add (ObjectHandle); } } }
// Object Observer Interface void dmz::ObjectPluginHighlight::update_object_flag ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Boolean Value, const Boolean *PreviousValue) { if (Value) { if (ObjectHandle != _current) { ObjectModule *module (get_object_module ()); if (module) { module->store_flag (_current, _highlightAttr, False); } _current = ObjectHandle; } } else if (ObjectHandle == _current) { _current = 0; } }
// Object Observer Interface void dmz::QtPluginCanvasObject::create_object ( const UUID &Identity, const Handle ObjectHandle, const ObjectType &Type, const ObjectLocalityEnum Locality) { Config data; ObjectType currentType (Type); if (_find_config_from_type (data, currentType)) { String name (currentType.get_name ()); name << "." << ObjectHandle; ObjectStruct *os (new ObjectStruct (ObjectHandle)); os->item->setData (QtCanvasObjectNameIndex, name.get_buffer ()); ObjectModule *objMod (get_object_module ()); if (objMod) { Vector pos; Matrix ori; objMod->lookup_position (ObjectHandle, _defaultAttributeHandle, pos); objMod->lookup_orientation (ObjectHandle, _defaultAttributeHandle, ori); os->posX = pos.get_x (); os->posY = pos.get_z (); os->heading = get_heading (ori); os->update (); } _objectTable.store (os->ObjHandle, os); if (_canvasModule) { _canvasModule->add_item (os->ObjHandle, os->item); } } }