| 756 | } |
| 757 | |
| 758 | void ColladaAppMesh::getMorphVertexData(const domMorph* morph, F32 time, const MatrixF& objOffset, |
| 759 | Vector<Point3F>& v_points, |
| 760 | Vector<Point3F>& v_norms, |
| 761 | Vector<ColorI>& v_colors, |
| 762 | Vector<Point2F>& v_uvs, |
| 763 | Vector<Point2F>& v_uv2s) |
| 764 | { |
| 765 | // @todo: Could the base geometry (or any target geometry) also be a morph? |
| 766 | |
| 767 | // Get the target geometries and weights (could be animated) |
| 768 | Vector<const domGeometry*> targetGeoms; |
| 769 | domListOfFloats targetWeights; |
| 770 | |
| 771 | for (S32 iInput = 0; iInput < morph->getTargets()->getInput_array().getCount(); iInput++) { |
| 772 | const domInputLocal* input = morph->getTargets()->getInput_array()[iInput]; |
| 773 | const domSource* source = daeSafeCast<domSource>(findInputSource(input)); |
| 774 | |
| 775 | if (dStrEqual(input->getSemantic(), "MORPH_TARGET")) { |
| 776 | // Get the morph targets |
| 777 | _SourceReader srcTargets; |
| 778 | srcTargets.initFromSource(source); |
| 779 | |
| 780 | for (S32 iTarget = 0; iTarget < srcTargets.size(); iTarget++) { |
| 781 | // Lookup the element and add to the targets list |
| 782 | daeIDRef idref(srcTargets.getStringValue(iTarget)); |
| 783 | idref.setContainer(morph->getDocument()->getDomRoot()); |
| 784 | targetGeoms.push_back(daeSafeCast<domGeometry>(idref.getElement())); |
| 785 | } |
| 786 | } |
| 787 | else if (dStrEqual(input->getSemantic(), "MORPH_WEIGHT")) { |
| 788 | // Get the (possibly animated) morph weight |
| 789 | targetWeights = AnimatedFloatList(source->getFloat_array()).getValue(time); |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | // Check that we have a weight for each target |
| 794 | if (targetGeoms.size() != targetWeights.getCount()) |
| 795 | { |
| 796 | domController* ctrl = daeSafeCast<domController>(const_cast<domMorph*>(morph)->getParent()); |
| 797 | Con::warnf("Mismatched morph targets and weights in %s.", _GetNameOrId(ctrl)); |
| 798 | |
| 799 | // Set unused targets to zero weighting (unused weights are ignored) |
| 800 | while (targetGeoms.size() > targetWeights.getCount()) |
| 801 | targetWeights.append(0.0f); |
| 802 | } |
| 803 | |
| 804 | // Get the base geometry and vertex data |
| 805 | const domGeometry* baseGeometry = daeSafeCast<domGeometry>(morph->getSource().getElement()); |
| 806 | if (!baseGeometry) |
| 807 | return; |
| 808 | |
| 809 | getPrimitives(baseGeometry); |
| 810 | getVertexData(baseGeometry, time, objOffset, v_points, v_norms, v_colors, v_uvs, v_uv2s, true); |
| 811 | |
| 812 | // Get pointers to the arrays of base geometry data |
| 813 | Point3F* points_array = &v_points[v_points.size() - vertTuples.size()]; |
| 814 | Point3F* norms_array = &v_norms[v_norms.size() - vertTuples.size()]; |
| 815 | Point2F* uvs_array = &v_uvs[v_uvs.size() - vertTuples.size()]; |
nothing calls this directly
no test coverage detected