-
Notifications
You must be signed in to change notification settings - Fork 203
/
Copy pathwrapMeshWriteUtils.cpp
85 lines (68 loc) · 2.36 KB
/
wrapMeshWriteUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Copyright 2017 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <string>
#include <boost/python/class.hpp>
#include <boost/python.hpp>
#include <maya/MFnMesh.h>
#include <maya/MObject.h>
#include <maya/MStatus.h>
#include <pxr/pxr.h>
#include <pxr/base/gf/vec3f.h>
#include <pxr/base/tf/pyResultConversions.h>
#include <pxr/base/tf/token.h>
#include <pxr/base/vt/array.h>
#include <mayaUsd/fileio/utils/meshWriteUtils.h>
#include <mayaUsd/utils/util.h>
using namespace boost::python;
PXR_NAMESPACE_USING_DIRECTIVE
namespace {
static
tuple
_GetMeshNormals(const std::string& meshDagPath)
{
VtArray<GfVec3f> normalsArray;
TfToken interpolation;
MObject meshObj;
MStatus status = UsdMayaUtil::GetMObjectByName(meshDagPath, meshObj);
if (status != MS::kSuccess) {
TF_CODING_ERROR("Could not get MObject for dagPath: %s",
meshDagPath.c_str());
return make_tuple(normalsArray, interpolation);
}
MFnMesh meshFn(meshObj, &status);
if (!meshObj.hasFn(MFn::kMesh)) {
TF_CODING_ERROR("MFnMesh() failed for object at dagPath: %s",
meshDagPath.c_str());
return make_tuple(normalsArray, interpolation);
}
UsdMayaMeshWriteUtils::getMeshNormals(meshObj, &normalsArray, &interpolation);
return make_tuple(normalsArray, interpolation);
}
// Dummy class for putting UsdMayaMeshWriteUtils namespace functions in a Python
// MeshWriteUtils namespace.
class DummyScopeClass{};
} // anonymous namespace
void wrapMeshWriteUtils()
{
// TODO: HS, June 11, 2020 This logics is not accurate. Revisit this later.
// There are no test cases around is not being consumed in any tests.
/*
scope s = class_<DummyScopeClass>("MeshWriteUtils", no_init)
.def("GetMeshNormals", &_GetMeshNormals)
.staticmethod("GetMeshNormals")
;
*/
}