Adding recommended isolation output to OsdPolySmooth node.

- added attribute to the maya example node
- added AE template for editor display
- added ReSt documentation for the plugin
This commit is contained in:
manuelk 2013-11-25 17:12:57 -08:00
parent 8484d1e318
commit b3b2e56a26
7 changed files with 194 additions and 14 deletions

View File

@ -76,6 +76,7 @@ if (DOCUTILS_FOUND AND PYTHONINTERP_FOUND)
hbr_overview.rst
intro.rst
limiteval.rst
maya_osdpolysmooth.rst
osd_overview.rst
painttest.rst
ptexviewer.rst

View File

@ -1,20 +1,20 @@
..
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
@ -56,7 +56,8 @@ of the software.
:class: quickref
:widths: 50 50
* - | `mayaViewer <mayaviewer.html>`_
* - | `osdPolySmooth <maya_osdpolysmooth.html>`_
| `mayaViewer <mayaviewer.html>`_
- | `mayaPtexViewer <mayaptexviewer.html>`_
|
@ -64,10 +65,10 @@ of the software.
.. container:: notebox
**Note:**
the Maya plugins are currently unsupported and they may fail to compile
or work with current versions of OpenSubdiv. These were originally written for
the sole purpose of live demonstrations and the code is provided only as an
implementation example.
the mayaViewer and mayaPtexViewer plugins are currently unsupported and they
may fail to compile or work with current versions of OpenSubdiv. These were
originally written for the sole purpose of live demonstrations and the code
is provided only as an implementation example.
|

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

View File

@ -0,0 +1,113 @@
..
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.
osdPolySmooth
-------------
.. contents::
:local:
:backlinks: none
DESCRIPTION
===========
The OsdPolySmooth node takes a base mesh and generates an OpenSubdiv subdivided mesh.
.. image:: images/osdpolysmooth.png
:width: 400px
:align: center
:target: images/osdpolysmooth.png
.. container:: notebox
**Note:**
This plugin is not representative of actual workflows in the application. The
intended use is for quick comparisons with Renderman's interpolation settings.
Usage
=====
Once the plugin is loaded in Maya:
- Select a poly mesh
- Polygons -> Edit Mesh -> OSD Subdivide Meshes
Attributes (9)
==============
inputPolymesh, output, recommendedIsolation, subdivisionLevels, vertBoundaryMethod,
fvarBoundaryMethod, fvarPropagateCorners, smoothTriangles, creaseMethod,
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| Long Name (Short Name) | Type | Default | Flags |
+=========================================================================================+======+==========+====================================+
| inputPolymesh (ip) | mesh | | input hidden connectable storable |
| This is a description for this attribute | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| output (out) | mesh | | hidden connectable storable output |
| This is a description for this attribute | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| subdivisionLevels (sl) | int | 2 | input connectable storable |
| The number of recursive quad subdivisions to perform on each face. | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| recommendedIsolation (ri) | int | | output connectable storable |
| The recommended levels of subdivision required to account for crease sharpness | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| vertBoundaryMethod (vbm) | enum | EdgeOnly | input connectable storable |
| Controls how boundary edges and vertices are interpolated. | | | |
| - Smooth, Edges: *InterpolateBoundaryEdgeOnly* | | | |
| - Smooth, Edges and Corners: *InterpolateBoundaryEdgeAndCorner* | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| fvarBoundaryMethod (fvbm) | enum | None | input connectable storable |
| Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). | | | |
| - Bi-linear (None): *InterpolateBoundaryNone* | | | |
| - Smooth (Edge Only): *InterpolateBoundaryEdgeOnly* | | | |
| - Smooth (Edges and Corners: *InterpolateBoundaryEdgeAndCorner* | | | |
| - Smooth (ZBrush and Maya "Smooth Internal Only"): *InterpolateBoundaryAlwaysSharp* | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| fvarPropagateCorners (fvpc) | bool | false | input connectable storable |
| Check all faces to see if two edges side by side are facevarying boundary edges | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| smoothTriangles (stri) | bool | true | input connectable storable |
| Apply a special subdivision rule be applied to all triangular faces that was | | | |
| empirically determined to make triangles subdivide more smoothly. | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
| creaseMethod (crm) | enum | 0 | input connectable storable |
| Controls how boundary edges and vertices are interpolated. | | | |
| - Normal: No Crease sharpness smoothing | | | |
| - Chaikin: Improves the appearance of multiedge creases with varying weight | | | |
+-----------------------------------------------------------------------------------------+------+----------+------------------------------------+
SEE ALSO
========
`Code Examples <code_examples.html>`__, \
`glBatchViewer <glbatchviewer.html>`__, \
`glStencilViewer <glstencilviewer.html>`__, \
`ptexViewer <ptexviewer.html>`__, \
`paintTest <painttest.html>`__, \
`limitEval <limiteval.html>`__, \
`dxViewer <dxviewer.html>`__, \
`uvViewer <uvviewer.html>`__, \

View File

@ -78,6 +78,7 @@ const MString OsdPolySmooth::typeNameStr("osdPolySmooth");
MObject OsdPolySmooth::a_inputPolymesh;
MObject OsdPolySmooth::a_output;
MObject OsdPolySmooth::a_subdivisionLevels;
MObject OsdPolySmooth::a_recommendedIsolation;
MObject OsdPolySmooth::a_vertBoundaryMethod;
MObject OsdPolySmooth::a_fvarBoundaryMethod;
MObject OsdPolySmooth::a_fvarPropagateCorners;
@ -312,7 +313,8 @@ HMesh *
createOsdHbrFromPoly( MFnMesh const & inMeshFn,
MItMeshPolygon & inMeshItPolygon,
std::vector<int> & fvarIndices,
std::vector<int> & fvarWidths)
std::vector<int> & fvarWidths,
float * maxCreaseSharpness=0)
{
MStatus returnStatus;
@ -495,8 +497,12 @@ createOsdHbrFromPoly( MFnMesh const & inMeshFn,
}
// Apply Creases
applyCreaseEdges( inMeshFn, hbrMesh );
applyCreaseVertices( inMeshFn, hbrMesh );
float maxEdgeCrease = applyCreaseEdges( inMeshFn, hbrMesh );
float maxVertexCrease = applyCreaseVertices( inMeshFn, hbrMesh );
if (maxCreaseSharpness) {
*maxCreaseSharpness = std::max(maxEdgeCrease, maxVertexCrease);
}
// Return the resulting HBR Mesh
// Note that boundaryMethods and hbrMesh->Finish() still need to be called
@ -761,9 +767,10 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
// Note: These fvar values only need to be kept alive through the life of the farMesh
std::vector<int> fvarIndices;
std::vector<int> fvarWidths;
float maxCreaseSharpness=0.0;
HMesh *hbrMesh = createOsdHbrFromPoly(
inMeshFn, inMeshItPolygon, fvarIndices, fvarWidths);
inMeshFn, inMeshItPolygon, fvarIndices, fvarWidths, &maxCreaseSharpness);
assert(hbrMesh);
// Create the farMesh if successfully created the hbrMesh
@ -840,6 +847,9 @@ MStatus OsdPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
MDataHandle outMeshH = data.outputValue(a_output, &returnStatus);
MCHECKERR(returnStatus, "ERROR getting polygon data handle\n");
outMeshH.set(newMeshDataObj);
int isolation = std::min(10,(int)ceil(maxCreaseSharpness)+1);
data.outputValue(a_recommendedIsolation).set(isolation);
// == Cleanup OSD ============================================
// REVISIT: Re-add these deletes
@ -955,6 +965,24 @@ MStatus OsdPolySmooth::initialize() {
stat = addAttribute( a_subdivisionLevels );
MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_subdivisionLevels)" );
// a_recommendedIsolation : The number of recursive quad subdivisions to perform on each face.
a_recommendedIsolation = nAttr.create("recommendedIsolation", "ri", MFnNumericData::kInt, 0.0, &stat);
MCHECKERR( stat, "cannot create OsdPolySmooth::recommendedIsolation" );
stat = nAttr.setDefault(2);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setDefault(0)" );
stat = nAttr.setMin(0);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setMin(0)" );
stat = nAttr.setMax(10);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setSoftMax(10)" );
stat = nAttr.setReadable(true);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setReadable()" );
stat = nAttr.setWritable(false);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setWritable()" );
stat = nAttr.setHidden(false);
MCHECKERR( stat, "cannot OsdPolySmooth::recommendedIsolation.setHidden()" );
stat = addAttribute( a_recommendedIsolation );
MCHECKERR( stat, "cannot OsdPolySmooth::addAttribute(a_recommendedIsolation)" );
// a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul>
a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat);
MCHECKERR( stat, "cannot create OsdPolySmooth::vertBoundaryMethod" );
@ -1053,6 +1081,21 @@ MStatus OsdPolySmooth::initialize() {
MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect output" );
stat = attributeAffects( a_fvarBoundaryMethod, a_output );
MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect output" );
stat = attributeAffects( a_creaseMethod, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute creaseMethod affect .si output" );
stat = attributeAffects( a_inputPolymesh, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute inputPolymesh affect .si output" );
stat = attributeAffects( a_subdivisionLevels, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute subdivisionLevels affect .si output" );
stat = attributeAffects( a_smoothTriangles, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute smoothTriangles affect .si output" );
stat = attributeAffects( a_fvarPropagateCorners, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect .si output" );
stat = attributeAffects( a_vertBoundaryMethod, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect .si output" );
stat = attributeAffects( a_fvarBoundaryMethod, a_recommendedIsolation );
MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect .si output" );
// MAYA_NODE_BUILDER:END [ATTRIBUTE DEPENDS] ==========
return MS::kSuccess;

View File

@ -49,6 +49,7 @@ public:
static MObject a_inputPolymesh; // This is a description for this attribute
static MObject a_output; // This is a description for this attribute
static MObject a_subdivisionLevels; // The number of recursive quad subdivisions to perform on each face.
static MObject a_recommendedIsolation; // The recommended number of levels of isolation / subdivision based on topology
static MObject a_vertBoundaryMethod; // Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul>
static MObject a_fvarBoundaryMethod; // Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). <ul> <li>Bi-linear (None): Renderman: InterpolateBoundaryNone</li> <li>Smooth, (Edge Only): Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, (Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> <li>Smooth, (ZBrush and Maya "Smooth Internal Only"): Renderman: InterpolateBoundaryAlwaysSharp</li> </ul>
static MObject a_fvarPropagateCorners; //

View File

@ -55,6 +55,27 @@ global proc osdPolySmooth_removeUI() {
}
}
global proc AEosdPolySmoothTemplate( string $nodeName ) {
editorTemplate -beginScrollLayout;
editorTemplate -beginLayout "Subdivision Attributes" -collapse 0;
editorTemplate -addControl "displayMesh";
editorTemplate -addControl "subdivisionLevels";
editorTemplate -addControl "recommendedIsolation";
editorTemplate -addControl "vertBoundaryMethod";
editorTemplate -addControl "fvarBoundaryMethod";
editorTemplate -addControl "fvarPropagateCorners";
editorTemplate -addControl "smoothTriangles";
editorTemplate -addControl "creaseMethod";
editorTemplate -endLayout;
editorTemplate -addExtraControls;
editorTemplate -endScrollLayout;
}
// ===========================
// COMMANDS