Re: [osg-users] Problem with animation in .osgb files

2014-03-04 Thread Maxim Voloshin
In my code animation play with space key(in .fbx and .dae files), but in osg 
native formats I can't control it - animation play once without pressing key 
and AnimationManagerFinder is empty.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58445#58445





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Problem with animation in .osgb files

2014-02-25 Thread Maxim Voloshin
Hi, everyone

I am new in OSG and have a problem. I wrote the code that plays animation in 
.fbx models, but I can't play animation in .osgb(.osgt, .ive) models. Please 
see the attached file and help me.

P.S. Sorry for the clumsy English(

Thank you!

Cheers,
Maxim Voloshin

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56536#56536



#include stdafx.h
#include osgAnimation/BasicAnimationManager
#include osgViewer/Viewer
#include osgDB/ConvertUTF
#include osgDB/ReadFile 
#include osg/Node

#define KEY_Space 0x20

struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptrosgAnimation::BasicAnimationManager _am;

AnimationManagerFinder() 
{
setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
}

void apply(osg::Node node)
{
if (_am.valid()) return;

if (node.getUpdateCallback())
{
_am = 
dynamic_castosgAnimation::BasicAnimationManager*(node.getUpdateCallback());
return;
}

traverse(node);
}
};


class myKeyboardEventHandler : public osgGA::GUIEventHandler
{
 public:
osg::Group *e_root;

virtual bool handle(const osgGA::GUIEventAdapter ea, 
osgGA::GUIActionAdapter);
virtual void accept(osgGA::GUIEventHandlerVisitor v)  
{
v.visit(*this);
};
};

void play(osg::Group *root)
{
AnimationManagerFinder finder;
root-accept(finder); 

const osgAnimation::AnimationList animations = 
finder._am-getAnimationList();
animations[0]-setPlayMode(osgAnimation::Animation::STAY);

finder._am-playAnimation(animations[0].get());
std::cout  name is:   animations[0]-getName()  
std::endl;
}

bool myKeyboardEventHandler::handle(const osgGA::GUIEventAdapter ea, 
osgGA::GUIActionAdapter aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
switch(ea.getKey())
{
case KEY_Space:
std::cout  Animation 
started, ;
play(e_root);
return false;
break;
default:
return false;
} 
}
default:
return false;
}
}

void _tmain(int argc, _TCHAR* argv[])
{
osg::Node *node = NULL;
node = 
osgDB::readNodeFile(osgDB::convertStringFromCurrentCodePageToUTF8(C:/Straight_AB.osgb));

osg::Group* root = new osg::Group();
root-addChild(node); 

osgViewer::Viewer viewer;
viewer.setUpViewInWindow(32, 32, 512, 512);
viewer.setSceneData(root);

myKeyboardEventHandler *myFirstEventHandler = new 
myKeyboardEventHandler();
myFirstEventHandler-e_root = root;
viewer.addEventHandler(myFirstEventHandler); 

viewer.run();
}___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with animation in .osgb files

2014-02-25 Thread Maxim Gammer
my very old code used osg::AnimationPathCallback


.

class FindAnimationVisitor : public osg::NodeVisitor
{
public:
FindAnimationVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
//apc=NULL;
setTraversalMask(0x);
setNodeMaskOverride(0x);
}

//найденные анимации
typedef std::vector osg::ref_ptrosg::AnimationPathCallback  NodeList;
NodeList _foundNodes;
//и соответственно объекты, содержащие эти самые анимации
typedef std::vector osg::ref_ptrosg::Transform  TransformList;
TransformList _foundTransforms;

virtual void apply(osg::Transform node);
virtual void apply(osg::Group group);
/*
virtual void apply(osg::MatrixTransform node);
virtual void apply(osg::AnimationPathCallback node);
*/

private:
//Путь анимации
//osg::ref_ptrosg::AnimationPathCallback apc;
};


void FindAnimationVisitor::apply(osg::Transform node)
{
//apc =
dynamic_castosg::AnimationPathCallback*(node.getUpdateCallback());
osg::ref_ptrosg::AnimationPathCallback test =
dynamic_castosg::AnimationPathCallback*(node.getUpdateCallback());
if (test.get())
{
//std::cout  I find animation;
//Запоминаем анимацию
_foundNodes.push_back
(dynamic_castosg::AnimationPathCallback*(node.getUpdateCallback()));
//и объект к которому она прикреплена
_foundTransforms.push_back (node);
}
traverse(node);
}

void FindAnimationVisitor::apply(osg::Group group)
{
traverse(group);
}




2013-09-30 6:18 GMT+06:00 Maxim Voloshin pyroz...@gmail.com:

 Hi, everyone

 I am new in OSG and have a problem. I wrote the code that plays animation
 in .fbx models, but I can't play animation in .osgb(.osgt, .ive) models.
 Please see the attached file and help me.

 P.S. Sorry for the clumsy English(

 Thank you!

 Cheers,
 Maxim Voloshin

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=56536#56536




 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Maxim Gammer
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with animation in .osgb files

2014-02-25 Thread Laurens Voerman

Hi Maxim
I tried your code, and it plays an animation from an .osgb file for me.
Regards, Laurens.

On 9/30/2013 2:18 AM, Maxim Voloshin wrote:

Hi, everyone

I am new in OSG and have a problem. I wrote the code that plays animation in 
.fbx models, but I can't play animation in .osgb(.osgt, .ive) models. Please 
see the attached file and help me.

P.S. Sorry for the clumsy English(

Thank you!

Cheers,
Maxim Voloshin

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56536#56536





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with animation in .osgb files

2014-02-25 Thread Maxim Gammer
ok)


2014-02-25 21:19 GMT+06:00 Laurens Voerman l.voer...@rug.nl:

  Hi Maxim
 I tried your code, and it plays an animation from an .osgb file for me.
 Regards, Laurens.


 On 9/30/2013 2:18 AM, Maxim Voloshin wrote:

 Hi, everyone

 I am new in OSG and have a problem. I wrote the code that plays animation in 
 .fbx models, but I can't play animation in .osgb(.osgt, .ive) models. Please 
 see the attached file and help me.

 P.S. Sorry for the clumsy English(

 Thank you!

 Cheers,
 Maxim Voloshin

 --
 Read this topic online 
 here:http://forum.openscenegraph.org/viewtopic.php?p=56536#56536




 ___
 osg-users mailing 
 listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




-- 
Maxim Gammer
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org