2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License
|
|
|
|
// and the following modification to it: Section 6 Trademarks.
|
|
|
|
// deleted and replaced with:
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +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 for reproducing
|
|
|
|
// the content of the NOTICE file.
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// You may obtain a copy of the License at
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-07-18 21:19:50 +00:00
|
|
|
// 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.
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifndef EXAMPLES_MAYAVIEWER_OSDMESHDATA_H_
|
|
|
|
#define EXAMPLES_MAYAVIEWER_OSDMESHDATA_H_
|
2012-06-12 16:28:00 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <osd/error.h>
|
|
|
|
#include <osd/vertex.h>
|
|
|
|
#include <osd/glMesh.h>
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <osd/cpuGLVertexBuffer.h>
|
|
|
|
#include <osd/cpuComputeContext.h>
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifdef OPENSUBDIV_HAS_OPENCL
|
|
|
|
#include <osd/clGLVertexBuffer.h>
|
|
|
|
#include <osd/clComputeContext.h>
|
|
|
|
#endif
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifdef OPENSUBDIV_HAS_CUDA
|
|
|
|
#include <osd/cudaGLVertexBuffer.h>
|
|
|
|
#include <osd/cudaComputeContext.h>
|
|
|
|
#endif
|
2012-06-12 16:28:00 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include <maya/MDagPath.h>
|
|
|
|
#include <maya/MUserData.h>
|
|
|
|
#include <maya/MFloatPointArray.h>
|
|
|
|
#include <maya/MFnMesh.h>
|
|
|
|
#include <maya/MDoubleArray.h>
|
|
|
|
#include <maya/MHWGeometry.h>
|
|
|
|
#include <maya/MIntArray.h>
|
|
|
|
#include <maya/MUintArray.h>
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
class OpenSubdivShader; // for getting attributes in rebuildHbrMeshIfNeeded
|
|
|
|
class FVarDataDesc;
|
2012-06-21 01:51:16 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
typedef OpenSubdiv::HbrMesh<OpenSubdiv::OsdVertex> OsdHbrMesh;
|
2012-06-12 23:28:17 +00:00
|
|
|
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
class OsdMeshData : public MUserData
|
|
|
|
{
|
2012-06-12 16:28:00 +00:00
|
|
|
|
|
|
|
public:
|
2012-12-11 01:15:13 +00:00
|
|
|
explicit OsdMeshData(const MDagPath& meshDagPath);
|
|
|
|
virtual ~OsdMeshData();
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
void rebuildHbrMeshIfNeeded(OpenSubdivShader *shader);
|
|
|
|
void prepare();
|
|
|
|
void updateGeometry(const MHWRender::MVertexBuffer *point);
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
GLuint bindPositionVBO() { return _mesh->BindVertexBuffer(); }
|
|
|
|
OpenSubdiv::OsdGLDrawContext * getDrawContext() { return _mesh->GetDrawContext(); }
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
// accessors
|
|
|
|
const MDagPath& getDagPath() { return _meshDagPath; }
|
|
|
|
void setMeshTopoDirty() { _meshTopoDirty = true; }
|
2012-06-12 23:28:17 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
public:
|
2012-06-12 16:28:00 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
enum KernelType { kCPU = 0,
|
|
|
|
kOPENMP = 1,
|
|
|
|
kCUDA = 2,
|
|
|
|
kCL = 3,
|
|
|
|
kGLSL = 4,
|
|
|
|
kGLSLCompute = 5 };
|
|
|
|
|
|
|
|
enum SchemeType {
|
|
|
|
// needs to match HbrMeshUtil::SchemeType enums (or whatever hbrUtil uses)
|
|
|
|
kCatmark=0,
|
|
|
|
kLoop=1,
|
|
|
|
kBilinear=2 };
|
|
|
|
|
|
|
|
enum InterpolateBoundaryType {
|
|
|
|
// needs to match OsdHbrMesh::InterpolateBoundaryMethod enums
|
|
|
|
kInterpolateBoundaryNone,
|
|
|
|
kInterpolateBoundaryEdgeOnly,
|
|
|
|
kInterpolateBoundaryEdgeAndCorner,
|
|
|
|
kInterpolateBoundaryAlwaysSharp };
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initializeMesh();
|
|
|
|
void clearComputeContextAndVertexBuffer();
|
|
|
|
|
|
|
|
MStatus buildUVList( MFnMesh& meshFn, std::vector<float>& uvList );
|
|
|
|
|
|
|
|
MDagPath _meshDagPath;
|
|
|
|
bool _meshTopoDirty;
|
|
|
|
|
|
|
|
OsdHbrMesh *_hbrmesh;
|
|
|
|
|
|
|
|
OpenSubdiv::OsdGLMeshInterface *_mesh;
|
|
|
|
|
|
|
|
MFloatPointArray _pointArray;
|
|
|
|
|
|
|
|
// topology cache
|
|
|
|
MIntArray _vertexList;
|
|
|
|
MUintArray _edgeIds, _vtxIds;
|
|
|
|
MDoubleArray _edgeCreaseData, _vtxCreaseData;
|
|
|
|
int _level;
|
|
|
|
int _scheme;
|
|
|
|
int _kernel;
|
|
|
|
bool _adaptive;
|
|
|
|
InterpolateBoundaryType _interpBoundary;
|
|
|
|
InterpolateBoundaryType _interpUVBoundary;
|
|
|
|
|
|
|
|
// UV face-varying
|
|
|
|
MString _uvSet;
|
|
|
|
FVarDataDesc *_fvarDesc;
|
|
|
|
|
|
|
|
bool _needsUpdate;
|
|
|
|
bool _needsInitializeMesh;
|
2012-06-12 16:28:00 +00:00
|
|
|
};
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif // EXAMPLES_MAYAVIEWER_OSDMESHDATA_H_
|