本文整理汇总了C++中NodePtr::findAttachment方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr::findAttachment方法的具体用法?C++ NodePtr::findAttachment怎么用?C++ NodePtr::findAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePtr
的用法示例。
在下文中一共展示了NodePtr::findAttachment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
Action::ResultE PhysicsHandlerFinder::check(NodePtr& node)
{
AttachmentPtr a = node->findAttachment(PhysicsHandler::getClassType());
if(a!=NullFC)
{
_found = PhysicsHandlerPtr::dcast(a);
return Action::Quit;
}
return Action::Continue;
}
示例2: check
Action::ResultE check(NodePtr& node)
{
AttachmentPtr a = node->findAttachment(Name::getClassType());
if(a != NullFC)
{
NamePtr n = NamePtr::dcast(a);
if(n->getField().getValue() == *_name)
{
_found = node;
return Action::Quit;
}
}
return Action::Continue;
}
示例3: 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();
//.........这里部分代码省略.........
示例4: main
// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// GLUT init
int winid = setupGLUT(&argc, argv);
// the connection between GLUT and OpenSG
GLUTWindowPtr gwin = GLUTWindow::create();
gwin->setId(winid);
gwin->init();
// load the scene
NodePtr scene;
if(argc < 2)
{
FWARNING(("No file given!\n"));
scene = makeTorus(.5, 2, 16, 16);
}
else
{
/*
All scene file loading is handled via the SceneFileHandler.
*/
scene = SceneFileHandler::the().read(argv[1]);
}
/*
An Attachment is a special field container that can be attached to many
of the internal classes like Nodes and NodeCores. There can be multiple
Attachments attached to an object.
Attachments can be attached to all FieldContainers that are derived from
AttachmentContainer. This includes most higher-level classes in the
system, like Nodes, NodeCores, Windows, Viewports etc.
The only predefined kind of Attachment is the Name, which can
keep the name of an object. Some of loaders (e.g. the WRL loader)
create these kinds of Attachments for named nodes.
*/
/*
An Attachment is a FieldContainer and as such needs to be created using
::create().
*/
NamePtr name = Name::create();
/*
The NameAttachment only has a single field, there's no need to use the
mask here.
*/
beginEditCP(name);
{
name->getField().setValue("Scene");
}
endEditCP (name);
/*
Attach the name to the scene node.
*/
beginEditCP(scene, Node::AttachmentsFieldMask);
{
scene->addAttachment(name);
}
endEditCP (scene, Node::AttachmentsFieldMask);
/*
Check if the scene has a Name attachment
Attachments are categorized by the GroupID of their class. Every
AttachmentContainer generally keeps only one attachment of a specific
kind.
*/
AttachmentPtr a;
a = scene->findAttachment(Name::getClassType());
if(a!=NullFC)
{
NamePtr n = NamePtr::dcast(a);
SLOG << "Node name: " << n->getField().getValue() << endl;
}
else
{
SLOG << "Node has no name!" << endl;
}
// use the finder helper to find a named object
finder f;
NodePtr found;
found = f.find(scene, "Scene");
SLOG << "Found object " << found << " named Scene." << endl;
//.........这里部分代码省略.........