Browse Source

fixed another bug: since maya2egg looks at MAnimControl::maxTime() to figure end_frame, lets set the maxTime on egg2maya to the end frame

Asad M. Zaman 17 years ago
parent
commit
89aa597bd4

+ 15 - 1
pandatool/src/mayaegg/mayaEggLoader.cxx

@@ -65,6 +65,7 @@
 #include <maya/MTransformationMatrix.h>
 #include <maya/MFnIkJoint.h>
 #include <maya/MFnSkinCluster.h>
+#include <maya/MAnimControl.h>
 #include <maya/MFnAnimCurve.h>
 #include "post_maya_include.h"
 
@@ -954,7 +955,10 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del
     for (ci = poly->begin(); ci != poly->end(); ++ci) {
       EggVertex *vtx = (*ci);
       EggVertexPool *pool = poly->get_pool();
-      TexCoordd uv = vtx->get_uv();
+      TexCoordd uv(0,0);
+      if (vtx->has_uv()) {
+        uv = vtx->get_uv();
+      }
       vertIndices.push_back(mesh->GetVert(vtx, context));
       tvertIndices.push_back(mesh->GetTVert(uv * uvtrans));
       cvertIndices.push_back(mesh->GetCVert(vtx->get_color()));
@@ -1177,6 +1181,9 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a
                            << " -ef: " << _end_frame << endl;
   }
 
+  // masad: keep track of maximum frames of animation on all these joints
+  MTime maxFrame(_start_frame - 1, _timeUnit);
+
   for (ei = _anim_tab.begin(); ei != _anim_tab.end(); ++ei) {
     MayaAnim *anim = (*ei).second;
     MObject node = GetDependencyNode(anim->_joint->get_name());
@@ -1263,6 +1270,13 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a
       mfnAnimCurveSY.addKey(time, scale[1], tangent, tangent, NULL, &status);
       mfnAnimCurveSZ.addKey(time, scale[2], tangent, tangent, NULL, &status);
     }
+    if (maxFrame < time) {
+      maxFrame = time;
+    }
+  }
+  if (anim) {
+    // masad: set the control's max time with maxFrame
+    MAnimControl::setMaxTime(maxFrame);
   }
 
   for (ci = _mesh_tab.begin();  ci != _mesh_tab.end();  ++ci) {

+ 1 - 0
pandatool/src/mayaegg/mayaToEggConverter.cxx

@@ -425,6 +425,7 @@ convert_maya() {
     end_frame = get_end_frame();
   } else {
     end_frame = MAnimControl::maxTime().value();
+    //end_frame = MAnimControl::animationEndTime().value(); //masad: we could use this
   }
   if (has_frame_inc()) {
     frame_inc = get_frame_inc();