Q_INVOKABLE void writeProperties(QVariant propertyMap) {
     auto offscreenUi = DependencyManager::get<OffscreenUi>();
     offscreenUi->executeOnUiThread([=] {
         QVariantMap map = propertyMap.toMap();
         for (const QString& key : map.keys()) {
             _qmlObject->setProperty(key.toStdString().c_str(), map[key]);
         }
     });
 }
Example #2
0
bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::vec4& color, const glm::vec3& direction) const {
    auto offscreenUi = DependencyManager::get<OffscreenUi>();
    offscreenUi->executeOnUiThread([offscreenUi, enabled] {
        offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled);
    });
    return qApp->getActiveDisplayPlugin()->setHandLaser(hands,
        enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
        color, direction);
}
Example #3
0
bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) const {
    auto offscreenUi = DependencyManager::get<OffscreenUi>();
    offscreenUi->executeOnUiThread([offscreenUi, enabled] {
        offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled);
    });


    auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
    auto sensorToWorld = myAvatar->getSensorToWorldMatrix();
    auto worldToSensor = glm::inverse(sensorToWorld);
    auto sensorStart = ::transformPoint(worldToSensor, worldStart);
    auto sensorDirection = ::transformVectorFast(worldToSensor, direction);

    return qApp->getActiveDisplayPlugin()->setExtraLaser(enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
        color, sensorStart, sensorDirection);
}