Пример #1
0
void
dmz::RenderModulePortalOSG::_init (const Config &Local) {

   _portalName = config_to_string ("portal.name", Local, _portalName);

   Config cullRangeData;
   if (Local.lookup_all_config ("visibility", cullRangeData)) {

      ConfigIterator it;
      Config cd;

      Boolean found (cullRangeData.get_first_config (it, cd));
      if (found)  {
         _fov = config_to_float32 ("fov", cd);
         _nearClip = config_to_float32 ("near", cd);
         _farClip = config_to_float32 ("far", cd);
      }
   }
   else {

      _fov = 60.0;
      _nearClip = 1.0f;
      _farClip = 10000.0f;
   }

   _log.info << "FOV: " << _fov << endl;
   _log.info << "Clip Planes: " << _nearClip << " / " << _farClip << endl;
}
Пример #2
0
void
dmz::QtCanvasViewSession::load_config (const Config &Source) {

   Int32 width (_canvas.width ());
   width = config_to_float32 ("canvasView.width", Source, width);

   Int32 height (_canvas.height ());
   height = config_to_float32 ("canvasView.height", Source, height);

//   _canvas.resize (width, height);

   Float32 scale (_canvas.get_scale ());
   scale = config_to_float32 ("canvasView.scale", Source, scale);
//   _canvas.set_scale (scale);

   // _canvas.verticalScrollBar ()->setValue (
   //    config_to_int32 ("canvasView.scrollBars.vertical", Source, 0));
   //
   // _canvas.horizontalScrollBar ()->setValue (
   //    config_to_int32 ("canvasView.scrollBars.horizontal", Source, 0));
}
void
dmz::CyclesPluginWallOSG::_create_object_wall (
      const Handle ObjectHandle,
      const ObjectType &Type) {

   WallStruct *wall (0);

   ObjectType current (Type);

   while (current && !wall) {

      wall = _wallTable.lookup (Type.get_handle ());

      Config wallDef;

      if (!wall && current.get_config ().lookup_all_config_merged ("wall", wallDef)) {

         const Float32 Red (config_to_float32 ("color.r", wallDef, 1.0));
         const Float32 Green (config_to_float32 ("color.g", wallDef, 1.0));
         const Float32 Blue (config_to_float32 ("color.b", wallDef, 1.0));
         const Float32 Alpha (config_to_float32 ("color.a", wallDef, 1.0));
         const Float32 Height (config_to_float32 ("height.value", wallDef, 1.0));
         const Float32 Offset (config_to_float32 ("offset.value", wallDef, 1.0));

         _log.info << " " << Type.get_name () << " wall information." << endl
            << "\t   Red : " << Red << endl
            << "\t Green : " << Green << endl
            << "\t  Blue : " << Blue << endl
            << "\t Alpha : " << Alpha << endl
            << "\tHeight : " << Height << endl
            << "\tOffset : " << Offset << endl;

         wall = new WallStruct (
            True,
            osg::Vec4 (Red, Green, Blue, Alpha),
            Height,
            Offset);

         if (wall && !_wallTable.store (Type.get_handle (), wall)) {

            delete wall; wall = 0;
         }
      }
      else { current.become_parent (); }
   }

   if (wall && wall->ColorDefined) {

      _create_wall (ObjectHandle, *wall);
   }
   else if (!wall) {

      wall = new WallStruct (False, osg::Vec4 (0.0f, 0.0f, 0.0f, 0.0f), 0.0f, 0.0f);

      if (wall && !_wallTable.store (Type.get_handle (), wall)) {

         delete wall; wall = 0;
      }
   }
}
Пример #4
0
void
dmz::AudioModuleFMOD::_init (const Config &Local) {

    // Create a System object
   FMOD_RESULT createResult = FMOD::System_Create(&_system);
   _error_check ("Enabling FMOD", createResult);

   _dopplerScale = config_to_float32 ("dopplerScale.value", Local, _dopplerScale);
   _distanceFactor = config_to_float32 ("distanceFactor.value", Local, _distanceFactor);
   _rollOffScale = config_to_float32 ("rollOffScale.value", Local, _rollOffScale);
   _maxChannels = config_to_int32 ("maxChannels.value", Local, _maxChannels);

   _rightHandedCoordinates =
      config_to_boolean ("rightHandedCoordinate.value", Local, _rightHandedCoordinates);

   _forceFullDirectSoundHRTF = config_to_boolean (
      "forceFullDirectSoundHRTF.value",
      Local,
      _forceFullDirectSoundHRTF);

   if (_system) {

      unsigned int version;
      FMOD_RESULT result =_system->getVersion (&version);

      FMOD_CAPS caps;
      FMOD_SPEAKERMODE speakermode;
      result = _system->getDriverCaps (0, &caps, 0, 0, &speakermode);
      _error_check ("Getting driver caps", result);

      result = _system->setSpeakerMode (speakermode);
      _error_check ("Setting speaker mode", result);

      if (caps & FMOD_CAPS_HARDWARE_EMULATED) {

         result = _system->setDSPBufferSize (1024, 10);
         _error_check ("Setting speaker mode", result);
         _log.warn << "Audio hardware is being emulated" << endl;
      }

      FMOD_INITFLAGS flags = FMOD_INIT_NORMAL;

      if (_rightHandedCoordinates) { flags |= FMOD_INIT_3D_RIGHTHANDED; }

      // Only enable Software HRTF emulation if we are on windows (and therefore
      // DirectSound is available)
      #ifdef _WIN32
      if (_forceFullDirectSoundHRTF) { flags |= FMOD_INIT_DSOUND_HRTFFULL; }
      #endif

      result = _system->init (_maxChannels, flags, 0);

      if (result == FMOD_ERR_OUTPUT_CREATEBUFFER) {

        result = _system->setSpeakerMode(FMOD_SPEAKERMODE_STEREO);
        _error_check ("Setting speaker mode to stereo", result);
        result = _system->init(_maxChannels, flags, 0);
        _error_check ("Initializing FMOD Sound System", result);
      }

//      _system->set3DSettings (_dopplerScale, _distanceFactor, _rollOffScale);

      set_mute_all_state (True); // Mute all sounds for now (creating the first listener
                                 // will unmute them)
   }

   _log.info << "AudioModuleFMOD Initialized" << endl;
}
Пример #5
0
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);
}
Пример #6
0
void
dmz::QtModuleCanvasBasic::_init (Config &local) {

   qwidget_config_read ("widget", local, this);

   const Int32 MinX = config_to_int32 ("scene.min.x", local, -50000);
   const Int32 MinY = config_to_int32 ("scene.min.y", local, -50000);
   const Int32 MaxX = config_to_int32 ("scene.max.x", local, 100000);
   const Int32 MaxY = config_to_int32 ("scene.max.y", local, 100000);

   _scene.setSceneRect (QRectF (MinX, MinY, MaxX - MinX, MaxY - MinY));
   //_scene.setItemIndexMethod (QGraphicsScene::NoIndex);

   _canvas = new QtCanvasView (this);
   _canvas->setTransformationAnchor (QGraphicsView::AnchorViewCenter);
   _canvas->setResizeAnchor (QGraphicsView::AnchorViewCenter);

   const Boolean ScrollBars = config_to_boolean ("scrollbars.value", local, False);

   if (!ScrollBars) {

      _canvas->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
      _canvas->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
   }

   _canvas->setMouseTracking (true);
   //_canvas->setDragMode (QGraphicsView::ScrollHandDrag);

   setObjectName (get_plugin_name ().get_buffer ());
   _scene.setObjectName (objectName () + "Scene");
   _canvas->setObjectName (objectName () + "View");

   _canvas->setScene (&_scene);

   //_canvas->setBackgroundBrush (QPixmap ("/assets/images/background1.png"));

   QVBoxLayout *layout (new QVBoxLayout ());
   layout->addWidget (_canvas);

   setLayout (layout);
   setMouseTracking (true);
   _inputModuleName = config_to_string ("module.input.name", local);

   if (_canvas) {

      _keyEvent.set_source_handle (get_plugin_handle ());
      _mouseEvent.set_source_handle (get_plugin_handle ());

      String value;

      Boolean enableOpenGL (False);

      if (local.lookup_attribute ("canvas.opengl", value)) {

         if (value.to_lower () == "true") { enableOpenGL = True; }
      }

      Boolean enableAntialiasing (False);
      if (local.lookup_attribute ("canvas.antialiasing", value)) {

         if (value.to_lower () == "true") { enableAntialiasing = True; }
      }

      if (enableOpenGL) {

         _canvas->setViewport (new QGLWidget (QGLFormat  (QGL::SampleBuffers)));
         _log.info << "OpenGL enabled" << endl;
      }

      if (enableAntialiasing) {

         if (enableOpenGL) {

            _canvas->setRenderHint (QPainter::HighQualityAntialiasing, true);
            _log.info << "High Quality Antialiasing enabled" << endl;
         }
         else {

            _canvas->setRenderHint (QPainter::Antialiasing, true);
            _log.info << "Antialiasing enabled" << endl;
         }
      }

      if (local.lookup_attribute ("canvas.textantialiasing", value)) {

         if (value.to_lower () == "true") {

            _canvas->setRenderHint (QPainter::TextAntialiasing, true);
            _log.info << "Test Antialiasing enabled" << endl;
         }
      }

      _canvas->setRenderHint (QPainter::SmoothPixmapTransform, true);

      set_zoom_min_value (config_to_float32 ("canvas.zoom.min", local, _zoomMin));
      set_zoom_max_value (config_to_float32 ("canvas.zoom.max", local, _zoomMax));
      set_zoom_step_value (config_to_float32 ("canvas.zoom.step", local, _zoomStep));
      set_zoom (config_to_float32 ("canvas.zoom.default", local, _zoomDefault));
   }
}