mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-09 22:00:06 +00:00
Merge pull request #418 from asluk/dev
osd3 support for lefthanded meshes
This commit is contained in:
commit
6efe3e0bce
@ -119,7 +119,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, axis);
|
shape = Shape::parseObj(str.c_str(), kCatmark, false, axis);
|
||||||
|
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
|
|
||||||
|
@ -486,7 +486,7 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, int kernel, Scheme scheme=
|
|||||||
if (doAnim) {
|
if (doAnim) {
|
||||||
shape = g_objAnim->GetShape();
|
shape = g_objAnim->GetShape();
|
||||||
} else {
|
} else {
|
||||||
shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme);
|
shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme, shapeDesc.isLeftHanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create Vtr mesh (topology)
|
// create Vtr mesh (topology)
|
||||||
|
@ -26,12 +26,14 @@
|
|||||||
|
|
||||||
struct ShapeDesc {
|
struct ShapeDesc {
|
||||||
|
|
||||||
ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme) :
|
ShapeDesc(char const * iname, std::string const & idata, Scheme ischeme,
|
||||||
name(iname), data(idata), scheme(ischeme) { }
|
bool iIsLeftHanded=false) :
|
||||||
|
name(iname), data(idata), scheme(ischeme), isLeftHanded(iIsLeftHanded) { }
|
||||||
|
|
||||||
std::string name,
|
std::string name,
|
||||||
data;
|
data;
|
||||||
Scheme scheme;
|
Scheme scheme;
|
||||||
|
bool isLeftHanded;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<ShapeDesc> g_defaultShapes;
|
static std::vector<ShapeDesc> g_defaultShapes;
|
||||||
@ -73,6 +75,8 @@ static std::vector<ShapeDesc> g_defaultShapes;
|
|||||||
#include <shapes/catmark_hole_test2.h>
|
#include <shapes/catmark_hole_test2.h>
|
||||||
#include <shapes/catmark_hole_test3.h>
|
#include <shapes/catmark_hole_test3.h>
|
||||||
#include <shapes/catmark_hole_test4.h>
|
#include <shapes/catmark_hole_test4.h>
|
||||||
|
#include <shapes/catmark_lefthanded.h>
|
||||||
|
#include <shapes/catmark_righthanded.h>
|
||||||
#include <shapes/catmark_pawn.h>
|
#include <shapes/catmark_pawn.h>
|
||||||
#include <shapes/catmark_pyramid_creases0.h>
|
#include <shapes/catmark_pyramid_creases0.h>
|
||||||
#include <shapes/catmark_pyramid_creases1.h>
|
#include <shapes/catmark_pyramid_creases1.h>
|
||||||
@ -139,6 +143,8 @@ static void initShapes() {
|
|||||||
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test2", catmark_hole_test2, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test2", catmark_hole_test2, kCatmark ) );
|
||||||
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test3", catmark_hole_test3, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test3", catmark_hole_test3, kCatmark ) );
|
||||||
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test4", catmark_hole_test4, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_hole_test4", catmark_hole_test4, kCatmark ) );
|
||||||
|
g_defaultShapes.push_back( ShapeDesc("catmark_lefthanded", catmark_lefthanded, kCatmark, true /*isLeftHanded*/ ) );
|
||||||
|
g_defaultShapes.push_back( ShapeDesc("catmark_righthanded", catmark_righthanded, kCatmark ) );
|
||||||
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid_creases0", catmark_pyramid_creases0, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid_creases0", catmark_pyramid_creases0, kCatmark ) );
|
||||||
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid_creases1", catmark_pyramid_creases1, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid_creases1", catmark_pyramid_creases1, kCatmark ) );
|
||||||
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid", catmark_pyramid, kCatmark ) );
|
g_defaultShapes.push_back( ShapeDesc("catmark_pyramid", catmark_pyramid, kCatmark ) );
|
||||||
|
@ -296,9 +296,16 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
|
|||||||
|
|
||||||
IndexArray dstFaceVerts = refiner.setBaseFaceVertices(face);
|
IndexArray dstFaceVerts = refiner.setBaseFaceVertices(face);
|
||||||
|
|
||||||
for (int vert=0; vert<dstFaceVerts.size(); ++vert) {
|
if (desc.isLeftHanded) {
|
||||||
|
for (int vert=dstFaceVerts.size()-1; vert >=0; --vert) {
|
||||||
|
|
||||||
dstFaceVerts[vert] = desc.vertIndicesPerFace[idx++];
|
dstFaceVerts[vert] = desc.vertIndicesPerFace[idx++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int vert=0; vert<dstFaceVerts.size(); ++vert) {
|
||||||
|
|
||||||
|
dstFaceVerts[vert] = desc.vertIndicesPerFace[idx++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -373,9 +380,16 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignFa
|
|||||||
|
|
||||||
IndexArray dstFaceValues = refiner.setBaseFVarFaceValues(face, channel);
|
IndexArray dstFaceValues = refiner.setBaseFVarFaceValues(face, channel);
|
||||||
|
|
||||||
for (int vert=0; vert<dstFaceValues.size(); ++vert) {
|
if (desc.isLeftHanded) {
|
||||||
|
for (int vert=dstFaceValues.size(); vert >= 0; --vert) {
|
||||||
dstFaceValues[vert] = channelIndices[idx++];
|
|
||||||
|
dstFaceValues[vert] = channelIndices[idx++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int vert=0; vert<dstFaceValues.size(); ++vert) {
|
||||||
|
|
||||||
|
dstFaceValues[vert] = channelIndices[idx++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ public:
|
|||||||
int numHoles;
|
int numHoles;
|
||||||
Index const * holeIndices;
|
Index const * holeIndices;
|
||||||
|
|
||||||
|
bool isLeftHanded;
|
||||||
|
|
||||||
// Face-varying data channel -- value indices correspond to vertex indices,
|
// Face-varying data channel -- value indices correspond to vertex indices,
|
||||||
// i.e. one for every vertex of every face:
|
// i.e. one for every vertex of every face:
|
||||||
//
|
//
|
||||||
|
@ -61,11 +61,13 @@ Shape::~Shape() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme, int axis, bool parsemtl) {
|
Shape * Shape::parseObj(char const * shapestr, Scheme shapescheme,
|
||||||
|
bool isLeftHanded, int axis, bool parsemtl) {
|
||||||
|
|
||||||
Shape * s = new Shape;
|
Shape * s = new Shape;
|
||||||
|
|
||||||
s->scheme = shapescheme;
|
s->scheme = shapescheme;
|
||||||
|
s->isLeftHanded = isLeftHanded;
|
||||||
|
|
||||||
char * str=const_cast<char *>(shapestr), line[256], buf[256], usemtl=-1;
|
char * str=const_cast<char *>(shapestr), line[256], buf[256], usemtl=-1;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
@ -71,7 +71,7 @@ struct Shape {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static Shape * parseObj(char const * Shapestr, Scheme schme,
|
static Shape * parseObj(char const * Shapestr, Scheme schme,
|
||||||
int axis=1, bool parsemtl=false);
|
bool isLeftHanded=false, int axis=1, bool parsemtl=false);
|
||||||
|
|
||||||
void parseMtllib(char const * stream);
|
void parseMtllib(char const * stream);
|
||||||
|
|
||||||
@ -100,6 +100,7 @@ struct Shape {
|
|||||||
std::vector<int> facenormals;
|
std::vector<int> facenormals;
|
||||||
std::vector<tag *> tags;
|
std::vector<tag *> tags;
|
||||||
Scheme scheme;
|
Scheme scheme;
|
||||||
|
bool isLeftHanded;
|
||||||
|
|
||||||
char FindMaterial(char const * name) {
|
char FindMaterial(char const * name) {
|
||||||
for (int i=0; i<(int)mtls.size(); ++i) {
|
for (int i=0; i<(int)mtls.size(); ++i) {
|
||||||
|
@ -211,8 +211,14 @@ TopologyRefinerFactory<Shape>::assignComponentTopology(
|
|||||||
Far::IndexArray dstFaceVerts = refiner.setBaseFaceVertices(i);
|
Far::IndexArray dstFaceVerts = refiner.setBaseFaceVertices(i);
|
||||||
//IndexArray dstFaceEdges = refiner.setBaseFaceEdges(i);
|
//IndexArray dstFaceEdges = refiner.setBaseFaceEdges(i);
|
||||||
|
|
||||||
for (int j=0; j<dstFaceVerts.size(); ++j) {
|
if (shape.isLeftHanded) {
|
||||||
dstFaceVerts[j] = shape.faceverts[ofs++];
|
for (int j=dstFaceVerts.size()-1; j>=0; --j) {
|
||||||
|
dstFaceVerts[j] = shape.faceverts[ofs++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int j=0; j<dstFaceVerts.size(); ++j) {
|
||||||
|
dstFaceVerts[j] = shape.faceverts[ofs++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,8 +242,14 @@ TopologyRefinerFactory<Shape>::assignFaceVaryingTopology(
|
|||||||
Far::IndexArray dstFaceUVs =
|
Far::IndexArray dstFaceUVs =
|
||||||
refiner.setBaseFVarFaceValues(i, channel);
|
refiner.setBaseFVarFaceValues(i, channel);
|
||||||
|
|
||||||
for (int j=0; j<dstFaceUVs.size(); ++j) {
|
if (shape.isLeftHanded) {
|
||||||
dstFaceUVs[j] = shape.faceuvs[ofs++];
|
for (int j=dstFaceUVs.size()-1; j >= 0; --j) {
|
||||||
|
dstFaceUVs[j] = shape.faceuvs[ofs++];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int j=0; j<dstFaceUVs.size(); ++j) {
|
||||||
|
dstFaceUVs[j] = shape.faceuvs[ofs++];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ static Shape * readShape( char const * fname, Scheme scheme ) {
|
|||||||
|
|
||||||
shapeStr[size]='\0';
|
shapeStr[size]='\0';
|
||||||
|
|
||||||
return Shape::parseObj( shapeStr, scheme, 1 );
|
return Shape::parseObj( shapeStr, scheme, false /*isLeftHanded*/, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STR(x) x
|
#define STR(x) x
|
||||||
|
3697
regression/shapes/catmark_lefthanded.h
Normal file
3697
regression/shapes/catmark_lefthanded.h
Normal file
File diff suppressed because it is too large
Load Diff
3695
regression/shapes/catmark_righthanded.h
Normal file
3695
regression/shapes/catmark_righthanded.h
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user