1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #include "pxr/pxr.h"
25 #include "pxr/usd/usdRi/rmanUtilities.h"
26
27 #include "pxr/usd/usdGeom/tokens.h"
28
29 PXR_NAMESPACE_OPEN_SCOPE
30
31
32 int
UsdRiConvertToRManInterpolateBoundary(TfToken const & token)33 UsdRiConvertToRManInterpolateBoundary(TfToken const& token)
34 {
35 if(token == UsdGeomTokens->none)
36 return 0;
37 else if(token == UsdGeomTokens->edgeAndCorner)
38 return 1;
39 else if(token == UsdGeomTokens->edgeOnly)
40 return 2;
41 else{
42 TF_CODING_ERROR("Invalid InterpolateBoundary Token: %s",
43 token.GetText());
44 return 0;
45 }
46 }
47
48 TfToken const&
UsdRiConvertFromRManInterpolateBoundary(int i)49 UsdRiConvertFromRManInterpolateBoundary(int i)
50 {
51 switch(i){
52 case 0:
53 return UsdGeomTokens->none;
54 case 1:
55 return UsdGeomTokens->edgeAndCorner;
56 case 2:
57 return UsdGeomTokens->edgeOnly;
58 default:
59 TF_CODING_ERROR("Invalid InterpolateBoundary int: %d", i);
60 return UsdGeomTokens->none;
61 }
62 }
63
64 int
UsdRiConvertToRManFaceVaryingLinearInterpolation(TfToken const & token)65 UsdRiConvertToRManFaceVaryingLinearInterpolation(TfToken const& token)
66 {
67 if(token == UsdGeomTokens->all) {
68 return 0;
69 }
70 else if(token == UsdGeomTokens->cornersOnly
71 || token == UsdGeomTokens->cornersPlus1
72 || token == UsdGeomTokens->cornersPlus2) {
73 return 1;
74 }
75 else if(token == UsdGeomTokens->none) {
76 return 2;
77 }
78 else if(token == UsdGeomTokens->boundaries) {
79 return 3;
80 }
81
82 else{
83 TF_CODING_ERROR("Invalid FaceVaryingLinearInterpolation Token: %s",
84 token.GetText());
85 return 1;
86 }
87 }
88
89 TfToken const&
UsdRiConvertFromRManFaceVaryingLinearInterpolation(int i)90 UsdRiConvertFromRManFaceVaryingLinearInterpolation(int i)
91 {
92 switch(i){
93 case 0:
94 return UsdGeomTokens->all;
95 case 1:
96 return UsdGeomTokens->cornersPlus1;
97 case 2:
98 return UsdGeomTokens->none;
99 case 3:
100 return UsdGeomTokens->boundaries;
101 default:
102 TF_CODING_ERROR("Invalid FaceVaryingLinearInterpolation int: %d", i);
103 return UsdGeomTokens->none;
104 }
105 }
106
107 int
UsdRiConvertToRManTriangleSubdivisionRule(TfToken const & token)108 UsdRiConvertToRManTriangleSubdivisionRule(TfToken const& token)
109 {
110 // XXX A value of 2 is needed in order for the smoothing algorithm to work.
111 if(token == UsdGeomTokens->catmullClark) {
112 return 0;
113 }
114 else if(token == UsdGeomTokens->smooth)
115 return 2;
116 else{
117 TF_CODING_ERROR("Invalid TriangleSubdivisionRule Token: %s",
118 token.GetText());
119 return 0;
120 }
121 }
122
123 TfToken const&
UsdRiConvertFromRManTriangleSubdivisionRule(int i)124 UsdRiConvertFromRManTriangleSubdivisionRule(int i)
125 {
126 // XXX A value of 2 is needed in order for the smoothing algorithm to work.
127 switch(i){
128 case 0:
129 return UsdGeomTokens->catmullClark;
130 case 2:
131 return UsdGeomTokens->smooth;
132 default:
133 TF_CODING_ERROR("Invalid TriangleSubdivisionRule int: %d", i);
134 return UsdGeomTokens->catmullClark;
135 }
136 }
137
138
139 PXR_NAMESPACE_CLOSE_SCOPE
140
141