Robin Steinke wrote:
> Carsten Neumann schrieb:
> 
>> unfortunately no, but could you post your code or attach your .h/.cpp
>> file, please ?
>>
>>     Thanks,
>>         Carsten
> 
> sure, should have done that in the first place. here it is,
> 
> greets, robin

I'll put some unrelated comments in here, hope you don't mind ;)

> 
> #ifndef _LEG_H_
> #define _LEG_H_
> #pragma once
> #endif
> 
> 
> #include <OpenSG/OSGConfig.h>
> #include <OpenSG/OSGSceneFileHandler.h>
> #include <iostream>
> #include <ant.h>
> #include <helper.h>
> #include <world.h>
> #include <OpenSG/OSGGeoFunctions.h>
> #include <OpenSG/OSGSwitch.h>
> #include <OpenSG/OSGSceneFileHandler.h>
> #include <OpenSG/OSGSimpleAttachments.h>
> 
> 
> using namespace std;
> OSG_USING_NAMESPACE
> extern Ant* myAnt;
> 
> class Leg {
> 
>       public:
>               Leg();
>               void setRotation();
> 
>       private:
>               Helper* load;
>               void setupLeg(std::string jointFilename);
>               NodePtr tempLeg;
>               std::vector<OSG::GeometryPtr> legGeoNodes;
>               std::vector<OSG::GeometryPtr> linkGeoNodes;

These vectors do not hold nodes, but geometries (which are derived
ultimately from NodeCore) so the name could be a little misleading.

>               std::vector<OSG::TransformPtr> linkTransform;
>               std::vector<OSG::NodePtr> linkTransformNodes;
>                       
>               Action::ResultE enter(NodePtr& node) { 
> 
>                       OSG::GeometryPtr g=OSG::NullFC; 
> 
>                       if (getName(node)) {
> 
>                               cout << getName(node) << endl;
>                       }
>                       else {
> 
>                               cout << "No name was set!" << endl;
>                       }
> 
>                       return Action::Continue; 
>               }
> };
> 
> 
> ------------------------------------------------------------------------
> 
> #include <leg.h>
> 
> Leg::Leg() {
> 
>       load = new Helper;
>       std::string jFile="object/output.bin";
>       setupLeg(jFile.c_str());
>       //saveJoint();
> 
> }
> 
> //Actions
> 
> //Action::ResultE isLegGeo(NodePtr& node) {
> //    
> //    OSG::GeometryPtr g=OSG::NullFC;
> //
> //    
> if(node.getCore()->getType().isDerivedFrom(OSG::Geometry::getClassType())) {
> //
> //            if(getName(node)) {
> //                    if(getName(node) == "LegGeo") {
> //                            
> //                            g=OSG::GeometryPtr::dcast(node->getCore());
> //                            legGeoNodes.push_back(g);
> //                    }
> //            }
> //    }
> //    return Action::Continue;
> //}
> //
> //Action::ResultE isLinkGeo(NodePtr& node) {
> //    
> //    OSG::GeometryPtr g=OSG::NullFC;
> //
> //    
> if(node.getCore()->getType().isDerivedFrom(OSG::Geometry::getClassType())) {
> //
> //            if(getName(node)) {
> //                    if(getName(node) == "LinkGeo") {
> //                            
> //                            g=OSG::GeometryPtr::dcast(node->getCore());
> //                            linkGeoNodes.push_back(g);
> //                    }
> //            }
> //    }
> //    return Action::Continue;
> //}
> //
> //Action::ResultE isLinkTrans(NodePtr& node) {
> //    
> //    OSG::NodePtr tempTransNode=OSG::NullFC;
> //    OSG::NodeCorePtr tempTransCore=OSG::NullFC;
> //    OSG::TransformPtr tempTrans=OSG::NullFC;
> //
> //    
> if(node.getCore()->getType().isDerivedFrom(OSG::NodePtr::getClassType())) {
This test will always fail, a core is never derived from Node or NodePtr
- I believe you meant .isDerivedFrom(OSG::Transform::getClassType()) ?

> //
> //            if(getName(node)) {
> //                    if(getName(node) == "LinkTransformNode") {
> //                            
> //                            tempTransNode = OSG::NodePtr::dcast(node);
not required, node is a NodePtr.

> //                            tempTransCore = node->getCore();
> //                            tempTrans = 
> OSG::TransformPtr::dcast(tempTransCore);
> //                            linkTransformNodes.push_back(tempTransNode);
> //                            linkTransform.push_back(tempTrans);
> //                    }
> //            }
> //    }
> //    return Action::Continue;
> //}
> 

Now to what you actually asked for ;)

> 
> void Leg::setupLeg(std::string legFilename) {
> 
>       tempLeg = load->loadObject(legFilename);        
>       
>       traverse(tempLeg, 
>              osgTypedFunctionFunctor1CPtrRef
>              <Action::ResultE, NodePtr>(enter));

try the following call instead. Your enter method is not a free
function, hence you need to supply an object to which it can be bound
when called (I hope I picked the right functor creation function).

traverse(tempLeg, osgTypedMethodFunctor1ObjPtrCPtrRef<Action::ResultE,
Leg, NodePtr>(this, &Leg::enter));

The functor creation functions are in
Source/Base/Functor/OSGTypedFunctors.h and  this page
http://www.opensg.org/doc-1.6.0/Traversal.html of the tutorial has a
similar example with a class counter (in the lower third of the page).
If it's not working please ask again.

        Hope this helps,
                Carsten

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to