History

can create static laser pointers, fixed a bug with multiple render states

SamGondelman committed 9 years ago

Commit af12b5a1 parent 8f533635 files · +104 −88Browse files

Showing the changes to interface/src/raypick/LaserPointerScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

interface/src/raypick/LaserPointerScriptingInterface.cpp+64−55
@@ -25,6 +25,61 @@ LaserPointerScriptingInterface* LaserPointerScriptingInterface::getInstance() { · 24 unmodified lines
2525 uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) {
2626 QVariantMap propertyMap = properties.toMap();
2727
28+ uint16_t filter = 0;
29+ if (propertyMap["filter"].isValid()) {
30+ filter = propertyMap["filter"].toUInt();
31+ }
32+
33+ float maxDistance = 0.0f;
34+ if (propertyMap["maxDistance"].isValid()) {
35+ maxDistance = propertyMap["maxDistance"].toFloat();
36+ }
37+
38+ bool enabled = false;
39+ if (propertyMap["enabled"].isValid()) {
40+ enabled = propertyMap["enabled"].toBool();
41+ }
42+
43+ QHash<QString, RenderState> renderStates;
44+ if (propertyMap["renderStates"].isValid()) {
45+ QList<QVariant> renderStateVariants = propertyMap["renderStates"].toList();
46+ for (QVariant& renderStateVariant : renderStateVariants) {
47+ if (renderStateVariant.isValid()) {
48+ QVariantMap renderStateMap = renderStateVariant.toMap();
49+ if (renderStateMap["name"].isValid()) {
50+ QString name = renderStateMap["name"].toString();
51+
52+ QUuid startID;
53+ if (renderStateMap["start"].isValid()) {
54+ QVariantMap startMap = renderStateMap["start"].toMap();
55+ if (startMap["type"].isValid()) {
56+ startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap);
57+ }
58+ }
59+
60+ QUuid pathID;
61+ if (renderStateMap["path"].isValid()) {
62+ QVariantMap pathMap = renderStateMap["path"].toMap();
63+ // right now paths must be line3ds
64+ if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") {
65+ pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap);
66+ }
67+ }
68+
69+ QUuid endID;
70+ if (renderStateMap["end"].isValid()) {
71+ QVariantMap endMap = renderStateMap["end"].toMap();
72+ if (endMap["type"].isValid()) {
73+ endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap);
74+ }
75+ }
76+
77+ renderStates[name] = RenderState(startID, pathID, endID);
78+ }
79+ }
80+ }
81+ }
82+
2883 if (propertyMap["joint"].isValid()) {
2984 QString jointName = propertyMap["joint"].toString();
3085
@@ -39,63 +94,17 @@ uint32_t LaserPointerScriptingInterface::createLaserPointer(const QVariant& prop · 8 unmodified lines
3994 dirOffset = vec3FromVariant(propertyMap["dirOffset"]);
4095 }
4196
42− uint16_t filter = 0;
43− if (propertyMap["filter"].isValid()) {
44− filter = propertyMap["filter"].toUInt();
45− }
46−
47− float maxDistance = 0.0f;
48− if (propertyMap["maxDistance"].isValid()) {
49− maxDistance = propertyMap["maxDistance"].toFloat();
50− }
51−
52− bool enabled = false;
53− if (propertyMap["enabled"].isValid()) {
54− enabled = propertyMap["enabled"].toBool();
55− }
56−
57− QHash<QString, RenderState> renderStates;
58− if (propertyMap["renderStates"].isValid()) {
59− QList<QVariant> renderStateVariants = propertyMap["renderStates"].toList();
60− for (QVariant& renderStateVariant : renderStateVariants) {
61− if (renderStateVariant.isValid()) {
62− QVariantMap renderStateMap = renderStateVariant.toMap();
63− if (renderStateMap["name"].isValid()) {
64− QString name = renderStateMap["name"].toString();
65−
66− QUuid startID;
67− if (renderStateMap["start"].isValid()) {
68− QVariantMap startMap = renderStateMap["start"].toMap();
69− if (startMap["type"].isValid()) {
70− startID = qApp->getOverlays().addOverlay(startMap["type"].toString(), startMap);
71− }
72− }
73−
74− QUuid pathID;
75− if (renderStateMap["path"].isValid()) {
76− QVariantMap pathMap = renderStateMap["path"].toMap();
77− // right now paths must be line3ds
78− if (pathMap["type"].isValid() && pathMap["type"].toString() == "line3d") {
79− pathID = qApp->getOverlays().addOverlay(pathMap["type"].toString(), pathMap);
80− }
81− }
82−
83− QUuid endID;
84− if (renderStateMap["end"].isValid()) {
85− QVariantMap endMap = renderStateMap["end"].toMap();
86− if (endMap["type"].isValid()) {
87− endID = qApp->getOverlays().addOverlay(endMap["type"].toString(), endMap);
88− }
89− }
97+ return LaserPointerManager::getInstance().createLaserPointer(jointName, posOffset, dirOffset, filter, maxDistance, renderStates, enabled);
98+ } else if (propertyMap["position"].isValid()) {
99+ glm::vec3 position = vec3FromVariant(propertyMap["position"]);
90100
91− renderStates[name] = RenderState(startID, pathID, endID);
92− }
93− }
94− }
101+ glm::vec3 direction = -Vectors::UP;
102+ if (propertyMap["direction"].isValid()) {
103+ direction = vec3FromVariant(propertyMap["direction"]);
95104 }
96105
97− return LaserPointerManager::getInstance().createLaserPointer(jointName, posOffset, dirOffset, filter, maxDistance, renderStates, enabled);
98− } else {
99− return 0;
106+ return LaserPointerManager::getInstance().createLaserPointer(position, direction, filter, maxDistance, renderStates, enabled);
100107 }
108+
109+ return 0;
101110 }