2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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:
|
2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 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.
|
2012-06-11 19:35:47 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifndef EXAMPLES_MAYAVIEWER_HBRUTIL_H_
|
|
|
|
#define EXAMPLES_MAYAVIEWER_HBRUTIL_H_
|
2012-06-11 18:53:35 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <far/meshFactory.h> // need to define HBR_ADAPTIVE
|
2012-09-18 01:41:48 +00:00
|
|
|
#include <hbr/mesh.h>
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <osd/vertex.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
typedef OpenSubdiv::HbrMesh<OpenSubdiv::OsdVertex> OsdHbrMesh;
|
|
|
|
typedef OpenSubdiv::HbrVertex<OpenSubdiv::OsdVertex> OsdHbrVertex;
|
|
|
|
typedef OpenSubdiv::HbrFace<OpenSubdiv::OsdVertex> OsdHbrFace;
|
|
|
|
typedef OpenSubdiv::HbrHalfedge<OpenSubdiv::OsdVertex> OsdHbrHalfedge;
|
|
|
|
typedef OpenSubdiv::HbrFVarData<OpenSubdiv::OsdVertex> 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<int> _fvarIndices;
|
|
|
|
|
|
|
|
// Individual widths of the facevarying data we want to store
|
|
|
|
std::vector<int> _fvarWidths;
|
|
|
|
|
|
|
|
// Total widths of the facevarying data
|
|
|
|
int _totalfvarWidth;
|
|
|
|
|
|
|
|
// How to interpolate boundaries
|
|
|
|
OsdHbrMesh::InterpolateBoundaryMethod _interpBoundary;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" OsdHbrMesh *
|
|
|
|
ConvertToHBR( int nVertices,
|
|
|
|
std::vector<int> const & faceVertCounts,
|
|
|
|
std::vector<int> const & faceIndices,
|
|
|
|
std::vector<int> const & vtxCreaseIndices,
|
|
|
|
std::vector<double> const & vtxCreases,
|
|
|
|
std::vector<int> const & edgeCrease1Indices,
|
|
|
|
std::vector<float> const & edgeCreases1,
|
|
|
|
std::vector<int> const & edgeCrease2Indices,
|
|
|
|
std::vector<double> const & edgeCreases2,
|
|
|
|
OsdHbrMesh::InterpolateBoundaryMethod interpBoundary,
|
|
|
|
HbrMeshUtil::SchemeType scheme,
|
|
|
|
bool usingPtex=false,
|
|
|
|
FVarDataDesc const * fvarDesc=NULL,
|
|
|
|
std::vector<float> const * fvarData=NULL
|
|
|
|
);
|
2012-09-18 01:41:48 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif // EXAMPLES_MAYAVIEWER_HBRUTIL_H_
|