本文整理汇总了C++中GeoPositions3fPtr::getFieldPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPositions3fPtr::getFieldPtr方法的具体用法?C++ GeoPositions3fPtr::getFieldPtr怎么用?C++ GeoPositions3fPtr::getFieldPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoPositions3fPtr
的用法示例。
在下文中一共展示了GeoPositions3fPtr::getFieldPtr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
void display(void)
{
Real32 time = glutGet(GLUT_ELAPSED_TIME);
updateMesh(time);
// we extract the core out of the root node
// as we now this is a geometry node
GeometryPtr geo = GeometryPtr::dcast(scene->getChild(0)->getCore());
//now modify it's content
// first we need a pointer to the position data field
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
//get the data field the pointer is pointing at
GeoPositions3f::StoredFieldType *posfield = pos->getFieldPtr();
//get some iterators
GeoPositions3f::StoredFieldType::iterator last, it;
// set the iterator to the first data
it = posfield->begin();
beginEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
//now simply run over all entires in the array
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++){
(*it) = Pnt3f(x, wMesh[x][z], z);
it++;
}
endEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
mgr->redraw();
}
示例2: initWave
static void initWave(void)
{
_size = (int) sqrt((float) _geo->getPositions()->getSize());
_surf.resize(_size);
for(UInt32 i=0;i<_size;++i)
_surf[i].resize(_size);
_force.resize(_size);
for(UInt32 i=0;i<_size;++i)
_force[i].resize(_size);
_veloc.resize(_size);
for(UInt32 i=0;i<_size;++i)
_veloc[i].resize(_size);
_surfo.resize(_size);
for(UInt32 i=0;i<_size;++i)
_surfo[i].resize(_size);
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(_geo->getPositions());
MFPnt3f *p = pos->getFieldPtr();
beginEditCP(pos);
{
int c = 0;
for(int i=0;i<_size;i++)
{
for(int j=0;j<_size;j++)
_surfo[i][j] = (*p)[c++][2];
}
}
endEditCP(pos);
}
示例3: updateGeometry
static void updateGeometry(GeometryPtr geo)
{
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
// p->setValue() is faster than pos->setValue()
MFPnt3f *p = pos->getFieldPtr();
beginEditCP(pos);
int c = 0;
for(int i=0;i<_size;++i)
{
for(int j=0;j<_size;++j)
{
Pnt3f &pp = (*p)[c++];
pp[2] = _surfo[i][j] + _surf[i][j];
}
}
endEditCP(pos);
}
示例4: 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();
//.........这里部分代码省略.........
示例5: calcVertexNormals
static void calcVertexNormals(GeometryPtr geo)
{
GeoNormals3fPtr norms = GeoNormals3fPtr::dcast(geo->getNormals());
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
MFPnt3f *p = pos->getFieldPtr();
MFVec3f *n = norms->getFieldPtr();
beginEditCP(norms);
Vec3f a, b, c;
int l = 0;
for(int i=0; i<_size; ++i)
{
for(int j=0; j<_size; ++j)
{
int m = i*_size+j;
if (i!=_size-1 && j!=_size-1)
{
a = (*p)[l+m+1] - (*p)[l+m];
b = (*p)[l+m+_size] - (*p)[l+m];
}
else
{
a = (*p)[l+m-1] - (*p)[l+m];
int index = l+m-_size;
if(index < 0)
index += norms->getSize();
b = (*p)[index] - (*p)[l+m];
}
c = a.cross(b);
c.normalize();
if (i==0 && j==_size-1)
{
a = (*p)[l+m-1] - (*p)[l+m];
b = (*p)[l+m+_size] - (*p)[l+m];
c = a.cross(b);
c.normalize();
c.negate();
}
if (i==_size-1 && j==0)
{
a = (*p)[l+m-_size] - (*p)[l+m];
b = (*p)[l+m+1] - (*p)[l+m];
c = a.cross(b);
c.normalize();
}
(*n)[l+m] = c;
}
}
l += _size*_size;
endEditCP(norms);
}