Fix Chaikin tag parsing

Also:
- add 2 shape examples with Chaikin rule tag
- add shapes to the glViewer
- add a stub in the documentation

Note: the Chaikin rule currently applied by Hbr appears to be somewhat off...

fixes #236
This commit is contained in:
manuelk 2013-11-01 11:38:20 -07:00
parent deccc5d818
commit 83d9315e64
5 changed files with 348 additions and 4 deletions

View File

@ -216,6 +216,14 @@ to make the crease semi-sharp.
----
Chaikin Rule
============
Chaikin's curve subdivision algorithm improves the appearance of multi-edge
semi-sharp creases with vayring weights.
----
Hierarchical Edits
==================

View File

@ -382,6 +382,12 @@ initializeShapes( ) {
#include <shapes/catmark_edgeonly.h>
g_defaultShapes.push_back(SimpleShape(catmark_edgeonly, "catmark_edgeonly", kCatmark));
#include <shapes/catmark_chaikin0.h>
g_defaultShapes.push_back(SimpleShape(catmark_chaikin0, "catmark_chaikin0", kCatmark));
#include <shapes/catmark_chaikin1.h>
g_defaultShapes.push_back(SimpleShape(catmark_chaikin1, "catmark_chaikin1", kCatmark));
#include <shapes/catmark_fan.h>
g_defaultShapes.push_back(SimpleShape(catmark_fan, "catmark_fan", kCatmark));

View File

@ -431,6 +431,30 @@ void applyTags( OpenSubdiv::HbrMesh<T> * mesh, shape const * sh ) {
mesh->SetFVarPropagateCorners( t->intargs[0] != 0 );
else
printf( "expecting single int argument for \"facevaryingpropagatecorners\"\n" );
} else if (t->name=="smoothtriangles") {
OpenSubdiv::HbrCatmarkSubdivision<T> * scheme =
dynamic_cast<OpenSubdiv::HbrCatmarkSubdivision<T> *>( mesh->GetSubdivision() );
if (not scheme) {
printf("the \"creasemethod\" tag can only be applied to Catmark meshes\n");
continue;
}
if ((int)t->intargs.size()==0) {
printf("the \"creasemethod\" tag expects an int argument\n");
continue;
}
if( t->intargs[0]==1 )
scheme->SetTriangleSubdivisionMethod(
OpenSubdiv::HbrCatmarkSubdivision<T>::k_Old);
else if( t->intargs[0]==2 )
scheme->SetTriangleSubdivisionMethod(
OpenSubdiv::HbrCatmarkSubdivision<T>::k_New);
else
printf("the \"creasemethod\" tag only accepts \"normal\" or \"chaikin\" as value (%s)\n", t->stringargs[0].c_str());
} else if (t->name=="creasemethod") {
OpenSubdiv::HbrCatmarkSubdivision<T> * scheme =
@ -447,11 +471,11 @@ void applyTags( OpenSubdiv::HbrMesh<T> * mesh, shape const * sh ) {
}
if( t->stringargs[0]=="normal" )
scheme->SetTriangleSubdivisionMethod(
OpenSubdiv::HbrCatmarkSubdivision<T>::k_Old);
scheme->SetCreaseSubdivisionMethod(
OpenSubdiv::HbrSubdivision<T>::k_CreaseNormal);
else if( t->stringargs[0]=="chaikin" )
scheme->SetTriangleSubdivisionMethod(
OpenSubdiv::HbrCatmarkSubdivision<T>::k_New);
scheme->SetCreaseSubdivisionMethod(
OpenSubdiv::HbrSubdivision<T>::k_CreaseChaikin);
else
printf("the \"creasemethod\" tag only accepts \"normal\" or \"chaikin\" as value (%s)\n", t->stringargs[0].c_str());

View File

@ -0,0 +1,153 @@
//
// 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.
//
static const std::string catmark_chaikin0 =
"# This file uses centimeters as units for non-parametric coordinates.\n"
"\n"
"v -0.500000 -1.500000 0.500000\n"
"v 0.500000 -1.500000 0.500000\n"
"v -0.500000 -0.900000 0.500000\n"
"v 0.500000 -0.900000 0.500000\n"
"v -0.500000 -0.300000 0.500000\n"
"v 0.500000 -0.300000 0.500000\n"
"v -0.500000 0.300000 0.500000\n"
"v 0.500000 0.300000 0.500000\n"
"v -0.500000 0.900000 0.500000\n"
"v 0.500000 0.900000 0.500000\n"
"v -0.500000 1.500000 0.500000\n"
"v 0.500000 1.500000 0.500000\n"
"v -0.500000 1.500000 -0.500000\n"
"v 0.500000 1.500000 -0.500000\n"
"v -0.500000 0.900000 -0.500000\n"
"v 0.500000 0.900000 -0.500000\n"
"v -0.500000 0.300000 -0.500000\n"
"v 0.500000 0.300000 -0.500000\n"
"v -0.500000 -0.300000 -0.500000\n"
"v 0.500000 -0.300000 -0.500000\n"
"v -0.500000 -0.900000 -0.500000\n"
"v 0.500000 -0.900000 -0.500000\n"
"v -0.500000 -1.500000 -0.500000\n"
"v 0.500000 -1.500000 -0.500000\n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vn -0.577350 -0.577350 0.577350\n"
"vn 0.577350 -0.577350 0.577350\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.577350 0.577350 0.577350\n"
"vn 0.577350 0.577350 0.577350\n"
"vn -0.577350 0.577350 -0.577350\n"
"vn 0.577350 0.577350 -0.577350\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.577350 -0.577350 -0.577350\n"
"vn 0.577350 -0.577350 -0.577350\n"
"s off\n"
"f 1/1/1 2/2/2 4/4/4 3/3/3\n"
"f 3/3/3 4/4/4 6/6/6 5/5/5\n"
"f 5/5/5 6/6/6 8/8/8 7/7/7\n"
"f 7/7/7 8/8/8 10/10/10 9/9/9\n"
"f 9/9/9 10/10/10 12/12/12 11/11/11\n"
"f 11/11/11 12/12/12 14/14/14 13/13/13\n"
"f 13/13/13 14/14/14 16/16/16 15/15/15\n"
"f 15/15/15 16/16/16 18/18/18 17/17/17\n"
"f 17/17/17 18/18/18 20/20/20 19/19/19\n"
"f 19/19/19 20/20/20 22/22/22 21/21/21\n"
"f 21/21/21 22/22/22 24/24/24 23/23/23\n"
"f 23/23/23 24/24/24 2/2/2 1/1/1\n"
"f 2/2/2 24/24/24 22/22/22 4/4/4\n"
"f 4/4/4 22/22/22 20/20/20 6/6/6\n"
"f 6/6/6 20/20/20 18/18/18 8/8/8\n"
"f 8/8/8 18/18/18 16/16/16 10/10/10\n"
"f 10/10/10 16/16/16 14/14/14 12/12/12\n"
"f 23/23/23 1/1/1 3/3/3 21/21/21\n"
"f 21/21/21 3/3/3 5/5/5 19/19/19\n"
"f 19/19/19 5/5/5 7/7/7 17/17/17\n"
"f 17/17/17 7/7/7 9/9/9 15/15/15\n"
"f 15/15/15 9/9/9 11/11/11 13/13/13\n"
"t crease 2/1/0 0 1 5.000000\n"
"t crease 2/1/0 10 11 5.000000\n"
"t crease 2/1/0 12 13 5.000000\n"
"t crease 2/1/0 22 23 5.000000\n"
"t crease 2/1/0 0 2 1.000000\n"
"t crease 2/1/0 1 3 1.000000\n"
"t crease 2/1/0 2 4 2.000000\n"
"t crease 2/1/0 3 5 2.000000\n"
"t crease 2/1/0 4 6 3.000000\n"
"t crease 2/1/0 5 7 3.000000\n"
"t crease 2/1/0 6 8 4.000000\n"
"t crease 2/1/0 7 9 4.000000\n"
"t crease 2/1/0 8 10 5.000000\n"
"t crease 2/1/0 9 11 5.000000\n"
"t crease 2/1/0 10 12 5.000000\n"
"t crease 2/1/0 11 13 5.000000\n"
"t crease 2/1/0 12 14 5.000000\n"
"t crease 2/1/0 13 15 5.000000\n"
"t crease 2/1/0 14 16 4.000000\n"
"t crease 2/1/0 15 17 4.000000\n"
"t crease 2/1/0 16 18 3.000000\n"
"t crease 2/1/0 17 19 3.000000\n"
"t crease 2/1/0 18 20 2.000000\n"
"t crease 2/1/0 19 21 2.000000\n"
"t crease 2/1/0 20 22 1.000000\n"
"t crease 2/1/0 21 23 1.000000\n"
"t crease 2/1/0 22 0 5.000000\n"
"t crease 2/1/0 23 1 5.000000\n"
"t creasemethod 0/0/1 normal\n"
"\n"
;

View File

@ -0,0 +1,153 @@
//
// 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.
//
static const std::string catmark_chaikin1 =
"# This file uses centimeters as units for non-parametric coordinates.\n"
"\n"
"v -0.500000 -1.500000 0.500000\n"
"v 0.500000 -1.500000 0.500000\n"
"v -0.500000 -0.900000 0.500000\n"
"v 0.500000 -0.900000 0.500000\n"
"v -0.500000 -0.300000 0.500000\n"
"v 0.500000 -0.300000 0.500000\n"
"v -0.500000 0.300000 0.500000\n"
"v 0.500000 0.300000 0.500000\n"
"v -0.500000 0.900000 0.500000\n"
"v 0.500000 0.900000 0.500000\n"
"v -0.500000 1.500000 0.500000\n"
"v 0.500000 1.500000 0.500000\n"
"v -0.500000 1.500000 -0.500000\n"
"v 0.500000 1.500000 -0.500000\n"
"v -0.500000 0.900000 -0.500000\n"
"v 0.500000 0.900000 -0.500000\n"
"v -0.500000 0.300000 -0.500000\n"
"v 0.500000 0.300000 -0.500000\n"
"v -0.500000 -0.300000 -0.500000\n"
"v 0.500000 -0.300000 -0.500000\n"
"v -0.500000 -0.900000 -0.500000\n"
"v 0.500000 -0.900000 -0.500000\n"
"v -0.500000 -1.500000 -0.500000\n"
"v 0.500000 -1.500000 -0.500000\n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vt 0 0 \n"
"vn -0.577350 -0.577350 0.577350\n"
"vn 0.577350 -0.577350 0.577350\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.707107 0.000000 0.707107\n"
"vn 0.707107 0.000000 0.707107\n"
"vn -0.577350 0.577350 0.577350\n"
"vn 0.577350 0.577350 0.577350\n"
"vn -0.577350 0.577350 -0.577350\n"
"vn 0.577350 0.577350 -0.577350\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.707107 0.000000 -0.707107\n"
"vn 0.707107 0.000000 -0.707107\n"
"vn -0.577350 -0.577350 -0.577350\n"
"vn 0.577350 -0.577350 -0.577350\n"
"s off\n"
"f 1/1/1 2/2/2 4/4/4 3/3/3\n"
"f 3/3/3 4/4/4 6/6/6 5/5/5\n"
"f 5/5/5 6/6/6 8/8/8 7/7/7\n"
"f 7/7/7 8/8/8 10/10/10 9/9/9\n"
"f 9/9/9 10/10/10 12/12/12 11/11/11\n"
"f 11/11/11 12/12/12 14/14/14 13/13/13\n"
"f 13/13/13 14/14/14 16/16/16 15/15/15\n"
"f 15/15/15 16/16/16 18/18/18 17/17/17\n"
"f 17/17/17 18/18/18 20/20/20 19/19/19\n"
"f 19/19/19 20/20/20 22/22/22 21/21/21\n"
"f 21/21/21 22/22/22 24/24/24 23/23/23\n"
"f 23/23/23 24/24/24 2/2/2 1/1/1\n"
"f 2/2/2 24/24/24 22/22/22 4/4/4\n"
"f 4/4/4 22/22/22 20/20/20 6/6/6\n"
"f 6/6/6 20/20/20 18/18/18 8/8/8\n"
"f 8/8/8 18/18/18 16/16/16 10/10/10\n"
"f 10/10/10 16/16/16 14/14/14 12/12/12\n"
"f 23/23/23 1/1/1 3/3/3 21/21/21\n"
"f 21/21/21 3/3/3 5/5/5 19/19/19\n"
"f 19/19/19 5/5/5 7/7/7 17/17/17\n"
"f 17/17/17 7/7/7 9/9/9 15/15/15\n"
"f 15/15/15 9/9/9 11/11/11 13/13/13\n"
"t crease 2/1/0 0 1 5.000000\n"
"t crease 2/1/0 10 11 5.000000\n"
"t crease 2/1/0 12 13 5.000000\n"
"t crease 2/1/0 22 23 5.000000\n"
"t crease 2/1/0 0 2 1.000000\n"
"t crease 2/1/0 1 3 1.000000\n"
"t crease 2/1/0 2 4 2.000000\n"
"t crease 2/1/0 3 5 2.000000\n"
"t crease 2/1/0 4 6 3.000000\n"
"t crease 2/1/0 5 7 3.000000\n"
"t crease 2/1/0 6 8 4.000000\n"
"t crease 2/1/0 7 9 4.000000\n"
"t crease 2/1/0 8 10 5.000000\n"
"t crease 2/1/0 9 11 5.000000\n"
"t crease 2/1/0 10 12 5.000000\n"
"t crease 2/1/0 11 13 5.000000\n"
"t crease 2/1/0 12 14 5.000000\n"
"t crease 2/1/0 13 15 5.000000\n"
"t crease 2/1/0 14 16 4.000000\n"
"t crease 2/1/0 15 17 4.000000\n"
"t crease 2/1/0 16 18 3.000000\n"
"t crease 2/1/0 17 19 3.000000\n"
"t crease 2/1/0 18 20 2.000000\n"
"t crease 2/1/0 19 21 2.000000\n"
"t crease 2/1/0 20 22 1.000000\n"
"t crease 2/1/0 21 23 1.000000\n"
"t crease 2/1/0 22 0 5.000000\n"
"t crease 2/1/0 23 1 5.000000\n"
"t creasemethod 0/0/1 chaikin\n"
"\n"
;