本文整理汇总了C++中GeometryPtr::beginFaces方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryPtr::beginFaces方法的具体用法?C++ GeometryPtr::beginFaces怎么用?C++ GeometryPtr::beginFaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryPtr
的用法示例。
在下文中一共展示了GeometryPtr::beginFaces方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enter
/*
Aufruf dieser Funktion erfolgt bei Traversierung des Szenengraphen
mittels OpenSG-Funktion traverse().
Enthaelt ein Knoten verwertbare Geometrieinformation so tragen wir
Zeiger auf seine Geometrie (OpenSG-Strukturen) im array gla_meshInfo_
ein.
Nebenbei bestimmen wir für die Geometrie auch noch die World-Space-
Transformation (evtl. existiert eine OpenSG-Funktion um diese
Information zu erhalten, der Autor hat keine in der OpenSG-API
entdeckt).
*/
Action::ResultE enter(NodePtr &node)
{
int i, j, h;
Pnt3f v;
int numFaces, numFaceVertices, vId, size;
MeshInfo meshInfo;
TinyMatrix transf;
FaceIterator fit;
int numQuads;
NamePtr namePtr;
char name[255];
namePtr = NamePtr::dcast(node->findAttachment(Name::getClassType().getGroupId()));
if(namePtr == osg::NullFC)
strcpy(name, "");
else
{
strcpy(name, namePtr->getFieldPtr()->getValue().c_str());
}
SINFO << "Node name = '" << name << "'" << endl << endLog;
GeometryPtr geo = GeometryPtr::dcast(node->getCore());
if(geo != NullFC)
{
GeoPLengthsUI32Ptr pLength = GeoPLengthsUI32Ptr::dcast(geo->getLengths());
GeoPTypesUI8Ptr pTypes = GeoPTypesUI8Ptr::dcast(geo->getTypes());
/* pLength and pTypes should not be NullFC, however VRML Importer/Exporter
code is instable by now, so this can happen */
if((pLength != NullFC) && (pTypes != NullFC))
{
GeoPLengthsUI32::StoredFieldType * pLengthField = pLength->getFieldPtr();
GeoPTypesUI8::StoredFieldType * pTypeField = pTypes->getFieldPtr();
size = pLengthField->size();
for(h = 0; h < size; h++)
{
if(((*pTypeField)[h] == GL_TRIANGLES) ||
((*pTypeField)[h] == GL_QUADS))
{
/* may quads appear in GL_TRIANGLES ? */
/* check if all triangles have three vertices */
numQuads = 0;
fit = geo->beginFaces();
while(fit != geo->endFaces())
{
numFaceVertices = fit.getLength();
if(numFaceVertices == 4)
numQuads++;
if(numFaceVertices > 4)
{
SWARNING <<
"More than 4 vertices in face!" <<
endl <<
endLog;
return Action::Continue;
// exit(1);
}
++fit;
}
if(numQuads > 0)
{
SWARNING << "Quad encountered" << endl << endLog;
}
if(gl_sga->nodeDepth_ > 0)
{
for(i = 0; i < gl_sga->nodeDepth_; i++)
{
meshInfo.transf = meshInfo.transf * gl_sga->transf_[i];
}
}
else
meshInfo.transf.identity();
/* access to vertices */
GeoPositions3fPtr pPos = GeoPositions3fPtr::dcast(geo->getPositions());
GeoPositions3f::StoredFieldType * pPosField = pPos->getFieldPtr();
/* access to faces */
numFaces = 0;
fit = geo->beginFaces();
//.........这里部分代码省略.........
示例2: renderScene
//.........这里部分代码省略.........
GLubyte *pixels = new GLubyte[size];
glReadPixels(0 , 0 , window_w , window_h , GL_RGB , GL_UNSIGNED_BYTE , pixels);
// init RGB and count&debug values
int red,green,blue;
int count(0);
//iterate through pixels
for(int u(0);u < size;u=u+3){
// get pixels
red = pixels[u];
green = pixels[u+1];
blue = pixels[u+2];
// calc unique index
int index = 256 * green + 256 * 256 * red + blue;
// ignore black
if(index == 0 )
continue;
// fill RGB vector
vector<int> ct;
ct.push_back(red);
ct.push_back(green);
ct.push_back(blue);
// put in map
color_map[index] = ct;
}
cout << "Colors seen in frame: "<< color_map.size()<<endl;
map<int,vector<int> >::iterator mip;
// for all _visible_ triangles
int h(0);
FaceIterator fit = TEST->beginFaces();
float thresh = 0.95;
int count_lines_drawn(0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINES);
vector<Pnt3f> cp;
for(mip = color_map.begin();mip != color_map.end();mip++){
int face_index = _COLORS[mip->first];
fit.seek(face_index);
int a = fit.getPositionIndex(0);
int b = fit.getPositionIndex(1);
int c = fit.getPositionIndex(2);
FaceIterator nit;
glBegin(GL_LINES);
glColor3f(1.0,0,0);
for(nit = TEST->beginFaces();nit != TEST->endFaces();++nit)
{
if(fit.getIndex() == nit.getIndex())
continue;
int a2 = nit.getPositionIndex(0);
int b2 = nit.getPositionIndex(1);
int c2 = nit.getPositionIndex(2);
// a-b
if(a == a2 || a == b2 || a == c2)
if(b == a2 || b == b2 || b == c2){
if(fit.getNormal(0).dot(nit.getNormal(0)) < thresh){
count_lines_drawn++;
示例3: convertToTs
//.........这里部分代码省略.........
/* second pass */
numVertices = 0;
numFaces = 0;
for(i = 0; i < numGeometryNodes_; i++)
{
if((i > 0) && (meshInfo_[i].meshId != meshInfo_[i - 1].meshId))
{
offsetVertices += meshInfo_[i - 1].numVertices;
}
if((i == 0) || (meshInfo_[i].meshId != meshInfo_[i - 1].meshId))
{
/* set vertex data */
for(j = 0; j < meshInfo_[i].vPtr->size(); j++)
{
v[0] = (*meshInfo_[i].vPtr)[j][0];
v[1] = (*meshInfo_[i].vPtr)[j][1];
v[2] = (*meshInfo_[i].vPtr)[j][2];
/* transformation does matter for case of single flat mesh */
v = meshInfo_[i].transf * v; /* transform into world space */
ts->setVertex(offsetVertices + j, v);
}
numVertices += meshInfo_[i].numVertices;
}
/* set face data */
geoPtr = meshInfo_[i].geoPtr;
for(fit = geoPtr->beginFaces(); fit != geoPtr->endFaces(); ++fit)
{
/* this should be always 3 */
numFaceVertices = fit.getLength();
if(numFaceVertices == 4)
{
for(j = 0; j < 4; j++)
{
quadVIds[j] = fit.getPositionIndex(j);
(*isQuadVertex)->setBit(quadVIds[j], 1);
}
/* split quad into two triangles */
ts->setFace(numFaces, offsetVertices + quadVIds[0],
offsetVertices + quadVIds[1],
offsetVertices + quadVIds[2]);
numFaces++;
ts->setFace(numFaces, offsetVertices + quadVIds[2],
offsetVertices + quadVIds[3],
offsetVertices + quadVIds[0]);
numFaces++;
}
else
{
if(numFaceVertices != 3)
{
printf("numFaceVertices=%d\n", numFaceVertices);
// exit(1);
return -1;
}
for(j = 0; j < 3; j++)