Ejemplo n.º 1
0
/* virtual */ void
av::tools::PickSelector::evaluate()
{
  av::tools::Selector::evaluate();

  // try to pick if trigger changes to or stays true
  if (PickTrigger.getValue() && (!mLastPickTrigger || !TransitionOnly.getValue()))
  {
    pick();

    if (!mSelectedTargets.empty() || !SelectedTargets.isEmpty())
      SelectedTargets.setValue(mSelectedTargets);

    if (!mLastPickTrigger)
    {
      mLastPickTrigger = true;
      if (!TransitionOnly.getValue() && EveryFrame.getValue())
        alwaysEvaluate(true);
    }
  }
  else if (!PickTrigger.getValue() && mLastPickTrigger)
  {
    if (!SelectedTargets.isEmpty())
      SelectedTargets.clear();
    mLastPickTrigger = false;
    alwaysEvaluate(false);
  }
}
Ejemplo n.º 2
0
/* virtual */ void
av::tools::ChangeSelector::evaluate()
{
  av::tools::Selector::evaluate();

  const MFTargetHolder::ContainerType &targets = Targets.getValue();
  MFTargetHolder::ContainerType added_targets, kept_targets, removed_targets;

  for (MFTargetHolder::ContainerType::const_iterator last_holder = mLastTargets.begin();
       last_holder != mLastTargets.end(); ++last_holder)
  {
    if (!hasTarget(targets, (*last_holder)->Target.getValue()))
      removed_targets.push_back(*last_holder);
  }

  for (MFTargetHolder::ContainerType::const_iterator holder = targets.begin();
       holder != targets.end(); ++holder)
  {
    const SFContainer::ValueType &target = (*holder)->Target.getValue();
    (hasTarget(mLastTargets, target) ? kept_targets : added_targets).push_back(*holder);
  }

  if (!removed_targets.empty() || !RemovedTargets.isEmpty())
    RemovedTargets.setValue(removed_targets);
  if (!kept_targets.empty() || !KeptTargets.isEmpty())
    KeptTargets.setValue(kept_targets);
  if (!added_targets.empty() || !SelectedTargets.isEmpty())
    SelectedTargets.setValue(added_targets);

  mLastTargets = targets;
  alwaysEvaluate(!added_targets.empty() || !removed_targets.empty());
}
Ejemplo n.º 3
0
/* virtual */ void
av::sound::SoundSource::fieldHasChangedLocalSideEffect(const Field& field)
{
  if (&field == &URL) {
    std::string url = URL.getValue();
    for_each_local_source(&LocalSource::setURL, url);
    PlayTime.setValue ( mLocalSources.empty() ? 0.0 : mLocalSources.front()->getPlayTime() );
  } else if (&field == &Spatialize) {
    bool spatialize = Spatialize.getValue();
    for_each_local_source(&LocalSource::setSpatialize, spatialize);
  } else if (&field == &Loop) {
    bool loop = Loop.getValue();
    for_each_local_source(&LocalSource::setLooping, loop);
  } else if (&field == &Velocity) {
    ::gua::math::vec3 velocity = Velocity.getValue();
    for_each_local_source(&LocalSource::setVelocity, velocity);
  } else if (&field == &Direction) {
    ::gua::math::vec3 direction = Direction.getValue();
    for_each_local_source(&LocalSource::setDirection, direction);
  } else if (&field == &ConeInnerAngle) {
    float angle = ConeInnerAngle.getValue();
    for_each_local_source(&LocalSource::setConeInnerAngle, angle);
  } else if (&field == &ConeOuterAngle) {
    float angle = ConeOuterAngle.getValue();
    for_each_local_source(&LocalSource::setConeOuterAngle, angle);
  } else if (&field == &ConeOuterGain) {
    float gain = ConeOuterGain.getValue();
    for_each_local_source(&LocalSource::setConeOuterGain, gain);
  } else if (&field == &Gain) {
    float gain = Gain.getValue();
    for_each_local_source(&LocalSource::setGain, gain);
  } else if (&field == &Pitch) {
    float pitch = Pitch.getValue();
    for_each_local_source(&LocalSource::setPitch, pitch);
  } else if (&field == &Priority) {
    float priority = Priority.getValue();
    for_each_local_source(&LocalSource::setPriority, priority);
  } else if (&field == &ReverbLevel) {
    float revlevel = ReverbLevel.getValue();
    for_each_local_source(&LocalSource::setReverbLevel, revlevel);
  } else if (&field == &Free) {
    for_each_local_source(&LocalSource::setFree);
  } else if (&field == &Play) {
    for_each_local_source(&LocalSource::play);
    mPollPlaying = true;
    alwaysEvaluate(true);
  } else if (&field == &Pause) {
    for_each_local_source(&LocalSource::pause);
  } else if (&field == &Stop) {
    for_each_local_source(&LocalSource::stop);
  } else if (&field == &Rewind) {
    for_each_local_source(&LocalSource::rewind);
  } else   if (&field == &NewSampleBuffer) {
    for_each_local_source(&LocalSource::enqueueSampleBuffer, NewSampleBuffer.getValue());
  } else {
    //av::osg::Group::fieldHasChangedLocalSideEffect(field);
    av::gua::TransformNode::fieldHasChangedLocalSideEffect(field);
  }
}
Ejemplo n.º 4
0
av::oculus::OculusWindow::OculusWindow(
  std::shared_ptr< ::gua::OculusWindow> const& guaOculusWindow
) : av::gua::GlfwWindow(guaOculusWindow),
    m_guaOculusWindow(guaOculusWindow)
{
  // store hmd params in according fields
  AV_FC_ADD_FIELD(SensorOrientation, ::gua::math::mat4());
  AV_FC_ADD_FIELD(Resolution,m_guaOculusWindow->get_window_resolution());
  AV_FC_ADD_FIELD(EyeResolution,m_guaOculusWindow->get_window_resolution());
  AV_FC_ADD_FIELD(LeftScreenSize, m_guaOculusWindow->get_left_screen_size());
  AV_FC_ADD_FIELD(RightScreenSize, m_guaOculusWindow->get_right_screen_size());
  AV_FC_ADD_FIELD(LeftScreenTranslation, m_guaOculusWindow->get_left_screen_translation());
  AV_FC_ADD_FIELD(RightScreenTranslation, m_guaOculusWindow->get_right_screen_translation());
  AV_FC_ADD_FIELD(EyeDistance, m_guaOculusWindow->get_IPD());



  // needs to evaluate every frame to update sensor orientation
  alwaysEvaluate(true);
}
Ejemplo n.º 5
0
void
av::sound::SoundSource::evaluateLocalSideEffect()
{
  if (!mPollPlaying)
  {
    return;
  }

  bool all_done = true;
  for (LocalSources::iterator local_source = mLocalSources.begin();
  local_source != mLocalSources.end();
  ++local_source)
  {
    LocalSource& obj = **local_source;
    all_done &= obj.donePlaying();
  }
  if (all_done)
  {
    mPollPlaying = false;
    alwaysEvaluate(false);
    FinishedPlaying.touch();
  }
}