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
275275 data.updateClusterBuffer(clusterMatrices);
276276 Transform renderTransform = modelTransform;
277277 if (clusterMatrices.size() == 1) {
278+#ifdef SKIN_MATRIX
279+ SKIN_ASSERT(false);
278280 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
279289 }
280290 data.updateTransformForSkinnedMesh(renderTransform, modelTransform);
281291
@@ -1178,15 +1188,14 @@ void Model::updateClusterMatrices() { · 896 unmodified lines
11781188 for (int j = 0; j < mesh.clusters.size(); j++) {
11791189 const FBXCluster& cluster = mesh.clusters.at(j);
11801190
1181− // AJT: TODO REMOVE
1182− /*
1191+ // AJT: TODO FIXME
1192+#ifdef SKIN_MATRIX
1193+ SKIN_ASSERT(false);
11831194 auto jointMatrix = _rig.getJointTransform(cluster.jointIndex);
11841195 glm_mat4u_mul(jointMatrix, cluster.inverseBindMatrix, state.clusterMatrices[j]);
1185− */
1196+#endif
1197+#ifdef SKIN_COMP
11861198 AnimPose jointPose = _rig.getJointPose(cluster.jointIndex);
1187−
1188− // AJT: TODO: store inverseBindMatrix as an animpose
1189− // AJT: TODO: optimize AnimPose::operator*
11901199 AnimPose result = jointPose * AnimPose(cluster.inverseBindMatrix);
11911200
11921201 // pack scale rotation and translation into a mat4.
@@ -1194,15 +1203,15 @@ void Model::updateClusterMatrices() { · 1 unmodified line
11941203 state.clusterMatrices[j][0].y = result.scale().y;
11951204 state.clusterMatrices[j][0].z = result.scale().z;
11961205
1197− DualQuaternion dq(result.rot(), result.trans());
1198− state.clusterMatrices[j][1].x = dq.real().x;
1199− state.clusterMatrices[j][1].y = dq.real().y;
1200− state.clusterMatrices[j][1].z = dq.real().z;
1201− state.clusterMatrices[j][1].w = dq.real().w;
1202− state.clusterMatrices[j][2].x = dq.imag().x;
1203− state.clusterMatrices[j][2].y = dq.imag().y;
1204− state.clusterMatrices[j][2].z = dq.imag().z;
1205− state.clusterMatrices[j][2].w = dq.imag().w;
1206+ state.clusterMatrices[j][1].x = result.rot().x;
1207+ state.clusterMatrices[j][1].y = result.rot().y;
1208+ state.clusterMatrices[j][1].z = result.rot().z;
1209+ state.clusterMatrices[j][1].w = result.rot().w;
1210+
1211+ state.clusterMatrices[j][2].x = result.trans().x;
1212+ state.clusterMatrices[j][2].y = result.trans().y;
1213+ state.clusterMatrices[j][2].z = result.trans().z;
1214+#endif
12061215 }
12071216 }
12081217

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