// // Copyright 2013 Pixar // // Licensed under the Apache License, Version 2.0 (the "Apache License") // with the following modification; you may not use this file except in // compliance with the Apache License and the following modification to it: // Section 6. Trademarks. is deleted and replaced with: // // 6. Trademarks. This License does not grant permission to use the trade // names, trademarks, service marks, or product names of the Licensor // and its affiliates, except as required to comply with Section 4(c) of // the License and to reproduce the content of the NOTICE file. // // You may obtain a copy of the Apache License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the Apache License with the above modification is // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the Apache License for the specific // language governing permissions and limitations under the Apache License. // #ifndef EXAMPLES_MAYAVIEWER_HBRUTIL_H_ #define EXAMPLES_MAYAVIEWER_HBRUTIL_H_ #include // need to define HBR_ADAPTIVE #include #include #include typedef OpenSubdiv::HbrMesh OsdHbrMesh; typedef OpenSubdiv::HbrVertex OsdHbrVertex; typedef OpenSubdiv::HbrFace OsdHbrFace; typedef OpenSubdiv::HbrHalfedge OsdHbrHalfedge; typedef OpenSubdiv::HbrFVarData OsdHbrFVarData; // XXX placeholder for enums used by ConvertToHBR // would be nice if these came from OsdHbrMesh, is there a util // class where these could live? typedef struct { enum SchemeType { kCatmark=0, kLoop=1, kBilinear=2 }; } HbrMeshUtil; // // Face-varying data descriptor // Wrapper for basic information needed to request // face-varying data allocation from HBR // class FVarDataDesc { public: // Must be instantiated with descriptor information FVarDataDesc( int count, const int *indices, // start index for each face-varying variable const int *widths, // width for each face-varying variable int width, OsdHbrMesh::InterpolateBoundaryMethod boundary=OsdHbrMesh::k_InterpolateBoundaryNone ) { _fvarCount = count; _totalfvarWidth = width; _fvarIndices.assign( indices, indices+count ); _fvarWidths.assign( widths, widths+count ); _interpBoundary = boundary; } ~FVarDataDesc() {} // Accessors int getCount() const { return _fvarCount; } const int *getIndices() const { return &_fvarIndices.front(); } const int *getWidths() const { return &_fvarWidths.front(); } int getTotalWidth() const { return _totalfvarWidth; } OsdHbrMesh::InterpolateBoundaryMethod getInterpBoundary() const { return _interpBoundary; } private: // Number of facevarying datums int _fvarCount; // Start indices of the facevarying data we want to store std::vector _fvarIndices; // Individual widths of the facevarying data we want to store std::vector _fvarWidths; // Total widths of the facevarying data int _totalfvarWidth; // How to interpolate boundaries OsdHbrMesh::InterpolateBoundaryMethod _interpBoundary; }; extern "C" OsdHbrMesh * ConvertToHBR( int nVertices, std::vector const & faceVertCounts, std::vector const & faceIndices, std::vector const & vtxCreaseIndices, std::vector const & vtxCreases, std::vector const & edgeCrease1Indices, std::vector const & edgeCreases1, std::vector const & edgeCrease2Indices, std::vector const & edgeCreases2, OsdHbrMesh::InterpolateBoundaryMethod interpBoundary, HbrMeshUtil::SchemeType scheme, bool usingPtex=false, FVarDataDesc const * fvarDesc=NULL, std::vector const * fvarData=NULL ); #endif // EXAMPLES_MAYAVIEWER_HBRUTIL_H_