Showing the changes to interface/src/raypick/LaserPointerScriptingInterface.cpp (1 of 17 files). Show all
Unified · Split
| @@ -0,0 +1,61 @@ | |||
| 1 | // | ||
| 2 | // LaserPointerScriptingInterface.cpp | ||
| 3 | // interface/src/raypick | ||
| 4 | // | ||
| 5 | // Created by Sam Gondelman 7/11/2017 | ||
| 6 | // Copyright 2017 High Fidelity, Inc. | ||
| 7 | // | ||
| 8 | // Distributed under the Apache License, Version 2.0. | ||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 10 | // | ||
| 11 | |||
| 12 | #include "LaserPointerScriptingInterface.h" | ||
| 13 | |||
| 14 | #include <QVariant> | ||
| 15 | #include "RegisteredMetaTypes.h" | ||
| 16 | #include "GLMHelpers.h" | ||
| 17 | |||
| 18 | LaserPointerScriptingInterface* LaserPointerScriptingInterface::getInstance() { | ||
| 19 | static LaserPointerScriptingInterface instance; | ||
| 20 | return &instance; | ||
| 21 | } | ||
| 22 | |||
| 23 | uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) { | ||
| 24 | QVariantMap propertyMap = properties.toMap(); | ||
| 25 | |||
| 26 | if (propertyMap["joint"].isValid()) { | ||
| 27 | QString jointName = propertyMap["joint"].toString(); | ||
| 28 | |||
| 29 | glm::vec3 posOffset = Vectors::ZERO; | ||
| 30 | if (propertyMap["posOffset"].isValid()) { | ||
| 31 | posOffset = vec3FromVariant(propertyMap["posOffset"]); | ||
| 32 | } | ||
| 33 | |||
| 34 | glm::vec3 dirOffset = Vectors::FRONT; | ||
| 35 | if (propertyMap["dirOffset"].isValid()) { | ||
| 36 | posOffset = vec3FromVariant(propertyMap["dirOffset"]); | ||
| 37 | } | ||
| 38 | |||
| 39 | uint16_t filter = 0; | ||
| 40 | if (propertyMap["filter"].isValid()) { | ||
| 41 | filter = propertyMap["filter"].toUInt(); | ||
| 42 | } | ||
| 43 | |||
| 44 | float maxDistance = 0.0f; | ||
| 45 | if (propertyMap["maxDistance"].isValid()) { | ||
| 46 | maxDistance = propertyMap["maxDistance"].toFloat(); | ||
| 47 | } | ||
| 48 | |||
| 49 | bool enabled = false; | ||
| 50 | if (propertyMap["enabled"].isValid()) { | ||
| 51 | enabled = propertyMap["enabled"].toBool(); | ||
| 52 | } | ||
| 53 | |||
| 54 | // TODO: | ||
| 55 | // handle render state properties | ||
| 56 | |||
| 57 | return LaserPointerManager::getInstance().createLaserPointer(jointName, posOffset, dirOffset, filter, maxDistance, enabled); | ||
| 58 | } else { | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | } | ||