Fix for pupil dilation on Ryan's face.
Unified · Split
| @@ -2030,10 +2030,9 @@ void Application::updateMyAvatarLookAtPosition(glm::vec3& lookAtSpot, glm::vec3& · 2029 unmodified lines | |||
| 2030 | // deflect using Faceshift gaze data | 2030 | // deflect using Faceshift gaze data |
| 2031 | glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition(); | 2031 | glm::vec3 origin = _myAvatar.getHead().calculateAverageEyePosition(); |
| 2032 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; | 2032 | float pitchSign = (_myCamera.getMode() == CAMERA_MODE_MIRROR) ? -1.0f : 1.0f; |
| 2033 | const float PITCH_SCALE = 0.25f; | 2033 | float deflection = Menu::getInstance()->getFaceshiftEyeDeflection(); |
| 2034 | const float YAW_SCALE = 0.25f; | ||
| 2035 | lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( | 2034 | lookAtSpot = origin + _myCamera.getRotation() * glm::quat(glm::radians(glm::vec3( |
| 2036 | _faceshift.getEstimatedEyePitch() * pitchSign * PITCH_SCALE, _faceshift.getEstimatedEyeYaw() * YAW_SCALE, 0.0f))) * | 2035 | _faceshift.getEstimatedEyePitch() * pitchSign * deflection, _faceshift.getEstimatedEyeYaw() * deflection, 0.0f))) * |
| 2037 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); | 2036 | glm::inverse(_myCamera.getRotation()) * (lookAtSpot - origin); |
| 2038 | } | 2037 | } |
| 2039 | _myAvatar.getHead().setLookAtPosition(lookAtSpot); | 2038 | _myAvatar.getHead().setLookAtPosition(lookAtSpot); |
| @@ -46,12 +46,14 @@ Menu* Menu::getInstance() { · 45 unmodified lines | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f}; | 48 | const ViewFrustumOffset DEFAULT_FRUSTUM_OFFSET = {-135.0f, 0.0f, 0.0f, 25.0f, 0.0f}; |
| 49 | const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f; | ||
| 49 | 50 | ||
| 50 | Menu::Menu() : | 51 | Menu::Menu() : |
| 51 | _actionHash(), | 52 | _actionHash(), |
| 52 | _audioJitterBufferSamples(0), | 53 | _audioJitterBufferSamples(0), |
| 53 | _bandwidthDialog(NULL), | 54 | _bandwidthDialog(NULL), |
| 54 | _fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES), | 55 | _fieldOfView(DEFAULT_FIELD_OF_VIEW_DEGREES), |
| 56 | _faceshiftEyeDeflection(DEFAULT_FACESHIFT_EYE_DEFLECTION), | ||
| 55 | _frustumDrawMode(FRUSTUM_DRAW_MODE_ALL), | 57 | _frustumDrawMode(FRUSTUM_DRAW_MODE_ALL), |
| 56 | _viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET), | 58 | _viewFrustumOffset(DEFAULT_FRUSTUM_OFFSET), |
| 57 | _voxelModeActionsGroup(NULL), | 59 | _voxelModeActionsGroup(NULL), |
| @@ -512,6 +514,7 @@ void Menu::loadSettings(QSettings* settings) { · 454 unmodified lines | |||
| 512 | 514 | ||
| 513 | _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); | 515 | _audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0); |
| 514 | _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); | 516 | _fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES); |
| 517 | _faceshiftEyeDeflection = loadSetting(settings, "faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION); | ||
| 515 | _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM); | 518 | _maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM); |
| 516 | _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_VOXEL_SIZE_SCALE); | 519 | _voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_VOXEL_SIZE_SCALE); |
| 517 | _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0); | 520 | _boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0); |
| @@ -540,6 +543,7 @@ void Menu::saveSettings(QSettings* settings) { · 22 unmodified lines | |||
| 540 | 543 | ||
| 541 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); | 544 | settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples); |
| 542 | settings->setValue("fieldOfView", _fieldOfView); | 545 | settings->setValue("fieldOfView", _fieldOfView); |
| 546 | settings->setValue("faceshiftEyeDeflection", _faceshiftEyeDeflection); | ||
| 543 | settings->setValue("maxVoxels", _maxVoxels); | 547 | settings->setValue("maxVoxels", _maxVoxels); |
| 544 | settings->setValue("voxelSizeScale", _voxelSizeScale); | 548 | settings->setValue("voxelSizeScale", _voxelSizeScale); |
| 545 | settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust); | 549 | settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust); |
| @@ -790,6 +794,10 @@ void Menu::editPreferences() { · 244 unmodified lines | |||
| 790 | pupilDilation->setValue(applicationInstance->getAvatar()->getHead().getPupilDilation() * pupilDilation->maximum()); | 794 | pupilDilation->setValue(applicationInstance->getAvatar()->getHead().getPupilDilation() * pupilDilation->maximum()); |
| 791 | form->addRow("Pupil Dilation:", pupilDilation); | 795 | form->addRow("Pupil Dilation:", pupilDilation); |
| 792 | 796 | ||
| 797 | QSlider* faceshiftEyeDeflection = new QSlider(Qt::Horizontal); | ||
| 798 | faceshiftEyeDeflection->setValue(_faceshiftEyeDeflection * faceshiftEyeDeflection->maximum()); | ||
| 799 | form->addRow("Faceshift Eye Deflection:", faceshiftEyeDeflection); | ||
| 800 | |||
| 793 | QSpinBox* fieldOfView = new QSpinBox(); | 801 | QSpinBox* fieldOfView = new QSpinBox(); |
| 794 | fieldOfView->setMaximum(180); | 802 | fieldOfView->setMaximum(180); |
| 795 | fieldOfView->setMinimum(1); | 803 | fieldOfView->setMinimum(1); |
| @@ -865,6 +873,8 @@ void Menu::editPreferences() { · 69 unmodified lines | |||
| 865 | 873 | ||
| 866 | _fieldOfView = fieldOfView->value(); | 874 | _fieldOfView = fieldOfView->value(); |
| 867 | applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height()); | 875 | applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height()); |
| 876 | |||
| 877 | _faceshiftEyeDeflection = faceshiftEyeDeflection->value() / (float)faceshiftEyeDeflection->maximum(); | ||
| 868 | } | 878 | } |
| 869 | 879 | ||
| 870 | sendFakeEnterEvent(); | 880 | sendFakeEnterEvent(); |
| @@ -50,6 +50,7 @@ public: · 49 unmodified lines | |||
| 50 | 50 | ||
| 51 | float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; } | 51 | float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; } |
| 52 | float getFieldOfView() const { return _fieldOfView; } | 52 | float getFieldOfView() const { return _fieldOfView; } |
| 53 | float getFaceshiftEyeDeflection() const { return _faceshiftEyeDeflection; } | ||
| 53 | BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; } | 54 | BandwidthDialog* getBandwidthDialog() const { return _bandwidthDialog; } |
| 54 | FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; } | 55 | FrustumDrawMode getFrustumDrawMode() const { return _frustumDrawMode; } |
| 55 | ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; } | 56 | ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; } |
| @@ -127,6 +128,7 @@ private: · 71 unmodified lines | |||
| 127 | int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback | 128 | int _audioJitterBufferSamples; /// number of extra samples to wait before starting audio playback |
| 128 | BandwidthDialog* _bandwidthDialog; | 129 | BandwidthDialog* _bandwidthDialog; |
| 129 | float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus | 130 | float _fieldOfView; /// in Degrees, doesn't apply to HMD like Oculus |
| 131 | float _faceshiftEyeDeflection; | ||
| 130 | FrustumDrawMode _frustumDrawMode; | 132 | FrustumDrawMode _frustumDrawMode; |
| 131 | ViewFrustumOffset _viewFrustumOffset; | 133 | ViewFrustumOffset _viewFrustumOffset; |
| 132 | QActionGroup* _voxelModeActionsGroup; | 134 | QActionGroup* _voxelModeActionsGroup; |
| @@ -1234,7 +1234,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) · 1233 unmodified lines | |||
| 1234 | } | 1234 | } |
| 1235 | 1235 | ||
| 1236 | // find the clusters with which the mesh is associated | 1236 | // find the clusters with which the mesh is associated |
| 1237 | extracted.mesh.isEye = false; | ||
| 1238 | QVector<QString> clusterIDs; | 1237 | QVector<QString> clusterIDs; |
| 1239 | foreach (const QString& childID, childMap.values(it.key())) { | 1238 | foreach (const QString& childID, childMap.values(it.key())) { |
| 1240 | foreach (const QString& clusterID, childMap.values(childID)) { | 1239 | foreach (const QString& clusterID, childMap.values(childID)) { |
| @@ -1245,12 +1244,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) · 4 unmodified lines | |||
| 1245 | const Cluster& cluster = clusters[clusterID]; | 1244 | const Cluster& cluster = clusters[clusterID]; |
| 1246 | clusterIDs.append(clusterID); | 1245 | clusterIDs.append(clusterID); |
| 1247 | 1246 | ||
| 1248 | QString jointID = childMap.value(clusterID); | ||
| 1249 | if (jointID == jointEyeLeftID || jointID == jointEyeRightID) { | ||
| 1250 | extracted.mesh.isEye = true; | ||
| 1251 | } | ||
| 1252 | // see http://stackoverflow.com/questions/13566608/loading-skinning-information-from-fbx for a discussion | 1247 | // see http://stackoverflow.com/questions/13566608/loading-skinning-information-from-fbx for a discussion |
| 1253 | // of skinning information in FBX | 1248 | // of skinning information in FBX |
| 1249 | QString jointID = childMap.value(clusterID); | ||
| 1254 | fbxCluster.jointIndex = modelIDs.indexOf(jointID); | 1250 | fbxCluster.jointIndex = modelIDs.indexOf(jointID); |
| 1255 | if (fbxCluster.jointIndex == -1) { | 1251 | if (fbxCluster.jointIndex == -1) { |
| 1256 | qDebug() << "Joint not in model list: " << jointID << "\n"; | 1252 | qDebug() << "Joint not in model list: " << jointID << "\n"; |
| @@ -1278,16 +1274,19 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) · 21 unmodified lines | |||
| 1278 | } | 1274 | } |
| 1279 | 1275 | ||
| 1280 | // whether we're skinned depends on how many clusters are attached | 1276 | // whether we're skinned depends on how many clusters are attached |
| 1277 | int maxJointIndex = extracted.mesh.clusters.at(0).jointIndex; | ||
| 1281 | if (clusterIDs.size() > 1) { | 1278 | if (clusterIDs.size() > 1) { |
| 1282 | extracted.mesh.clusterIndices.resize(extracted.mesh.vertices.size()); | 1279 | extracted.mesh.clusterIndices.resize(extracted.mesh.vertices.size()); |
| 1283 | extracted.mesh.clusterWeights.resize(extracted.mesh.vertices.size()); | 1280 | extracted.mesh.clusterWeights.resize(extracted.mesh.vertices.size()); |
| 1281 | float maxWeight = 0.0f; | ||
| 1284 | for (int i = 0; i < clusterIDs.size(); i++) { | 1282 | for (int i = 0; i < clusterIDs.size(); i++) { |
| 1285 | QString clusterID = clusterIDs.at(i); | 1283 | QString clusterID = clusterIDs.at(i); |
| 1286 | const Cluster& cluster = clusters[clusterID]; | 1284 | const Cluster& cluster = clusters[clusterID]; |
| 1287 | 1285 | float totalWeight = 0.0f; | |
| 1288 | for (int j = 0; j < cluster.indices.size(); j++) { | 1286 | for (int j = 0; j < cluster.indices.size(); j++) { |
| 1289 | int oldIndex = cluster.indices.at(j); | 1287 | int oldIndex = cluster.indices.at(j); |
| 1290 | float weight = cluster.weights.at(j); | 1288 | float weight = cluster.weights.at(j); |
| 1289 | totalWeight += weight; | ||
| 1291 | for (QMultiHash<int, int>::const_iterator it = extracted.newIndices.constFind(oldIndex); | 1290 | for (QMultiHash<int, int>::const_iterator it = extracted.newIndices.constFind(oldIndex); |
| 1292 | it != extracted.newIndices.end() && it.key() == oldIndex; it++) { | 1291 | it != extracted.newIndices.end() && it.key() == oldIndex; it++) { |
| 1293 | glm::vec4& weights = extracted.mesh.clusterWeights[it.value()]; | 1292 | glm::vec4& weights = extracted.mesh.clusterWeights[it.value()]; |
| @@ -1302,8 +1301,13 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) · 8 unmodified lines | |||
| 1302 | } | 1301 | } |
| 1303 | } | 1302 | } |
| 1304 | } | 1303 | } |
| 1304 | if (totalWeight > maxWeight) { | ||
| 1305 | maxWeight = totalWeight; | ||
| 1306 | maxJointIndex = extracted.mesh.clusters.at(i).jointIndex; | ||
| 1307 | } | ||
| 1305 | } | 1308 | } |
| 1306 | } | 1309 | } |
| 1310 | extracted.mesh.isEye = (maxJointIndex == geometry.leftEyeJointIndex || maxJointIndex == geometry.rightEyeJointIndex); | ||
| 1307 | 1311 | ||
| 1308 | // extract spring edges, connections if springy | 1312 | // extract spring edges, connections if springy |
| 1309 | if (extracted.mesh.springiness > 0.0f) { | 1313 | if (extracted.mesh.springiness > 0.0f) { |