History

WIP checkpoint, root transforms for shapes and non-animated fbx files are working.

Anthony J. Thibault committed 8 years ago

Commit 23affb51 parent 532c8a26 files · +207 −46Browse files

Showing the changes to libraries/render-utils/src/Model.cpp (1 of 6 files). Show all

Unified · Split

libraries/render-utils/src/Model.cpp+24−15
@@ -275,7 +275,17 @@ void Model::updateRenderItems() { · 274 unmodified lines
275 data.updateClusterBuffer(clusterMatrices);275 data.updateClusterBuffer(clusterMatrices);
276 Transform renderTransform = modelTransform;276 Transform renderTransform = modelTransform;
277 if (clusterMatrices.size() == 1) {277 if (clusterMatrices.size() == 1) {
278#ifdef SKIN_MATRIX
279 SKIN_ASSERT(false);
278 renderTransform = modelTransform.worldTransform(Transform(clusterMatrices[0]));280 renderTransform = modelTransform.worldTransform(Transform(clusterMatrices[0]));
281#endif
282#ifdef SKIN_COMP
283 glm::vec3 scale(clusterMatrices[0][0]);
284 glm::quat rot(clusterMatrices[0][1].w, clusterMatrices[0][1].x, clusterMatrices[0][1].y, clusterMatrices[0][1].z);
285 glm::vec3 trans(clusterMatrices[0][2]);
286 glm::mat4 m = createMatFromScaleQuatAndPos(scale, rot, trans);
287 renderTransform = modelTransform.worldTransform(Transform(m));
288#endif
279 }289 }
280 data.updateTransformForSkinnedMesh(renderTransform, modelTransform);290 data.updateTransformForSkinnedMesh(renderTransform, modelTransform);
281 291
@@ -1178,15 +1188,14 @@ void Model::updateClusterMatrices() { · 896 unmodified lines
1178 for (int j = 0; j < mesh.clusters.size(); j++) {1188 for (int j = 0; j < mesh.clusters.size(); j++) {
1179 const FBXCluster& cluster = mesh.clusters.at(j);1189 const FBXCluster& cluster = mesh.clusters.at(j);
1180 1190
1181 // AJT: TODO REMOVE1191 // AJT: TODO FIXME
1182 /*1192#ifdef SKIN_MATRIX
1193 SKIN_ASSERT(false);
1183 auto jointMatrix = _rig.getJointTransform(cluster.jointIndex);1194 auto jointMatrix = _rig.getJointTransform(cluster.jointIndex);
1184 glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);1195 glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
1185 */1196#endif
1197#ifdef SKIN_COMP
1186 AnimPose jointPose = _rig.getJointPose(cluster.jointIndex);1198 AnimPose jointPose = _rig.getJointPose(cluster.jointIndex);
1187
1188 // AJT: TODO: store inverseBindMatrix as an animpose
1189 // AJT: TODO: optimize AnimPose::operator*
1190 AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);1199 AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
1191 1200
1192 // pack scale rotation and translation into a mat4.1201 // pack scale rotation and translation into a mat4.
@@ -1194,15 +1203,15 @@ void Model::updateClusterMatrices() { · 1 unmodified line
1194 state.clusterMatrices[j][0].y = result.scale().y;1203 state.clusterMatrices[j][0].y = result.scale().y;
1195 state.clusterMatrices[j][0].z = result.scale().z;1204 state.clusterMatrices[j][0].z = result.scale().z;
1196 1205
1197 DualQuaternion dq(result.rot(), result.trans());1206 state.clusterMatrices[j][1].x = result.rot().x;
1198 state.clusterMatrices[j][1].x = dq.real().x;1207 state.clusterMatrices[j][1].y = result.rot().y;
1199 state.clusterMatrices[j][1].y = dq.real().y;1208 state.clusterMatrices[j][1].z = result.rot().z;
1200 state.clusterMatrices[j][1].z = dq.real().z;1209 state.clusterMatrices[j][1].w = result.rot().w;
1201 state.clusterMatrices[j][1].w = dq.real().w;1210
1202 state.clusterMatrices[j][2].x = dq.imag().x;1211 state.clusterMatrices[j][2].x = result.trans().x;
1203 state.clusterMatrices[j][2].y = dq.imag().y;1212 state.clusterMatrices[j][2].y = result.trans().y;
1204 state.clusterMatrices[j][2].z = dq.imag().z;1213 state.clusterMatrices[j][2].z = result.trans().z;
1205 state.clusterMatrices[j][2].w = dq.imag().w;1214#endif
1206 }1215 }
1207 }1216 }
1208 1217

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t