Skip to content

Commit

Permalink
Merge pull request #43 from LumaPictures/pr/use_PxrUsdMayaXformStack
Browse files Browse the repository at this point in the history
Change transform translation to use PxrUsdMayaXformStack, the same object used in usd plugin
  • Loading branch information
fabal authored Feb 7, 2018
2 parents ee65ad9 + 3cdd9f9 commit c364f7e
Show file tree
Hide file tree
Showing 17 changed files with 1,425 additions and 958 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ else()
find_package(Qt4 REQUIRED QtGui)
endif()

include_directories(${PXR_INCLUDE_DIRS})
include_directories(${PXR_INCLUDE_DIRS} ${PXR_CMAKE_DIR}/third_party/maya/include)
link_directories(${PXR_CMAKE_DIR}/third_party/maya/lib)

# FindBoost is particularly buggy, and doesn't like custom boost locations.
# Adding specific components forces calls to _Boost_find_library, which
Expand Down
138 changes: 0 additions & 138 deletions lib/AL_USDMaya/AL/usdmaya/TransformOperation.cpp

This file was deleted.

78 changes: 0 additions & 78 deletions lib/AL_USDMaya/AL/usdmaya/TransformOperation.h

This file was deleted.

46 changes: 5 additions & 41 deletions lib/AL_USDMaya/AL/usdmaya/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,48 +36,12 @@ namespace AL {
namespace usdmaya {

//----------------------------------------------------------------------------------------------------------------------
void matrixToSRT(GfMatrix4d& value, double S[3], MEulerRotation& R, double T[3])
MTransformationMatrix matrixToMTransformationMatrix(GfMatrix4d& value)
{
double matrix[4][4];
value.Get(matrix);
T[0] = matrix[3][0];
T[1] = matrix[3][1];
T[2] = matrix[3][2];
MVector xAxis(matrix[0][0], matrix[0][1], matrix[0][2]);
MVector yAxis(matrix[1][0], matrix[1][1], matrix[1][2]);
MVector zAxis(matrix[2][0], matrix[2][1], matrix[2][2]);
double scaleX = xAxis.length();
double scaleY = yAxis.length();
double scaleZ = zAxis.length();
xAxis /= scaleX;
yAxis /= scaleY;
zAxis /= scaleZ;
bool isNegated = ((xAxis ^ yAxis) * zAxis) < 0.0;
if(isNegated)
{
zAxis = -zAxis;
scaleZ = -scaleZ;
}
S[0] = scaleX;
S[1] = scaleY;
S[2] = scaleZ;
matrix[0][0] = xAxis.x;
matrix[0][1] = xAxis.y;
matrix[0][2] = xAxis.z;
matrix[0][3] = 0;
matrix[1][0] = yAxis.x;
matrix[1][1] = yAxis.y;
matrix[1][2] = yAxis.z;
matrix[1][3] = 0;
matrix[2][0] = zAxis.x;
matrix[2][1] = zAxis.y;
matrix[2][2] = zAxis.z;
matrix[2][3] = 0;
matrix[3][0] = 0;
matrix[3][1] = 0;
matrix[3][2] = 0;
matrix[3][3] = 1.0;
R = MMatrix(matrix);
MMatrix mayaMatrix;
// maya matrices and pxr matrices share same ordering, so can copy direcly into MMatrix's storage
value.Get(mayaMatrix.matrix);
return MTransformationMatrix(mayaMatrix);
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down
10 changes: 4 additions & 6 deletions lib/AL_USDMaya/AL/usdmaya/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,12 @@ namespace usdmaya {
MString mapUsdPrimToMayaNode(const UsdPrim& usdPrim, const MObject& mayaObject, const MDagPath* const proxyShapeNode = nullptr);

//----------------------------------------------------------------------------------------------------------------------
/// \brief convert a 4x4 matrix to an SRT transformation. Assumes that there is no shearing.
/// \param value the 4x4 matrix to extract the TRS values from
/// \param S the returned scale value
/// \param R the returned euler rotation values
/// \param T the returned translation values
/// \brief convert a 4x4 matrix to a Maya MTransformationMatrix, for decomposition
/// \param value the input pixar 4x4 matrix
/// \return the MTransformationMatrix, which can be queried for individual xform components
/// \ingroup usdmaya
//----------------------------------------------------------------------------------------------------------------------
void matrixToSRT(GfMatrix4d& value, double S[3], MEulerRotation& R, double T[3]);
MTransformationMatrix matrixToMTransformationMatrix(GfMatrix4d& value);

//----------------------------------------------------------------------------------------------------------------------
/// \brief convert string types
Expand Down
Loading

0 comments on commit c364f7e

Please sign in to comment.