History

more work on extra lasers

Brad Hefta-Gaub committed 10 years ago

Commit a282d831 parent 8a071f18 files · +107 −15Browse files

Showing the changes to interface/src/scripting/HMDScriptingInterface.cpp (1 of 8 files). Show all

Unified · Split

interface/src/scripting/HMDScriptingInterface.cpp+15−5
@@ -130,16 +130,26 @@ bool HMDScriptingInterface::setHandLasers(int hands, bool enabled, const glm::ve · 129 unmodified lines
130130 color, direction);
131131 }
132132
133−bool HMDScriptingInterface::setExtraLaser(const vec3& worldStart, bool enabled, const vec4& color, const vec3& direction) const {
133+bool HMDScriptingInterface::setExtraLaser(const glm::vec3& worldStart, bool enabled, const glm::vec4& color, const glm::vec3& direction) const {
134134 auto offscreenUi = DependencyManager::get<OffscreenUi>();
135135 offscreenUi->executeOnUiThread([offscreenUi, enabled] {
136136 offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", enabled);
137137 });
138138
139− mat4 extraLaserPose;
140− return qApp->getActiveDisplayPlugin()->setExtraLaser(extraLaserPose,
141− enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
142− color, direction);
139+
140+ auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
141+ auto sensorToWorld = myAvatar->getSensorToWorldMatrix();
142+ auto worldToSensor = glm::inverse(sensorToWorld);
143+ auto sensorStart = ::transformPoint(worldToSensor, worldStart);
144+ auto sensorDirection = ::transformVectorFast(worldToSensor, direction); // wrong
145+
146+ qDebug() << __FUNCTION__ << "worldStart:" << worldStart << "sensorStart:" << sensorStart;
147+ qDebug() << __FUNCTION__ << "direction:" << direction << "sensorDirection:" << sensorDirection;
148+ qDebug() << __FUNCTION__ << "enabled:" << enabled;
149+
150+
151+ return qApp->getActiveDisplayPlugin()->setExtraLaser(enabled ? DisplayPlugin::HandLaserMode::Overlay : DisplayPlugin::HandLaserMode::None,
152+ color, sensorStart, sensorDirection);
143153 }
144154
145155 void HMDScriptingInterface::disableExtraLaser() const {