本文整理汇总了C++中Poly::CalcPlane方法的典型用法代码示例。如果您正苦于以下问题:C++ Poly::CalcPlane方法的具体用法?C++ Poly::CalcPlane怎么用?C++ Poly::CalcPlane使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Poly
的用法示例。
在下文中一共展示了Poly::CalcPlane方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MatchPolygon
int MatchPolygon (MdlObject *root, vector<Vector3>& pverts, int& startVertex)
{
for (int a=0;a<root->poly.size();a++) {
Poly *pl = root->poly[a];
if (pl->verts.size() != pverts.size())
continue;
// An early out plane comparision, will also make sure that "double-sided" polgyon pairs
// are handled correctly
Plane plane = pl->CalcPlane (root->verts);
Plane tplane;
tplane.MakePlane (pverts[0],pverts[1],pverts[2]);
if (!plane.EpsilonCompare(tplane, EPSILON))
continue;
// in case the polygon vertices have been reordered,
// this takes care of finding "the first" vertex again
int startv = 0;
for (;startv < pverts.size();startv++) {
if ((root->verts[pl->verts [0]].pos-pverts[startv]).length () < EPSILON)
break;
}
// no start vertex has been found
if (startv == pverts.size())
continue;
// compare the polygon vertices with eachother...
int v = 0;
for (;v<pverts.size();v++) {
if ((root->verts[pl->verts[v]].pos - pverts[(v+startv)%pverts.size()]).length () >= EPSILON)
break;
}
if (v==pverts.size()) {
startVertex=startv;
return a;
}
}
return -1;
}
示例2: GenerateFromPolyMesh
void Object::GenerateFromPolyMesh(PolyMesh *o)
{
std::vector<int> old2new;
std::vector<Vector3> vertPos;
GenerateUniqueVectors(o->verts, vertPos, old2new);
vertices.resize(o->verts.size());
copy(o->verts.begin(),o->verts.end(),vertices.begin());
std::map<Poly*, Face*> poly2face;
// maps edge to first vertex index
std::map<int, std::vector<Edge*> > edgeMap;
// simple definition: intersecting edges are edges with the same vertex pair
// use o->poly, because the edges from non-curved polygons are needed as well
for (uint a=0;a<o->poly.size();a++) {
Poly* pl = o->poly[a];
Face *f = new Face;
poly2face[pl] = f;
faces.push_back(f);
f->plane = pl->CalcPlane(o->verts);
for (uint e=0;e<pl->verts.size();e++) {
Edge* edge = new Edge;
edge->meshVerts[0] = pl->verts[e];
edge->meshVerts[1] = pl->verts[(e+1)%pl->verts.size()];
for(int x=0;x<2;x++) edge->pos [x] = old2new[edge->meshVerts[x]];
edge->face = f;
edge->dir = o->verts[edge->meshVerts[1]].pos - o->verts[edge->meshVerts[0]].pos;
edges.push_back(edge);
f->edges.push_back(edge);
edgeMap[edge->pos[0]].push_back (edge);
}
}
for (uint a=0;a<edges.size();a++) {
Edge *edge = edges[a];
// parallel edge with same direction
std::vector<Edge*>& v = edgeMap[edge->pos[0]];
for (uint b=0;b<v.size();b++) {
if (v[b] != edge && v[b]->pos[1] == edge->pos[1]) {
d_trace("Matching parallel edge (%d, %d) with (%d, %d)\n", v[b]->pos[0], v[b]->pos[1], edge->pos[0], edge->pos[1]);
edge->intersecting.push_back(v[b]);
}
}
// opposite direction
std::vector<Edge*>& w = edgeMap[edge->pos[1]];
for (uint b=0;b<w.size();b++) {
if (w[b]->pos[1] == edge->pos[0] && w[b] != edge) {
d_trace("Matching opposite edge (%d, %d) with (%d, %d)\n", w[b]->pos[0], w[b]->pos[1], edge->pos[0], edge->pos[1]);
edge->intersecting.push_back(w[b]);
}
}
}
edgeMap.clear();
// calculate edge normals
for (uint a=0;a<edges.size();a++) {
Edge* e = edges[a];
e->normal = e->face->plane.GetVector();
for (uint b=0;b<e->intersecting.size();b++)
e->normal += e->intersecting[b]->face->plane.GetVector();
e->normal.normalize();
}
std::vector<Vector3> tmpvrt;
const int steps=10;
int numCurvedPoly = 0;
for (std::map<Poly*,Face*>::iterator pit=poly2face.begin();pit!=poly2face.end();++pit)
if (pit->first->verts.size() == 4) numCurvedPoly ++;
indexBuffer.Init(sizeof(uint) * 3 * 2 * (steps-1) * (steps-1) * numCurvedPoly);
vertexBuffer.Init(sizeof(Vector3) * steps * steps * numCurvedPoly);
uint *indexData = (uint*)indexBuffer.LockData();
Vector3* vertexData = (Vector3*)vertexBuffer.LockData();
Vector3* curPos = vertexData;
uint* curIndex = indexData;
uint vertexOffset = 0;
for (std::map<Poly*,Face*>::iterator pit=poly2face.begin();pit!=poly2face.end();++pit)
{
Poly* pl = pit->first;
Face* face = pit->second;
if (pl->verts.size() == 4) {
const float step = 1.0f / (float)(steps-1);
//.........这里部分代码省略.........