Hey everyone. I have some previous posts on trying to get 2 hands to animate to sensor input.
I have a NodeVisitor class that goes through a model and adds a NodeCallback class to each MatrixTransform node it finds. Then in that NodeCallback I do some tests to see if it is a MatrixTransform that I want to affect. In the NodeVisitor class I attach some axes to the nodes I am looking to affect. When runing the axes move around according to my input but the model stays stationary. Am I missing something on how this should be implemented? NodeVisitor Class: Code: FingerTraverser::FingerTraverser(ErghisAPI::ErghisAPIController * a, int hand) : NodeVisitor(TRAVERSE_ALL_CHILDREN), api(a), fc(new FingerCallback(a,hand)) { } FingerTraverser::~FingerTraverser() { void FingerTraverser::apply(MatrixTransform &node) { ref_ptr<MatrixTransform> joint = dynamic_cast<MatrixTransform*>(&node); OSG_FATAL << "Joint lib name: " << joint ->libraryName() << "::" << joint ->className() << "Joint node name: " << joint ->getName() << std::endl; if (joint) { joint->setUpdateCallback(fc); joint->setDataVariance(Object::DYNAMIC); joint->addChild(createAxis(5)); } traverse(node); } The NodeCallback class: Code: FingerCallback::FingerCallback(ErghisAPIController *a, int h) : api(a), hand(h) { fingerTypes[L_IND] = fingers::finger::Index; fingerTypes[R_IND] = fingers::finger::Index; fingerTypes[L_MID] = fingers::finger::Middle; fingerTypes[R_MID] = fingers::finger::Middle; fingerTypes[L_RING] = fingers::finger::Ring; fingerTypes[R_RING] = fingers::finger::Ring; fingerTypes[L_PINK] = fingers::finger::Pinky; fingerTypes[R_PINK] = fingers::finger::Pinky; fingerTypes[L_THUMB] = fingers::finger::Thumb; fingerTypes[R_THUMB] = fingers::finger::Thumb; } FingerCallback::~FingerCallback() { } void FingerCallback::operator()(Node* node, NodeVisitor * nv) { ref_ptr<MatrixTransform> trans = dynamic_cast< MatrixTransform * > (node); sphere = api->getFrame(); if (!trans) return; bool isAFinger = getFinger(node); if (hand == LEFT && isAFinger) { OSG_FATAL << "Adjusting left finger" << std::endl; Vector EFVec = sphere.leftHand.fingers[finger].position; Vec3d erghisFingerVec = Vec3d(EFVec.getX() / X_SCALEFAC + X_OFFSET, 0, EFVec.getY()/Y_SCALEFAC - Y_OFFSET); Matrix m; m.makeTranslate(erghisFingerVec); trans->setMatrix(m); trans->dirtyBound(); } if (hand == RIGHT && isAFinger) { OSG_FATAL << "Adjusting right finger" << std::endl; Vector EFVec = sphere.rightHand.fingers[finger].position; Vec3d erghisFingerVec = Vec3d(EFVec.getX() / X_SCALEFAC + X_OFFSET, 0, EFVec.getY() / Y_SCALEFAC - Y_OFFSET); Matrix m; m.makeTranslate(erghisFingerVec); trans->setMatrix(m); trans->dirtyBound(); } traverse(node, nv); } bool FingerCallback::getFinger(Node *node) { std::string fing = node->getName(); try{ finger = fingerTypes.at(fing); return true; } catch (...) { return false; } return false; } ... Thank you! Cheers, Chris[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61043#61043 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org