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