OLD | NEW |
1 //-***************************************************************************** | 1 //-***************************************************************************** |
2 // | 2 // |
3 // Copyright (c) 2009-2011, | 3 // Copyright (c) 2009-2011, |
4 // Sony Pictures Imageworks Inc. and | 4 // Sony Pictures Imageworks Inc. and |
5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. | 5 // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. |
6 // | 6 // |
7 // All rights reserved. | 7 // All rights reserved. |
8 // | 8 // |
9 // Redistribution and use in source and binary forms, with or without | 9 // Redistribution and use in source and binary forms, with or without |
10 // modification, are permitted provided that the following conditions are | 10 // modification, are permitted provided that the following conditions are |
(...skipping 23 matching lines...) Expand all Loading... |
34 // | 34 // |
35 //-***************************************************************************** | 35 //-***************************************************************************** |
36 | 36 |
37 #include "AbcWriteJob.h" | 37 #include "AbcWriteJob.h" |
38 #include <Alembic/AbcCoreHDF5/All.h> | 38 #include <Alembic/AbcCoreHDF5/All.h> |
39 namespace | 39 namespace |
40 { | 40 { |
41 bool hasDuplicates(const util::ShapeSet & dagPath) | 41 bool hasDuplicates(const util::ShapeSet & dagPath) |
42 { | 42 { |
43 std::set<std::string> roots; | 43 std::set<std::string> roots; |
44 const util::ShapeSet::iterator end = dagPath.end(); | 44 const util::ShapeSet::const_iterator end = dagPath.end(); |
45 for (util::ShapeSet::iterator it = dagPath.begin(); it != end; it++) | 45 for (util::ShapeSet::const_iterator it = dagPath.begin(); |
| 46 it != end; it++) |
46 { | 47 { |
47 MFnTransform mFn(it->node()); | 48 MFnTransform mFn(it->node()); |
48 if (roots.count(mFn.name().asChar()) > 0) | 49 if (roots.count(mFn.name().asChar()) > 0) |
49 return true; | 50 return true; |
50 else | 51 else |
51 roots.insert(mFn.name().asChar()); | 52 roots.insert(mFn.name().asChar()); |
52 } | 53 } |
53 return false; | 54 return false; |
54 } | 55 } |
55 | 56 |
56 class CallWriteVisitor : public boost::static_visitor<> | 57 class CallWriteVisitor : public boost::static_visitor<> |
57 { | 58 { |
58 public: | 59 public: |
59 explicit CallWriteVisitor(double iFrame): mFrame(iFrame) {} | 60 explicit CallWriteVisitor(double iFrame): mFrame(iFrame) {} |
60 | 61 |
61 /* | 62 void operator()(MayaCameraWriterPtr & iNode) |
62 void operator()(MayaNurbsSurfaceWriterPtr & iNode) | |
63 { | 63 { |
64 iNode->write(mFrame); | 64 iNode->write(); |
65 } | |
66 | |
67 void operator()(MayaLightWriterPtr & iNode) | |
68 { | |
69 iNode->write(mFrame); | |
70 } | 65 } |
71 | 66 |
72 void operator()(MayaLocatorWriterPtr & iNode) | 67 void operator()(MayaLocatorWriterPtr & iNode) |
73 { | 68 { |
74 iNode->write(mFrame); | 69 iNode->write(); |
75 } | 70 } |
76 */ | 71 |
| 72 void operator()(MayaMeshWriterPtr & iNode) |
| 73 { |
| 74 iNode->write(); |
| 75 } |
77 | 76 |
78 void operator()(MayaNurbsCurveWriterPtr & iNode) | 77 void operator()(MayaNurbsCurveWriterPtr & iNode) |
79 { | 78 { |
80 iNode->write(); | 79 iNode->write(); |
81 } | 80 } |
82 | 81 |
83 void operator()(MayaCameraWriterPtr & iNode) | 82 void operator()(MayaNurbsSurfaceWriterPtr & iNode) |
84 { | 83 { |
85 iNode->write(); | 84 iNode->write(); |
86 } | 85 } |
87 | 86 |
88 void operator()(MayaPointPrimitiveWriterPtr & iNode) | 87 void operator()(MayaPointPrimitiveWriterPtr & iNode) |
89 { | 88 { |
90 iNode->write(mFrame); | 89 iNode->write(mFrame); |
91 } | 90 } |
92 | 91 |
93 void operator()(MayaMeshWriterPtr & iNode) | 92 |
94 { | |
95 iNode->write(); | |
96 } | |
97 | 93 |
98 private: | 94 private: |
99 double mFrame; | 95 double mFrame; |
100 }; | 96 }; |
101 | 97 |
102 void addToString(std::string & str, | 98 void addToString(std::string & str, |
103 const std::string & name, unsigned int value) | 99 const std::string & name, unsigned int value) |
104 { | 100 { |
105 if (value > 0) | 101 if (value > 0) |
106 { | 102 { |
107 std::stringstream ss; | 103 std::stringstream ss; |
108 ss << value; | 104 ss << value; |
109 str += name + std::string(" ") + ss.str() + std::string(" "); | 105 str += name + std::string(" ") + ss.str() + std::string(" "); |
110 } | 106 } |
111 } | 107 } |
112 | 108 |
113 // increment each CV counter according to the node type in mShapeList | 109 // increment each CV counter according to the node type in mShapeList |
114 class IncrementCVCountsVisitor : public boost::static_visitor<> | 110 class IncrementCVCountsVisitor : public boost::static_visitor<> |
115 { | 111 { |
116 public: | 112 public: |
117 IncrementCVCountsVisitor() | 113 IncrementCVCountsVisitor() |
118 { | 114 { |
119 mCVsArray[0] = 0; // increment onto NurbsAnimCVs | 115 mCVsArray[0] = 0; // increment onto NurbsAnimCVs |
120 mCVsArray[1] = 0; // increment onto CurveAnimCVs | 116 mCVsArray[1] = 0; // increment onto CurveAnimCVs |
121 mCVsArray[2] = 0; // increment onto PointAnimCVs | 117 mCVsArray[2] = 0; // increment onto PointAnimCVs |
122 mCVsArray[3] = 0; // increment onto SubDAnimCVs | 118 mCVsArray[3] = 0; // increment onto SubDAnimCVs |
123 mCVsArray[4] = 0; // increment onto PolyAnimCVs | 119 mCVsArray[4] = 0; // increment onto PolyAnimCVs |
124 } | 120 } |
125 | 121 |
126 /* | 122 |
127 void operator()(MayaNurbsSurfaceWriterPtr & iNode) | 123 void operator()(MayaNurbsSurfaceWriterPtr & iNode) |
128 { | 124 { |
129 mCVsArray[0] += iNode->getNumCVs(); | 125 mCVsArray[0] += iNode->getNumCVs(); |
130 } | 126 } |
131 | 127 |
132 void operator()(MayaLocatorWriterPtr & iNode) {} | 128 void operator()(MayaLocatorWriterPtr & iNode) {} |
133 */ | |
134 | 129 |
135 void operator()(MayaNurbsCurveWriterPtr & iNode) | 130 void operator()(MayaNurbsCurveWriterPtr & iNode) |
136 { | 131 { |
137 mCVsArray[1] += iNode->getNumCVs(); | 132 mCVsArray[1] += iNode->getNumCVs(); |
138 } | 133 } |
139 | 134 |
140 void operator()(MayaCameraWriterPtr & iNode) {} | 135 void operator()(MayaCameraWriterPtr & iNode) {} |
141 | 136 |
142 void operator()(MayaPointPrimitiveWriterPtr & iNode) | 137 void operator()(MayaPointPrimitiveWriterPtr & iNode) |
143 { | 138 { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 iCallback.replace(pos, 13, str); | 212 iCallback.replace(pos, 13, str); |
218 } | 213 } |
219 | 214 |
220 if (isMelCallback) | 215 if (isMelCallback) |
221 MGlobal::executeCommand(iCallback.c_str(), true); | 216 MGlobal::executeCommand(iCallback.c_str(), true); |
222 else | 217 else |
223 MGlobal::executePythonCommand(iCallback.c_str(), true); | 218 MGlobal::executePythonCommand(iCallback.c_str(), true); |
224 } | 219 } |
225 } | 220 } |
226 | 221 |
227 AbcWriteJob::AbcWriteJob(const util::ShapeSet & iDagPath, | 222 AbcWriteJob::AbcWriteJob(const char * iFileName, |
228 const char * iFileName, | |
229 bool iUseSelectionList, | |
230 bool iWorldSpace, | |
231 bool iWriteVisibility, | |
232 bool iWriteUVs, | |
233 std::set<double> & iTransFrames, | 223 std::set<double> & iTransFrames, |
234 Alembic::AbcCoreAbstract::v1::TimeSamplingPtr iTransTime, | 224 Alembic::AbcCoreAbstract::TimeSamplingPtr iTransTime, |
235 std::set<double> & iShapeFrames, | 225 std::set<double> & iShapeFrames, |
236 Alembic::AbcCoreAbstract::v1::TimeSamplingPtr iShapeTime, | 226 Alembic::AbcCoreAbstract::TimeSamplingPtr iShapeTime, |
237 std::string & iMelPerFrameCallback, | 227 const JobArgs & iArgs) |
238 std::string & iMelPostCallback, | |
239 std::string & iPythonPerFrameCallback, | |
240 std::string & iPythonPostCallback, | |
241 std::string & iPrefixFilter, | |
242 std::set< std::string > & iAttribs) | |
243 { | 228 { |
244 MStatus status; | 229 MStatus status; |
245 mDagPath = iDagPath; | |
246 mFileName = iFileName; | 230 mFileName = iFileName; |
247 mBoxIndex = 0; | 231 mBoxIndex = 0; |
| 232 mArgs = iArgs; |
248 | 233 |
249 mUseSelectionList = iUseSelectionList; | 234 if (mArgs.useSelectionList) |
250 if (mUseSelectionList) | |
251 { | 235 { |
252 // get all the DAG nodes starting from the current selection | |
253 // this list will be used as a filter while setting up the write jobs if
mDagPath is not empty; | |
254 // if mDagPath is empty, all DAG nodes from the actively selected | |
255 // to the root will be written out | |
256 bool noRootProvided = mDagPath.empty(); | |
257 | 236 |
258 // get the active selection | 237 // get the active selection |
259 MSelectionList activeList; | 238 MSelectionList activeList; |
260 MGlobal::getActiveSelectionList(activeList); | 239 MGlobal::getActiveSelectionList(activeList); |
261 mSList = activeList; | 240 mSList = activeList; |
262 unsigned int selectionSize = activeList.length(); | 241 unsigned int selectionSize = activeList.length(); |
263 for (unsigned int index = 0; index < selectionSize; index ++) | 242 for (unsigned int index = 0; index < selectionSize; index ++) |
264 { | 243 { |
265 MDagPath dagPath; | 244 MDagPath dagPath; |
266 status = activeList.getDagPath(index, dagPath); | 245 status = activeList.getDagPath(index, dagPath); |
267 if (status == MS::kSuccess) | 246 if (status == MS::kSuccess) |
268 { | 247 { |
269 unsigned int length = dagPath.length(); | 248 unsigned int length = dagPath.length(); |
270 while (--length) | 249 while (--length) |
271 { | 250 { |
272 dagPath.pop(); | 251 dagPath.pop(); |
273 mSList.add(dagPath, MObject::kNullObj, true); | 252 mSList.add(dagPath, MObject::kNullObj, true); |
274 } | 253 } |
275 if (noRootProvided) | |
276 mDagPath.insert(dagPath); | |
277 } | 254 } |
278 } | 255 } |
279 } | 256 } |
280 | 257 |
281 mWorldSpace = iWorldSpace; | |
282 mWriteVisibility = iWriteVisibility; | |
283 mWriteUVs = iWriteUVs; | |
284 | |
285 mTransFrames = iTransFrames; | 258 mTransFrames = iTransFrames; |
286 mShapeFrames = iShapeFrames; | 259 mShapeFrames = iShapeFrames; |
287 | 260 |
288 mFilter = iPrefixFilter; | |
289 mAttribs = iAttribs; | |
290 | |
291 // only needed during creation of the transforms and shapes | 261 // only needed during creation of the transforms and shapes |
292 mTransTime = iTransTime; | 262 mTransTime = iTransTime; |
293 mTransTimeIndex = 0; | 263 mTransTimeIndex = 0; |
294 mShapeTime = iShapeTime; | 264 mShapeTime = iShapeTime; |
295 mShapeTimeIndex = 0; | 265 mShapeTimeIndex = 0; |
296 | 266 |
297 // should have at least 1 value | 267 // should have at least 1 value |
298 assert(!mTransFrames.empty() && !mShapeFrames.empty()); | 268 assert(!mTransFrames.empty() && !mShapeFrames.empty()); |
299 | 269 |
300 // First transform sample and shape sample MUST be equal. Otherwise | |
301 // setup would write a sample that is in one but not the other. | |
302 assert(*(mTransFrames.begin()) == *(mShapeFrames.begin())); | |
303 | |
304 mFirstFrame = *(mTransFrames.begin()); | 270 mFirstFrame = *(mTransFrames.begin()); |
305 std::set<double>::iterator last = mTransFrames.end(); | 271 std::set<double>::iterator last = mTransFrames.end(); |
306 last--; | 272 last--; |
307 mLastFrame = *last; | 273 mLastFrame = *last; |
308 last = mShapeFrames.end(); | 274 last = mShapeFrames.end(); |
309 last--; | 275 last--; |
310 | 276 |
311 double lastShapeFrame = *last; | 277 double lastShapeFrame = *last; |
312 if (lastShapeFrame > mLastFrame) | 278 if (lastShapeFrame > mLastFrame) |
313 mLastFrame = lastShapeFrame; | 279 mLastFrame = lastShapeFrame; |
314 // if there is only one sample, then force static | |
315 mShapesStatic = mShapeFrames.size() < 2; | |
316 mTransStatic = mTransFrames.size() < 2; | |
317 | |
318 mMelPerFrameCallback = iMelPerFrameCallback; | |
319 mMelPostCallback = iMelPostCallback; | |
320 mPythonPerFrameCallback = iPythonPerFrameCallback; | |
321 mPythonPostCallback = iPythonPostCallback; | |
322 } | 280 } |
323 | 281 |
324 void AbcWriteJob::getBoundingBox(const MMatrix & eMInvMat) | 282 void AbcWriteJob::getBoundingBox(const MMatrix & eMInvMat) |
325 { | 283 { |
326 MStatus status; | 284 MStatus status; |
327 | 285 |
328 // short-circuit if the selection flag is on but this node is not in the | 286 // short-circuit if the selection flag is on but this node is not in the |
329 // active selection | 287 // active selection |
330 | 288 |
331 // MGlobal::isSelected(ob) doesn't work, because DG node and DAG node is | 289 // MGlobal::isSelected(ob) doesn't work, because DG node and DAG node is |
332 // not the same even if they refer to the same MObject | 290 // not the same even if they refer to the same MObject |
333 if (mUseSelectionList && !mSList.hasItem(mCurDag)) | 291 if (mArgs.useSelectionList && !mSList.hasItem(mCurDag)) |
334 return; | 292 return; |
335 | 293 |
336 MObject ob = mCurDag.node(); | 294 MObject ob = mCurDag.node(); |
337 | 295 |
338 // check for riCurves flag for flattening all curve object to | 296 // check for riCurves flag for flattening all curve object to |
339 // one curve group | 297 // one curve group |
340 MFnDependencyNode fnDepNode(ob, &status); | 298 MFnDependencyNode fnDepNode(ob, &status); |
341 MPlug riCurvesPlug = fnDepNode.findPlug("riCurves", &status); | 299 MPlug riCurvesPlug = fnDepNode.findPlug("riCurves", &status); |
342 if ( status == MS::kSuccess && riCurvesPlug.asBool() == true) | 300 if ( status == MS::kSuccess && riCurvesPlug.asBool() == true) |
343 { | 301 { |
(...skipping 14 matching lines...) Expand all Loading... |
358 unsigned int numChild = mCurDag.childCount(); | 316 unsigned int numChild = mCurDag.childCount(); |
359 for (unsigned int i = 0; i < numChild; ++i) | 317 for (unsigned int i = 0; i < numChild; ++i) |
360 { | 318 { |
361 mCurDag.push(mCurDag.child(i)); | 319 mCurDag.push(mCurDag.child(i)); |
362 getBoundingBox(eMInvMat); | 320 getBoundingBox(eMInvMat); |
363 mCurDag.pop(); | 321 mCurDag.pop(); |
364 } | 322 } |
365 } | 323 } |
366 else if (ob.hasFn(MFn::kParticle) || ob.hasFn(MFn::kMesh) | 324 else if (ob.hasFn(MFn::kParticle) || ob.hasFn(MFn::kMesh) |
367 || ob.hasFn(MFn::kNurbsCurve) | 325 || ob.hasFn(MFn::kNurbsCurve) |
368 /*|| ob.hasFn(MFn::kNurbsSurface)*/ ) | 326 || ob.hasFn(MFn::kNurbsSurface) ) |
369 { | 327 { |
370 if (util::isIntermediate(mCurDag.node())) | 328 if (util::isIntermediate(mCurDag.node())) |
371 return; | 329 return; |
372 | 330 |
373 MFnDagNode mFn(mCurDag, &status); | 331 MFnDagNode mFn(mCurDag, &status); |
374 if (status == MS::kSuccess) | 332 if (status == MS::kSuccess) |
375 { | 333 { |
376 MBoundingBox box = mFn.boundingBox(); | 334 MBoundingBox box = mFn.boundingBox(); |
377 box.transformUsing(mCurDag.exclusiveMatrix()*eMInvMat); | 335 box.transformUsing(mCurDag.exclusiveMatrix()*eMInvMat); |
378 mCurBBox.expand(box); | 336 mCurBBox.expand(box); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 371 } |
414 return true; | 372 return true; |
415 } | 373 } |
416 | 374 |
417 void AbcWriteJob::setup(double iFrame, MayaTransformWriterPtr iParent) | 375 void AbcWriteJob::setup(double iFrame, MayaTransformWriterPtr iParent) |
418 { | 376 { |
419 MStatus status; | 377 MStatus status; |
420 | 378 |
421 // short-circuit if selection flag is on but this node isn't actively | 379 // short-circuit if selection flag is on but this node isn't actively |
422 // selected | 380 // selected |
423 if (mUseSelectionList && !mSList.hasItem(mCurDag)) | 381 if (mArgs.useSelectionList && !mSList.hasItem(mCurDag)) |
424 return; | 382 return; |
425 | 383 |
426 MObject ob = mCurDag.node(); | 384 MObject ob = mCurDag.node(); |
427 | 385 |
428 // skip all intermediate nodes (and their children) | 386 // skip all intermediate nodes (and their children) |
429 if (util::isIntermediate(ob)) | 387 if (util::isIntermediate(ob)) |
430 { | 388 { |
431 return; | 389 return; |
432 } | 390 } |
433 | 391 |
| 392 // skip nodes that aren't renderable (and their children) |
| 393 if (mArgs.excludeInvisible && util::isRenderable(ob)) |
| 394 { |
| 395 return; |
| 396 } |
| 397 |
434 // look for riCurves flag for flattening all curve objects to a curve group | 398 // look for riCurves flag for flattening all curve objects to a curve group |
435 MFnDependencyNode fnDepNode(ob, &status); | 399 MFnDependencyNode fnDepNode(ob, &status); |
436 MPlug riCurvesPlug = fnDepNode.findPlug("riCurves", &status); | 400 MPlug riCurvesPlug = fnDepNode.findPlug("riCurves", &status); |
437 bool riCurvesVal = riCurvesPlug.asBool(); | 401 bool riCurvesVal = riCurvesPlug.asBool(); |
438 bool writeOutAsGroup = false; | 402 bool writeOutAsGroup = false; |
439 if (riCurvesVal) | 403 if (riCurvesVal) |
440 { | 404 { |
441 writeOutAsGroup = checkCurveGrp(); | 405 writeOutAsGroup = checkCurveGrp(); |
442 if (writeOutAsGroup == false) | 406 if (writeOutAsGroup == false) |
443 { | 407 { |
444 MString msg = "Curves have different degrees or close "; | 408 MString msg = "Curves have different degrees or close "; |
445 msg += "states, not writing out as curve group"; | 409 msg += "states, not writing out as curve group"; |
446 MGlobal::displayWarning(msg); | 410 MGlobal::displayWarning(msg); |
447 } | 411 } |
448 } | 412 } |
449 if ( status == MS::kSuccess && riCurvesVal && writeOutAsGroup) | 413 if ( status == MS::kSuccess && riCurvesVal && writeOutAsGroup) |
450 { | 414 { |
451 MayaNurbsCurveWriterPtr nurbsCurve; | 415 MayaNurbsCurveWriterPtr nurbsCurve; |
452 if (iParent == NULL) | 416 if (iParent == NULL) |
453 { | 417 { |
454 Alembic::Abc::OObject obj = mRoot.getTop(); | 418 Alembic::Abc::OObject obj = mRoot.getTop(); |
455 nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( | 419 nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( |
456 mCurDag, obj, mShapeTimeIndex, true, mWriteVisibility, | 420 mCurDag, obj, mShapeTimeIndex, true, mArgs)); |
457 mShapesStatic)); | |
458 } | 421 } |
459 else | 422 else |
460 { | 423 { |
461 Alembic::Abc::OObject obj = iParent->getObject(); | 424 Alembic::Abc::OObject obj = iParent->getObject(); |
462 nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( | 425 nurbsCurve = MayaNurbsCurveWriterPtr(new MayaNurbsCurveWriter( |
463 mCurDag, obj, mShapeTimeIndex, true, mWriteVisibility, | 426 mCurDag, obj, mShapeTimeIndex, true, mArgs)); |
464 mShapesStatic)); | |
465 } | 427 } |
466 | 428 |
467 if (nurbsCurve->isAnimated() && !mShapesStatic) | 429 if (nurbsCurve->isAnimated() && mShapeTimeIndex != 0) |
468 { | 430 { |
469 MayaNodePtr nd = nurbsCurve; | 431 MayaNodePtr nd = nurbsCurve; |
470 mShapeList.push_back(nd); | 432 mShapeList.push_back(nd); |
471 mStats.mCurveAnimNum++; | 433 mStats.mCurveAnimNum++; |
472 mStats.mCurveAnimCurves += nurbsCurve->getNumCurves(); | 434 mStats.mCurveAnimCurves += nurbsCurve->getNumCurves(); |
473 mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); | 435 mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); |
474 } | 436 } |
475 else | 437 else |
476 { | 438 { |
477 mStats.mCurveStaticNum++; | 439 mStats.mCurveStaticNum++; |
478 mStats.mCurveStaticCurves += nurbsCurve->getNumCurves(); | 440 mStats.mCurveStaticCurves += nurbsCurve->getNumCurves(); |
479 mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); | 441 mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); |
480 } | 442 } |
481 | 443 |
482 AttributesWriterPtr attrs = nurbsCurve->getAttrs(); | 444 AttributesWriterPtr attrs = nurbsCurve->getAttrs(); |
483 if (!mShapesStatic && attrs->isAnimated()) | 445 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
484 mShapeAttrList.push_back(attrs); | 446 mShapeAttrList.push_back(attrs); |
485 } | 447 } |
486 else if (ob.hasFn(MFn::kTransform)) | 448 else if (ob.hasFn(MFn::kTransform)) |
487 { | 449 { |
488 MFnTransform fnTrans(ob, &status); | 450 MFnTransform fnTrans(ob, &status); |
489 if (status != MS::kSuccess) | 451 if (status != MS::kSuccess) |
490 { | 452 { |
491 MString msg = "Initialize transform node "; | 453 MString msg = "Initialize transform node "; |
492 msg += mCurDag.fullPathName(); | 454 msg += mCurDag.fullPathName(); |
493 msg += " failed, skipping."; | 455 msg += " failed, skipping."; |
494 MGlobal::displayWarning(msg); | 456 MGlobal::displayWarning(msg); |
495 return; | 457 return; |
496 } | 458 } |
497 | 459 |
498 MayaTransformWriterPtr trans; | 460 MayaTransformWriterPtr trans; |
499 | 461 |
500 // parented to the root case | 462 // parented to the root case |
501 if (iParent == NULL) | 463 if (iParent == NULL) |
502 { | 464 { |
503 Alembic::Abc::OObject obj = mRoot.getTop(); | 465 Alembic::Abc::OObject obj = mRoot.getTop(); |
504 trans = MayaTransformWriterPtr(new MayaTransformWriter( | 466 trans = MayaTransformWriterPtr(new MayaTransformWriter( |
505 obj, mCurDag, mTransTimeIndex, mWorldSpace, | 467 obj, mCurDag, mTransTimeIndex, mArgs)); |
506 mWriteVisibility, mTransStatic)); | |
507 } | 468 } |
508 else | 469 else |
509 { | 470 { |
510 trans = MayaTransformWriterPtr(new MayaTransformWriter( | 471 trans = MayaTransformWriterPtr(new MayaTransformWriter( |
511 *iParent, mCurDag, mTransTimeIndex, mWriteVisibility, | 472 *iParent, mCurDag, mTransTimeIndex, mArgs)); |
512 mTransStatic)); | |
513 } | 473 } |
514 | 474 |
515 if (trans->isAnimated() && !mTransStatic) | 475 if (trans->isAnimated() && mTransTimeIndex != 0) |
516 { | 476 { |
517 mTransList.push_back(trans); | 477 mTransList.push_back(trans); |
518 mStats.mTransAnimNum++; | 478 mStats.mTransAnimNum++; |
519 } | 479 } |
520 else | 480 else |
521 mStats.mTransStaticNum++; | 481 mStats.mTransStaticNum++; |
522 | 482 |
523 AttributesWriterPtr attrs = trans->getAttrs(); | 483 AttributesWriterPtr attrs = trans->getAttrs(); |
524 if (!mTransStatic && attrs->isAnimated()) | 484 if (mTransTimeIndex != 0 && attrs->isAnimated()) |
525 mTransAttrList.push_back(attrs); | 485 mTransAttrList.push_back(attrs); |
526 | 486 |
527 // loop through the children, making sure to push and pop them | 487 // loop through the children, making sure to push and pop them |
528 // from the MDagPath | 488 // from the MDagPath |
529 unsigned int numChild = mCurDag.childCount(); | 489 unsigned int numChild = mCurDag.childCount(); |
530 for (unsigned int i = 0; i < numChild; ++i) | 490 for (unsigned int i = 0; i < numChild; ++i) |
531 { | 491 { |
532 mCurDag.push(mCurDag.child(i)); | 492 mCurDag.push(mCurDag.child(i)); |
533 setup(iFrame, trans); | 493 setup(iFrame, trans); |
534 mCurDag.pop(); | 494 mCurDag.pop(); |
535 } | 495 } |
536 } | 496 } |
| 497 else if (ob.hasFn(MFn::kLocator)) |
| 498 { |
| 499 MFnDependencyNode fnLocator(ob, & status); |
| 500 if (status != MS::kSuccess) |
| 501 { |
| 502 MString msg = "Initialize locator node "; |
| 503 msg += mCurDag.fullPathName(); |
| 504 msg += " failed, skipping."; |
| 505 MGlobal::displayWarning(msg); |
| 506 return; |
| 507 } |
| 508 |
| 509 if (iParent != NULL) |
| 510 { |
| 511 Alembic::Abc::OObject obj = iParent->getObject(); |
| 512 MayaLocatorWriterPtr locator(new MayaLocatorWriter( |
| 513 mCurDag, obj, mShapeTimeIndex, mArgs)); |
| 514 |
| 515 if (locator->isAnimated() && mShapeTimeIndex != 0) |
| 516 { |
| 517 MayaNodePtr nd = locator; |
| 518 mShapeList.push_back(nd); |
| 519 mStats.mLocatorAnimNum++; |
| 520 } |
| 521 else |
| 522 { |
| 523 mStats.mLocatorStaticNum++; |
| 524 } |
| 525 |
| 526 AttributesWriterPtr attrs = locator->getAttrs(); |
| 527 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
| 528 mShapeAttrList.push_back(attrs); |
| 529 } |
| 530 else |
| 531 { |
| 532 MString err = "Can't translate "; |
| 533 err += fnLocator.name() + " since it doesn't have a parent."; |
| 534 MGlobal::displayError(err); |
| 535 } |
| 536 } |
537 else if (ob.hasFn(MFn::kParticle)) | 537 else if (ob.hasFn(MFn::kParticle)) |
538 { | 538 { |
539 MFnParticleSystem mFnParticle(ob, &status); | 539 MFnParticleSystem mFnParticle(ob, &status); |
540 if (status != MS::kSuccess) | 540 if (status != MS::kSuccess) |
541 { | 541 { |
542 MString msg = "Initialize particle system "; | 542 MString msg = "Initialize particle system "; |
543 msg += mCurDag.fullPathName(); | 543 msg += mCurDag.fullPathName(); |
544 msg += " failed, skipping."; | 544 msg += " failed, skipping."; |
545 MGlobal::displayWarning(msg); | 545 MGlobal::displayWarning(msg); |
546 return; | 546 return; |
547 } | 547 } |
548 | 548 |
549 if (iParent != NULL) | 549 if (iParent != NULL) |
550 { | 550 { |
551 Alembic::Abc::OObject obj = iParent->getObject(); | 551 Alembic::Abc::OObject obj = iParent->getObject(); |
552 MayaPointPrimitiveWriterPtr particle(new MayaPointPrimitiveWriter( | 552 MayaPointPrimitiveWriterPtr particle(new MayaPointPrimitiveWriter( |
553 iFrame, mCurDag, obj, mShapeTimeIndex, | 553 iFrame, mCurDag, obj, mShapeTimeIndex, mArgs)); |
554 mWriteVisibility, mShapesStatic)); | |
555 | 554 |
556 if (particle->isAnimated() && !mShapesStatic) | 555 if (particle->isAnimated() && mShapeTimeIndex != 0) |
557 { | 556 { |
558 MayaNodePtr nd = particle; | 557 MayaNodePtr nd = particle; |
559 mShapeList.push_back(nd); | 558 mShapeList.push_back(nd); |
560 mStats.mPointAnimNum++; | 559 mStats.mPointAnimNum++; |
561 mStats.mPointAnimCVs += particle->getNumCVs(); | 560 mStats.mPointAnimCVs += particle->getNumCVs(); |
562 } | 561 } |
563 else | 562 else |
564 { | 563 { |
565 mStats.mPointStaticNum++; | 564 mStats.mPointStaticNum++; |
566 mStats.mPointStaticCVs += particle->getNumCVs(); | 565 mStats.mPointStaticCVs += particle->getNumCVs(); |
567 } | 566 } |
568 | 567 |
569 AttributesWriterPtr attrs = particle->getAttrs(); | 568 AttributesWriterPtr attrs = particle->getAttrs(); |
570 if (!mShapesStatic && attrs->isAnimated()) | 569 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
571 mShapeAttrList.push_back(attrs); | 570 mShapeAttrList.push_back(attrs); |
572 } | 571 } |
573 else | 572 else |
574 { | 573 { |
575 MString err = "Can't translate "; | 574 MString err = "Can't translate "; |
576 err += mFnParticle.name() + " since it doesn't have a parent."; | 575 err += mFnParticle.name() + " since it doesn't have a parent."; |
577 MGlobal::displayError(err); | 576 MGlobal::displayError(err); |
578 } | 577 } |
579 } | 578 } |
580 else if (ob.hasFn(MFn::kMesh)) | 579 else if (ob.hasFn(MFn::kMesh)) |
581 { | 580 { |
582 MFnMesh fnMesh(ob, &status); | 581 MFnMesh fnMesh(ob, &status); |
583 if (status != MS::kSuccess) | 582 if (status != MS::kSuccess) |
584 { | 583 { |
585 MString msg = "Initialize mesh node "; | 584 MString msg = "Initialize mesh node "; |
586 msg += mCurDag.fullPathName(); | 585 msg += mCurDag.fullPathName(); |
587 msg += " failed, skipping."; | 586 msg += " failed, skipping."; |
588 MGlobal::displayWarning(msg); | 587 MGlobal::displayWarning(msg); |
589 return; | 588 return; |
590 } | 589 } |
591 | 590 |
592 if (iParent != NULL) | 591 if (iParent != NULL) |
593 { | 592 { |
594 Alembic::Abc::OObject obj = iParent->getObject(); | 593 Alembic::Abc::OObject obj = iParent->getObject(); |
595 MayaMeshWriterPtr mesh(new MayaMeshWriter(mCurDag, obj, | 594 MayaMeshWriterPtr mesh(new MayaMeshWriter(mCurDag, obj, |
596 mShapeTimeIndex, mWriteVisibility, mWriteUVs, mShapesStatic)); | 595 mShapeTimeIndex, mArgs)); |
597 | 596 |
598 if (mesh->isAnimated() && !mShapesStatic) | 597 if (mesh->isAnimated() && mShapeTimeIndex != 0) |
599 { | 598 { |
600 MayaNodePtr nd = mesh; | 599 MayaNodePtr nd = mesh; |
601 mShapeList.push_back(nd); | 600 mShapeList.push_back(nd); |
602 if (mesh->isSubD()) | 601 if (mesh->isSubD()) |
603 { | 602 { |
604 mStats.mSubDAnimNum++; | 603 mStats.mSubDAnimNum++; |
605 mStats.mSubDAnimCVs += mesh->getNumCVs(); | 604 mStats.mSubDAnimCVs += mesh->getNumCVs(); |
606 mStats.mSubDAnimFaces += mesh->getNumFaces(); | 605 mStats.mSubDAnimFaces += mesh->getNumFaces(); |
607 } | 606 } |
608 else | 607 else |
(...skipping 13 matching lines...) Expand all Loading... |
622 } | 621 } |
623 else | 622 else |
624 { | 623 { |
625 mStats.mPolyStaticNum++; | 624 mStats.mPolyStaticNum++; |
626 mStats.mPolyStaticCVs += mesh->getNumCVs(); | 625 mStats.mPolyStaticCVs += mesh->getNumCVs(); |
627 mStats.mPolyStaticFaces += mesh->getNumFaces(); | 626 mStats.mPolyStaticFaces += mesh->getNumFaces(); |
628 } | 627 } |
629 } | 628 } |
630 | 629 |
631 AttributesWriterPtr attrs = mesh->getAttrs(); | 630 AttributesWriterPtr attrs = mesh->getAttrs(); |
632 if (!mShapesStatic && attrs->isAnimated()) | 631 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
633 mShapeAttrList.push_back(attrs); | 632 mShapeAttrList.push_back(attrs); |
634 } | 633 } |
635 else | 634 else |
636 { | 635 { |
637 MString err = "Can't translate "; | 636 MString err = "Can't translate "; |
638 err += fnMesh.name() + " since it doesn't have a parent."; | 637 err += fnMesh.name() + " since it doesn't have a parent."; |
639 MGlobal::displayError(err); | 638 MGlobal::displayError(err); |
640 } | 639 } |
641 } | 640 } |
642 else if (ob.hasFn(MFn::kCamera)) | 641 else if (ob.hasFn(MFn::kCamera)) |
643 { | 642 { |
644 MFnCamera fnCamera(ob, &status); | 643 MFnCamera fnCamera(ob, &status); |
645 if (status != MS::kSuccess) | 644 if (status != MS::kSuccess) |
646 { | 645 { |
647 MString msg = "Initialize camera node "; | 646 MString msg = "Initialize camera node "; |
648 msg += mCurDag.fullPathName(); | 647 msg += mCurDag.fullPathName(); |
649 msg += " failed, skipping."; | 648 msg += " failed, skipping."; |
650 MGlobal::displayWarning(msg); | 649 MGlobal::displayWarning(msg); |
651 return; | 650 return; |
652 } | 651 } |
653 | 652 |
654 if (iParent != NULL) | 653 if (iParent != NULL) |
655 { | 654 { |
656 Alembic::Abc::OObject obj = iParent->getObject(); | 655 Alembic::Abc::OObject obj = iParent->getObject(); |
657 MayaCameraWriterPtr camera(new MayaCameraWriter( | 656 MayaCameraWriterPtr camera(new MayaCameraWriter( |
658 mCurDag, obj, mShapeTimeIndex, mWriteVisibility, | 657 mCurDag, obj, mShapeTimeIndex, mArgs)); |
659 mShapesStatic)); | |
660 | 658 |
661 if (camera->isAnimated() && !mShapesStatic) | 659 if (camera->isAnimated() && mShapeTimeIndex != 0) |
662 { | 660 { |
663 MayaNodePtr nd = camera; | 661 MayaNodePtr nd = camera; |
664 mShapeList.push_back(nd); | 662 mShapeList.push_back(nd); |
665 mStats.mCameraAnimNum++; | 663 mStats.mCameraAnimNum++; |
666 } | 664 } |
667 else | 665 else |
668 mStats.mCameraStaticNum++; | 666 mStats.mCameraStaticNum++; |
669 | 667 |
670 AttributesWriterPtr attrs = camera->getAttrs(); | 668 AttributesWriterPtr attrs = camera->getAttrs(); |
671 if (!mShapesStatic && attrs->isAnimated()) | 669 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
672 mShapeAttrList.push_back(attrs); | 670 mShapeAttrList.push_back(attrs); |
673 } | 671 } |
674 else | 672 else |
675 { | 673 { |
676 MString err = "Can't translate "; | 674 MString err = "Can't translate "; |
677 err += fnCamera.name() + " since it doesn't have a parent."; | 675 err += fnCamera.name() + " since it doesn't have a parent."; |
678 MGlobal::displayError(err); | 676 MGlobal::displayError(err); |
679 } | 677 } |
680 } | 678 } |
681 /* | |
682 else if (ob.hasFn(MFn::kNurbsSurface)) | 679 else if (ob.hasFn(MFn::kNurbsSurface)) |
683 { | 680 { |
684 MFnNurbsSurface fnNurbsSurface(ob, &status); | 681 MFnNurbsSurface fnNurbsSurface(ob, &status); |
685 if (status != MS::kSuccess) | 682 if (status != MS::kSuccess) |
686 { | 683 { |
687 MString msg = "Initialize nurbs surface "; | 684 MString msg = "Initialize nurbs surface "; |
688 msg += mCurDag.fullPathName(); | 685 msg += mCurDag.fullPathName(); |
689 msg += " failed, skipping."; | 686 msg += " failed, skipping."; |
690 MGlobal::displayWarning(msg); | 687 MGlobal::displayWarning(msg); |
691 return; | 688 return; |
692 } | 689 } |
693 | 690 |
694 if (iParent != NULL) | 691 if (iParent != NULL) |
695 { | 692 { |
696 Alembic::Abc::OObject obj = iParent->getObject(); | 693 Alembic::Abc::OObject obj = iParent->getObject(); |
697 MayaNurbsSurfaceWriterPtr nurbsSurface(new MayaNurbsSurfaceWriter( | 694 MayaNurbsSurfaceWriterPtr nurbsSurface(new MayaNurbsSurfaceWriter( |
698 mCurDag, obj, mWriteVisibility, mShapesStatic)); | 695 mCurDag, obj, mShapeTimeIndex, mArgs)); |
699 | 696 |
700 if (nurbsSurface->isAnimated() && !mShapesStatic) | 697 if (nurbsSurface->isAnimated() && mShapeTimeIndex != 0) |
701 { | 698 { |
702 MayaNodePtr nd = nurbsSurface; | 699 MayaNodePtr nd = nurbsSurface; |
703 mShapeList.push_back(nd); | 700 mShapeList.push_back(nd); |
704 mStats.mNurbsAnimNum++; | 701 mStats.mNurbsAnimNum++; |
705 mStats.mNurbsAnimCVs += nurbsSurface->getNumCVs(); | 702 mStats.mNurbsAnimCVs += nurbsSurface->getNumCVs(); |
706 } | 703 } |
707 else | 704 else |
708 { | 705 { |
709 mStats.mNurbsStaticNum++; | 706 mStats.mNurbsStaticNum++; |
710 mStats.mNurbsStaticCVs += nurbsSurface->getNumCVs(); | 707 mStats.mNurbsStaticCVs += nurbsSurface->getNumCVs(); |
711 } | 708 } |
712 | 709 |
713 AttributesWriterPtr attrs = camera->getAttrs(); | 710 AttributesWriterPtr attrs = nurbsSurface->getAttrs(); |
714 if (!mShapesStatic && attrs->isAnimated()) | 711 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
715 mShapeAttrList.push_back(attrs); | 712 mShapeAttrList.push_back(attrs); |
716 } | 713 } |
717 else | 714 else |
718 { | 715 { |
719 MString err = "Can't translate "; | 716 MString err = "Can't translate "; |
720 err += fnNurbsSurface.name() + " since it doesn't have a parent."; | 717 err += fnNurbsSurface.name() + " since it doesn't have a parent."; |
721 MGlobal::displayError(err); | 718 MGlobal::displayError(err); |
722 } | 719 } |
723 } | 720 } |
724 */ | |
725 else if (ob.hasFn(MFn::kNurbsCurve)) | 721 else if (ob.hasFn(MFn::kNurbsCurve)) |
726 { | 722 { |
727 MFnNurbsCurve fnNurbsCurve(ob, &status); | 723 MFnNurbsCurve fnNurbsCurve(ob, &status); |
728 if (status != MS::kSuccess) | 724 if (status != MS::kSuccess) |
729 { | 725 { |
730 MString msg = "Initialize curve node "; | 726 MString msg = "Initialize curve node "; |
731 msg += mCurDag.fullPathName(); | 727 msg += mCurDag.fullPathName(); |
732 msg += " failed, skipping."; | 728 msg += " failed, skipping."; |
733 MGlobal::displayWarning(msg); | 729 MGlobal::displayWarning(msg); |
734 return; | 730 return; |
735 } | 731 } |
736 | 732 |
737 if (iParent != NULL) | 733 if (iParent != NULL) |
738 { | 734 { |
739 Alembic::Abc::OObject obj = iParent->getObject(); | 735 Alembic::Abc::OObject obj = iParent->getObject(); |
740 MayaNurbsCurveWriterPtr nurbsCurve(new MayaNurbsCurveWriter( | 736 MayaNurbsCurveWriterPtr nurbsCurve(new MayaNurbsCurveWriter( |
741 mCurDag, obj, mShapeTimeIndex, false, mWriteVisibility, | 737 mCurDag, obj, mShapeTimeIndex, false, mArgs)); |
742 mShapesStatic)); | |
743 | 738 |
744 if (nurbsCurve->isAnimated() && !mShapesStatic) | 739 if (nurbsCurve->isAnimated() && mShapeTimeIndex != 0) |
745 { | 740 { |
746 MayaNodePtr nd = nurbsCurve; | 741 MayaNodePtr nd = nurbsCurve; |
747 mShapeList.push_back(nd); | 742 mShapeList.push_back(nd); |
748 mStats.mCurveAnimNum++; | 743 mStats.mCurveAnimNum++; |
749 mStats.mCurveAnimCurves++; | 744 mStats.mCurveAnimCurves++; |
750 mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); | 745 mStats.mCurveAnimCVs += nurbsCurve->getNumCVs(); |
751 } | 746 } |
752 else | 747 else |
753 { | 748 { |
754 mStats.mCurveStaticNum++; | 749 mStats.mCurveStaticNum++; |
755 mStats.mCurveStaticCurves++; | 750 mStats.mCurveStaticCurves++; |
756 mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); | 751 mStats.mCurveStaticCVs += nurbsCurve->getNumCVs(); |
757 } | 752 } |
758 | 753 |
759 AttributesWriterPtr attrs = nurbsCurve->getAttrs(); | 754 AttributesWriterPtr attrs = nurbsCurve->getAttrs(); |
760 if (!mShapesStatic && attrs->isAnimated()) | 755 if (mShapeTimeIndex != 0 && attrs->isAnimated()) |
761 mShapeAttrList.push_back(attrs); | 756 mShapeAttrList.push_back(attrs); |
762 } | 757 } |
763 else | 758 else |
764 { | 759 { |
765 MString err = "Can't translate "; | 760 MString err = "Can't translate "; |
766 err += fnNurbsCurve.name() + " since it doesn't have a parent."; | 761 err += fnNurbsCurve.name() + " since it doesn't have a parent."; |
767 MGlobal::displayError(err); | 762 MGlobal::displayError(err); |
768 } | 763 } |
769 } | 764 } |
770 else | 765 else |
771 { | 766 { |
772 MString warn = mCurDag.fullPathName() + " is an unsupported type of "; | 767 MString warn = mCurDag.fullPathName() + " is an unsupported type of "; |
773 warn += ob.apiTypeStr(); | 768 warn += ob.apiTypeStr(); |
774 MGlobal::displayWarning(warn); | 769 MGlobal::displayWarning(warn); |
775 } | 770 } |
776 } | 771 } |
777 | 772 |
778 | 773 |
779 AbcWriteJob::~AbcWriteJob() | 774 AbcWriteJob::~AbcWriteJob() |
780 { | 775 { |
781 } | 776 } |
782 | 777 |
783 bool AbcWriteJob::eval(double iFrame) | 778 bool AbcWriteJob::eval(double iFrame) |
784 { | 779 { |
785 if (iFrame == mFirstFrame) | 780 if (iFrame == mFirstFrame) |
786 { | 781 { |
787 // check if the shortnames of any two nodes are the same | 782 // check if the shortnames of any two nodes are the same |
788 // if so, exit here | 783 // if so, exit here |
789 if (hasDuplicates(mDagPath)) | 784 if (hasDuplicates(mArgs.dagPaths)) |
790 { | 785 { |
791 throw std::runtime_error("The names of root nodes are the same"); | 786 throw std::runtime_error("The names of root nodes are the same"); |
792 } | 787 } |
793 | 788 |
794 mRoot = Alembic::Abc::OArchive( Alembic::AbcCoreHDF5::WriteArchive(), | 789 mRoot = Alembic::Abc::OArchive( Alembic::AbcCoreHDF5::WriteArchive(), |
795 mFileName, Alembic::Abc::ErrorHandler::kThrowPolicy ); | 790 mFileName, Alembic::Abc::ErrorHandler::kThrowPolicy ); |
796 mShapeTimeIndex = mRoot.addTimeSampling(*mShapeTime); | 791 mShapeTimeIndex = mRoot.addTimeSampling(*mShapeTime); |
797 mTransTimeIndex = mRoot.addTimeSampling(*mTransTime); | 792 mTransTimeIndex = mRoot.addTimeSampling(*mTransTime); |
798 | 793 |
799 mBoxProp = Alembic::Abc::OBox3dProperty(mRoot.getTop().getProperties(), | 794 mBoxProp = Alembic::Abc::OBox3dProperty(mRoot.getTop().getProperties(), |
800 ".childBnds", mTransTimeIndex); | 795 ".childBnds", mTransTimeIndex); |
801 | 796 |
802 if (!mRoot.valid()) | 797 if (!mRoot.valid()) |
803 { | 798 { |
804 MGlobal::displayError("Unable to create abc file"); | 799 MGlobal::displayError("Unable to create abc file"); |
805 throw std::runtime_error("Unable to create abc file"); | 800 throw std::runtime_error("Unable to create abc file"); |
806 } | 801 } |
807 | 802 |
808 AttributesWriter::mFilter = &mFilter; | 803 util::ShapeSet::const_iterator end = mArgs.dagPaths.end(); |
809 AttributesWriter::mAttribs = &mAttribs; | 804 for (util::ShapeSet::const_iterator it = mArgs.dagPaths.begin(); |
810 | 805 it != end; ++it) |
811 const std::set< MDagPath >::iterator end = mDagPath.end(); | |
812 for (std::set< MDagPath >::iterator it = mDagPath.begin(); it != end; it
++) | |
813 { | 806 { |
814 mCurDag = *it; | 807 mCurDag = *it; |
815 setup(iFrame * util::spf(), MayaTransformWriterPtr()); | 808 setup(iFrame * util::spf(), MayaTransformWriterPtr()); |
816 } | 809 } |
817 perFrameCallback(iFrame); | 810 perFrameCallback(iFrame); |
818 } | 811 } |
819 else | 812 else |
820 { | 813 { |
821 std::set<double>::iterator checkFrame = mShapeFrames.find(iFrame); | 814 std::set<double>::iterator checkFrame = mShapeFrames.find(iFrame); |
822 bool foundShapeFrame = false; | 815 bool foundShapeFrame = false; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 return true; | 883 return true; |
891 } | 884 } |
892 | 885 |
893 return false; | 886 return false; |
894 } | 887 } |
895 | 888 |
896 void AbcWriteJob::perFrameCallback(double iFrame) | 889 void AbcWriteJob::perFrameCallback(double iFrame) |
897 { | 890 { |
898 MBoundingBox bbox; | 891 MBoundingBox bbox; |
899 | 892 |
900 util::ShapeSet::iterator it = mDagPath.begin(); | 893 util::ShapeSet::iterator it = mArgs.dagPaths.begin(); |
901 const util::ShapeSet::iterator end = mDagPath.end(); | 894 const util::ShapeSet::iterator end = mArgs.dagPaths.end(); |
902 for (; it != end; it ++) | 895 for (; it != end; it ++) |
903 { | 896 { |
904 mCurDag = *it; | 897 mCurDag = *it; |
905 | 898 |
906 mCurBBox.clear(); | 899 mCurBBox.clear(); |
907 MMatrix eMInvMat; | 900 MMatrix eMInvMat; |
908 if (mWorldSpace) | 901 if (mArgs.worldSpace) |
909 { | 902 { |
910 eMInvMat.setToIdentity(); | 903 eMInvMat.setToIdentity(); |
911 } | 904 } |
912 else | 905 else |
913 { | 906 { |
914 eMInvMat = mCurDag.exclusiveMatrixInverse(); | 907 eMInvMat = mCurDag.exclusiveMatrixInverse(); |
915 } | 908 } |
916 | 909 |
917 getBoundingBox(eMInvMat); | 910 getBoundingBox(eMInvMat); |
918 bbox.expand(mCurBBox); | 911 bbox.expand(mCurBBox); |
919 } | 912 } |
920 | 913 |
921 Alembic::Abc::V3d min(bbox.min().x, bbox.min().y, bbox.min().z); | 914 Alembic::Abc::V3d min(bbox.min().x, bbox.min().y, bbox.min().z); |
922 Alembic::Abc::V3d max(bbox.max().x, bbox.max().y, bbox.max().z); | 915 Alembic::Abc::V3d max(bbox.max().x, bbox.max().y, bbox.max().z); |
923 Alembic::Abc::Box3d b(min, max); | 916 Alembic::Abc::Box3d b(min, max); |
924 mBoxProp.set(b); | 917 mBoxProp.set(b); |
925 | 918 |
926 processCallback(mMelPerFrameCallback, true, iFrame, bbox); | 919 processCallback(mArgs.melPerFrameCallback, true, iFrame, bbox); |
927 processCallback(mPythonPerFrameCallback, false, iFrame, bbox); | 920 processCallback(mArgs.pythonPerFrameCallback, false, iFrame, bbox); |
928 } | 921 } |
929 | 922 |
930 | 923 |
931 // write the frame ranges and statistic string on the root | 924 // write the frame ranges and statistic string on the root |
932 // Also call the post callbacks | 925 // Also call the post callbacks |
933 void AbcWriteJob::postCallback(double iFrame) | 926 void AbcWriteJob::postCallback(double iFrame) |
934 { | 927 { |
935 std::string statsStr = ""; | 928 std::string statsStr = ""; |
936 | 929 |
937 addToString(statsStr, "SubDStaticNum", mStats.mSubDStaticNum); | 930 addToString(statsStr, "SubDStaticNum", mStats.mSubDStaticNum); |
(...skipping 23 matching lines...) Expand all Loading... |
961 addToString(statsStr, "PointAnimCVs", mStats.mPointAnimCVs); | 954 addToString(statsStr, "PointAnimCVs", mStats.mPointAnimCVs); |
962 | 955 |
963 addToString(statsStr, "NurbsStaticNum", mStats.mNurbsStaticNum); | 956 addToString(statsStr, "NurbsStaticNum", mStats.mNurbsStaticNum); |
964 addToString(statsStr, "NurbsAnimNum", mStats.mNurbsAnimNum); | 957 addToString(statsStr, "NurbsAnimNum", mStats.mNurbsAnimNum); |
965 addToString(statsStr, "NurbsStaticCVs", mStats.mNurbsStaticCVs); | 958 addToString(statsStr, "NurbsStaticCVs", mStats.mNurbsStaticCVs); |
966 addToString(statsStr, "NurbsAnimCVs", mStats.mNurbsAnimCVs); | 959 addToString(statsStr, "NurbsAnimCVs", mStats.mNurbsAnimCVs); |
967 | 960 |
968 addToString(statsStr, "TransStaticNum", mStats.mTransStaticNum); | 961 addToString(statsStr, "TransStaticNum", mStats.mTransStaticNum); |
969 addToString(statsStr, "TransAnimNum", mStats.mTransAnimNum); | 962 addToString(statsStr, "TransAnimNum", mStats.mTransAnimNum); |
970 | 963 |
| 964 addToString(statsStr, "LocatorStaticNum", mStats.mLocatorStaticNum); |
| 965 addToString(statsStr, "LocatorAnimNum", mStats.mLocatorAnimNum); |
| 966 |
971 addToString(statsStr, "CameraStaticNum", mStats.mCameraStaticNum); | 967 addToString(statsStr, "CameraStaticNum", mStats.mCameraStaticNum); |
972 addToString(statsStr, "CameraAnimNum", mStats.mCameraAnimNum); | 968 addToString(statsStr, "CameraAnimNum", mStats.mCameraAnimNum); |
973 | 969 |
974 addToString(statsStr, "GenericNum", mStats.mGenericNum); | |
975 | |
976 if (statsStr.length() > 0) | 970 if (statsStr.length() > 0) |
977 { | 971 { |
978 Alembic::Abc::OStringProperty stats(mRoot.getTop().getProperties(), | 972 Alembic::Abc::OStringProperty stats(mRoot.getTop().getProperties(), |
979 "statistics"); | 973 "statistics"); |
980 stats.set(statsStr); | 974 stats.set(statsStr); |
981 } | 975 } |
982 | 976 |
983 MBoundingBox bbox; | 977 MBoundingBox bbox; |
984 | 978 |
985 if (mMelPostCallback.find("#BOUNDS#") != std::string::npos || | 979 if (mArgs.melPostCallback.find("#BOUNDS#") != std::string::npos || |
986 mPythonPostCallback.find("#BOUNDS#") != std::string::npos || | 980 mArgs.pythonPostCallback.find("#BOUNDS#") != std::string::npos || |
987 mMelPostCallback.find("#BOUNDSARRAY#") != std::string::npos || | 981 mArgs.melPostCallback.find("#BOUNDSARRAY#") != std::string::npos || |
988 mPythonPostCallback.find("#BOUNDSARRAY#") != std::string::npos) | 982 mArgs.pythonPostCallback.find("#BOUNDSARRAY#") != std::string::npos) |
989 { | 983 { |
990 util::ShapeSet::iterator it = mDagPath.begin(); | 984 util::ShapeSet::const_iterator it = mArgs.dagPaths.begin(); |
991 const util::ShapeSet::iterator end = mDagPath.end(); | 985 const util::ShapeSet::const_iterator end = mArgs.dagPaths.end(); |
992 for (; it != end; it ++) | 986 for (; it != end; it ++) |
993 { | 987 { |
994 mCurDag = *it; | 988 mCurDag = *it; |
995 | 989 |
996 mCurBBox.clear(); | 990 mCurBBox.clear(); |
997 MMatrix eMInvMat; | 991 MMatrix eMInvMat; |
998 if (mWorldSpace) | 992 if (mArgs.worldSpace) |
999 { | 993 { |
1000 eMInvMat.setToIdentity(); | 994 eMInvMat.setToIdentity(); |
1001 } | 995 } |
1002 else | 996 else |
1003 { | 997 { |
1004 eMInvMat = mCurDag.exclusiveMatrixInverse(); | 998 eMInvMat = mCurDag.exclusiveMatrixInverse(); |
1005 } | 999 } |
1006 | 1000 |
1007 getBoundingBox(eMInvMat); | 1001 getBoundingBox(eMInvMat); |
1008 bbox.expand(mCurBBox); | 1002 bbox.expand(mCurBBox); |
1009 } | 1003 } |
1010 } | 1004 } |
1011 | 1005 |
1012 processCallback(mMelPostCallback, true, iFrame, bbox); | 1006 processCallback(mArgs.melPostCallback, true, iFrame, bbox); |
1013 processCallback(mPythonPostCallback, false, iFrame, bbox); | 1007 processCallback(mArgs.pythonPostCallback, false, iFrame, bbox); |
1014 } | 1008 } |
1015 | 1009 |
1016 | 1010 |
OLD | NEW |