1 // 2 // Copyright 2021 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 //////////////////////////////////////////////////////////////////////// 25 // This file is generated by a script. Do not edit directly. Edit the 26 // schema.template.h file to make changes. 27 28 #ifndef PXR_IMAGING_HD_PRIMVAR_SCHEMA_H 29 #define PXR_IMAGING_HD_PRIMVAR_SCHEMA_H 30 31 #include "pxr/imaging/hd/api.h" 32 33 #include "pxr/imaging/hd/schema.h" 34 35 PXR_NAMESPACE_OPEN_SCOPE 36 37 //----------------------------------------------------------------------------- 38 39 #define HDPRIMVAR_SCHEMA_TOKENS \ 40 (primvarValue) \ 41 (indexedPrimvarValue) \ 42 (indices) \ 43 (interpolation) \ 44 (role) \ 45 (constant) \ 46 (uniform) \ 47 (varying) \ 48 (vertex) \ 49 (faceVarying) \ 50 (instance) \ 51 (Point) \ 52 (Normal) \ 53 (Vector) \ 54 (Color) \ 55 (PointIndex) \ 56 (EdgeIndex) \ 57 (FaceIndex) \ 58 (TextureCoordinate) \ 59 (Transform) \ 60 61 TF_DECLARE_PUBLIC_TOKENS(HdPrimvarSchemaTokens, HD_API, 62 HDPRIMVAR_SCHEMA_TOKENS); 63 64 //----------------------------------------------------------------------------- 65 66 class HdPrimvarSchema : public HdSchema 67 { 68 public: HdPrimvarSchema(HdContainerDataSourceHandle container)69 HdPrimvarSchema(HdContainerDataSourceHandle container) 70 : HdSchema(container) {} 71 72 //ACCESSORS 73 74 75 // If the primvar does not have indices, GetPrimvarValue() and 76 // GetIndexedPrimvarValue() will return the same thing. If the primvar 77 // does has indices, GetPrimvarValue() will return the flattened value, 78 // while GetIndexedPrimvarValue() will return the unflattened value. 79 HD_API 80 HdSampledDataSourceHandle GetPrimvarValue(); 81 HD_API 82 HdSampledDataSourceHandle GetIndexedPrimvarValue(); 83 HD_API 84 HdIntArrayDataSourceHandle GetIndices(); 85 HD_API 86 HdTokenDataSourceHandle GetInterpolation(); 87 HD_API 88 HdTokenDataSourceHandle GetRole(); 89 90 // RETRIEVING AND CONSTRUCTING 91 92 /// Builds a container data source which includes the provided child data 93 /// sources. Parameters with nullptr values are excluded. This is a 94 /// low-level interface. For cases in which it's desired to define 95 /// the container with a sparse set of child fields, the Builder class 96 /// is often more convenient and readable. 97 HD_API 98 static HdContainerDataSourceHandle 99 BuildRetained( 100 const HdSampledDataSourceHandle &primvarValue, 101 const HdSampledDataSourceHandle &indexedPrimvarValue, 102 const HdIntArrayDataSourceHandle &indices, 103 const HdTokenDataSourceHandle &interpolation, 104 const HdTokenDataSourceHandle &role 105 ); 106 107 /// \class HdPrimvarSchema::Builder 108 /// 109 /// Utility class for setting sparse sets of child data source fields to be 110 /// filled as arguments into BuildRetained. Because all setter methods 111 /// return a reference to the instance, this can be used in the "builder 112 /// pattern" form. 113 class Builder 114 { 115 public: 116 HD_API 117 Builder &SetPrimvarValue( 118 const HdSampledDataSourceHandle &primvarValue); 119 HD_API 120 Builder &SetIndexedPrimvarValue( 121 const HdSampledDataSourceHandle &indexedPrimvarValue); 122 HD_API 123 Builder &SetIndices( 124 const HdIntArrayDataSourceHandle &indices); 125 HD_API 126 Builder &SetInterpolation( 127 const HdTokenDataSourceHandle &interpolation); 128 HD_API 129 Builder &SetRole( 130 const HdTokenDataSourceHandle &role); 131 132 /// Returns a container data source containing the members set thus far. 133 HD_API 134 HdContainerDataSourceHandle Build(); 135 136 private: 137 HdSampledDataSourceHandle _primvarValue; 138 HdSampledDataSourceHandle _indexedPrimvarValue; 139 HdIntArrayDataSourceHandle _indices; 140 HdTokenDataSourceHandle _interpolation; 141 HdTokenDataSourceHandle _role; 142 }; 143 // Returns true if it contains data sources for an indexed primvar value 144 // and for indices. 145 bool IsIndexed(); 146 147 148 /// Returns token data source for use as interpolation value. 149 /// Values of... 150 /// - HdPrimvarSchemaTokens->constant 151 /// - HdPrimvarSchemaTokens->uniform 152 /// - HdPrimvarSchemaTokens->varying 153 /// - HdPrimvarSchemaTokens->vertex 154 /// - HdPrimvarSchemaTokens->faceVarying 155 /// - HdPrimvarSchemaTokens->instance 156 /// ...will be stored statically and reused for future calls. 157 HD_API 158 static HdTokenDataSourceHandle BuildInterpolationDataSource( 159 const TfToken &interpolation); 160 /// Returns token data source for use as role value. 161 /// Values of... 162 /// - HdPrimvarSchemaTokens->Point 163 /// - HdPrimvarSchemaTokens->Normal 164 /// - HdPrimvarSchemaTokens->Vector 165 /// - HdPrimvarSchemaTokens->Color 166 /// - HdPrimvarSchemaTokens->PointIndex 167 /// - HdPrimvarSchemaTokens->EdgeIndex 168 /// - HdPrimvarSchemaTokens->FaceIndex 169 /// - HdPrimvarSchemaTokens->TextureCoordinate 170 /// ...will be stored statically and reused for future calls. 171 HD_API 172 static HdTokenDataSourceHandle BuildRoleDataSource( 173 const TfToken &role); 174 175 }; 176 177 PXR_NAMESPACE_CLOSE_SCOPE 178 179 #endif