mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-18 12:10:06 +00:00
Added more common utilities to support Shapes with non-Catmark schemes:
- added conversions Shape and Sdc scheme types - extended ObjAnim to take a scheme type on construction - updated far/tutorial_9 to make use of new functionality
This commit is contained in:
parent
6a07537375
commit
5c2191f89c
@ -88,7 +88,7 @@ ObjAnim::InterpolatePositions(float time, float * positions, int stride) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ObjAnim const *
|
ObjAnim const *
|
||||||
ObjAnim::Create(std::vector<char const *> objFiles, bool axis) {
|
ObjAnim::Create(std::vector<char const *> objFiles, bool axis, Scheme scheme) {
|
||||||
|
|
||||||
ObjAnim * anim=0;
|
ObjAnim * anim=0;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ ObjAnim::Create(std::vector<char const *> objFiles, bool axis) {
|
|||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
std::string str = ss.str();
|
std::string str = ss.str();
|
||||||
|
|
||||||
shape = Shape::parseObj(str.c_str(), kCatmark, false, axis);
|
shape = Shape::parseObj(str.c_str(), scheme, false, axis);
|
||||||
|
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
|
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
#ifndef OBJ_ANIM_H
|
#ifndef OBJ_ANIM_H
|
||||||
#define OBJ_ANIM_H
|
#define OBJ_ANIM_H
|
||||||
|
|
||||||
#include <vector>
|
#include "../../regression/common/shape_utils.h"
|
||||||
|
|
||||||
struct Shape;
|
#include <vector>
|
||||||
|
|
||||||
class ObjAnim {
|
class ObjAnim {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Factory function
|
// Factory function
|
||||||
static ObjAnim const * Create(std::vector<char const *> objFiles, bool axis=true);
|
static ObjAnim const * Create(std::vector<char const *> objFiles, bool axis=true,
|
||||||
|
Scheme scheme=kCatmark);
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~ObjAnim();
|
~ObjAnim();
|
||||||
|
@ -36,17 +36,34 @@
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
inline Scheme
|
||||||
|
ConvertSdcTypeToShapeScheme(OpenSubdiv::Sdc::SchemeType sdcScheme) {
|
||||||
|
|
||||||
|
switch (sdcScheme) {
|
||||||
|
case OpenSubdiv::Sdc::SCHEME_BILINEAR: return kBilinear;
|
||||||
|
case OpenSubdiv::Sdc::SCHEME_CATMARK: return kCatmark;
|
||||||
|
case OpenSubdiv::Sdc::SCHEME_LOOP: return kLoop;
|
||||||
|
default: printf("unknown Sdc::SchemeType : %d\n", (int)sdcScheme); break;
|
||||||
|
}
|
||||||
|
return kCatmark;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline OpenSubdiv::Sdc::SchemeType
|
||||||
|
ConvertShapeSchemeToSdcType(Scheme shapeScheme) {
|
||||||
|
|
||||||
|
switch (shapeScheme) {
|
||||||
|
case kBilinear: return OpenSubdiv::Sdc::SCHEME_BILINEAR;
|
||||||
|
case kCatmark: return OpenSubdiv::Sdc::SCHEME_CATMARK;
|
||||||
|
case kLoop: return OpenSubdiv::Sdc::SCHEME_LOOP;
|
||||||
|
default: printf("unknown Shape Scheme : %d\n", (int)shapeScheme); break;
|
||||||
|
}
|
||||||
|
return OpenSubdiv::Sdc::SCHEME_CATMARK;
|
||||||
|
}
|
||||||
|
|
||||||
inline OpenSubdiv::Sdc::SchemeType
|
inline OpenSubdiv::Sdc::SchemeType
|
||||||
GetSdcType(Shape const & shape) {
|
GetSdcType(Shape const & shape) {
|
||||||
|
|
||||||
OpenSubdiv::Sdc::SchemeType type=OpenSubdiv::Sdc::SCHEME_CATMARK;
|
return ConvertShapeSchemeToSdcType(shape.scheme);
|
||||||
|
|
||||||
switch (shape.scheme) {
|
|
||||||
case kBilinear: type = OpenSubdiv::Sdc::SCHEME_BILINEAR; break;
|
|
||||||
case kCatmark : type = OpenSubdiv::Sdc::SCHEME_CATMARK; break;
|
|
||||||
case kLoop : type = OpenSubdiv::Sdc::SCHEME_LOOP; break;
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline OpenSubdiv::Sdc::Options
|
inline OpenSubdiv::Sdc::Options
|
||||||
|
@ -239,6 +239,7 @@ namespace {
|
|||||||
//
|
//
|
||||||
Far::TopologyRefiner *
|
Far::TopologyRefiner *
|
||||||
createTopologyRefinerFromObj(std::string const & objFileName,
|
createTopologyRefinerFromObj(std::string const & objFileName,
|
||||||
|
Sdc::SchemeType schemeType,
|
||||||
PosVector & posVector) {
|
PosVector & posVector) {
|
||||||
|
|
||||||
const char * filename = objFileName.c_str();
|
const char * filename = objFileName.c_str();
|
||||||
@ -251,7 +252,8 @@ namespace {
|
|||||||
ifs.close();
|
ifs.close();
|
||||||
std::string shapeString = ss.str();
|
std::string shapeString = ss.str();
|
||||||
|
|
||||||
shape = Shape::parseObj(shapeString.c_str(), kCatmark, false);
|
shape = Shape::parseObj(
|
||||||
|
shapeString.c_str(), ConvertSdcTypeToShapeScheme(schemeType), false);
|
||||||
if (shape == 0) {
|
if (shape == 0) {
|
||||||
fprintf(stderr, "Error: Cannot create Shape from .obj file '%s'\n", filename);
|
fprintf(stderr, "Error: Cannot create Shape from .obj file '%s'\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
@ -553,7 +555,8 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
Far::TopologyRefiner * baseRefinerPtr = args.inputObjFile.empty() ?
|
Far::TopologyRefiner * baseRefinerPtr = args.inputObjFile.empty() ?
|
||||||
createTopologyRefinerDefault(args.geoMultiplier, basePositions) :
|
createTopologyRefinerDefault(args.geoMultiplier, basePositions) :
|
||||||
createTopologyRefinerFromObj(args.inputObjFile, basePositions);
|
createTopologyRefinerFromObj(args.inputObjFile, args.schemeType,
|
||||||
|
basePositions);
|
||||||
assert(baseRefinerPtr);
|
assert(baseRefinerPtr);
|
||||||
Far::TopologyRefiner & baseRefiner = *baseRefinerPtr;
|
Far::TopologyRefiner & baseRefiner = *baseRefinerPtr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user