@@ -263,18 +263,23 @@ class vtkF3DAlembicReader::vtkInternals
263263
264264 this ->SetupIndicesStorage (faceVertexCounts, originalData.Indices );
265265
266+ // By default, Alembic is CW while VTK is CCW
267+ // So we need to reverse the order of indices only if the mesh is not mirrored
268+ const bool doReverseRotate = matrix.determinant () > 0 ;
269+
266270 // Positions
267271 {
268272 V3fContainer pV3F;
269273 for (size_t pIndex = 0 ; pIndex < positions->size (); pIndex++)
270274 {
271- const Alembic::Abc::V3f tp = positions->get ()[pIndex] * matrix;
275+ Alembic::Abc::V3f tp;
276+ matrix.multVecMatrix (positions->get ()[pIndex], tp);
272277 pV3F.emplace_back (tp.x , tp.y , tp.z );
273278 }
274279 originalData.Attributes .insert (AttributesContainer::value_type (" P" , pV3F));
275280
276281 this ->UpdateIndices <Alembic::AbcGeom::Int32ArraySamplePtr>(
277- facePositionIndices, pIndicesOffset, originalData.Indices );
282+ facePositionIndices, pIndicesOffset, originalData.Indices , doReverseRotate );
278283 }
279284
280285 // Texture coordinate
@@ -297,12 +302,12 @@ class vtkF3DAlembicReader::vtkInternals
297302 {
298303 originalData.uvFaceVarying = true ;
299304 this ->UpdateIndices <Alembic::AbcGeom::UInt32ArraySamplePtr>(
300- uvIndices, uvIndicesOffset, originalData.Indices );
305+ uvIndices, uvIndicesOffset, originalData.Indices , doReverseRotate );
301306 }
302307 else
303308 {
304309 this ->UpdateIndices <Alembic::AbcGeom::Int32ArraySamplePtr>(
305- facePositionIndices, uvIndicesOffset, originalData.Indices );
310+ facePositionIndices, uvIndicesOffset, originalData.Indices , doReverseRotate );
306311 }
307312 }
308313 }
@@ -319,8 +324,9 @@ class vtkF3DAlembicReader::vtkInternals
319324 Alembic::AbcGeom::UInt32ArraySamplePtr normalIndices = normalValue.getIndices ();
320325 for (size_t index = 0 ; index < normalValue.getVals ()->size (); ++index)
321326 {
322- Alembic::AbcGeom::V3f normal = (*(normalValue.getVals ()))[index];
323- normal_v3f.emplace_back (normal[0 ], normal[1 ], normal[2 ]);
327+ Alembic::AbcGeom::V3f normal;
328+ matrix.multDirMatrix ((*(normalValue.getVals ()))[index], normal);
329+ normal_v3f.emplace_back (normal);
324330 }
325331 originalData.Attributes .insert (AttributesContainer::value_type (" N" , normal_v3f));
326332
@@ -329,12 +335,12 @@ class vtkF3DAlembicReader::vtkInternals
329335 originalData.nFaceVarying = true ;
330336
331337 this ->UpdateIndices <Alembic::AbcGeom::UInt32ArraySamplePtr>(
332- normalIndices, nIndicesOffset, originalData.Indices );
338+ normalIndices, nIndicesOffset, originalData.Indices , doReverseRotate );
333339 }
334340 else
335341 {
336342 this ->UpdateIndices <Alembic::AbcGeom::Int32ArraySamplePtr>(
337- facePositionIndices, nIndicesOffset, originalData.Indices );
343+ facePositionIndices, nIndicesOffset, originalData.Indices , doReverseRotate );
338344 }
339345 }
340346 }
@@ -433,7 +439,7 @@ class vtkF3DAlembicReader::vtkInternals
433439 const Alembic::AbcGeom::IXformSchema& xFormSchema = xForm.getSchema ();
434440 Alembic::AbcGeom::XformSample xFormSamp;
435441 xFormSchema.get (xFormSamp, selector);
436- objMatrix = matrix * xFormSamp.getMatrix ();
442+ objMatrix = xFormSamp.getMatrix () * matrix ;
437443 }
438444
439445 objects.pop ();
0 commit comments