Re: [osg-users] fbx animation

2014-11-17 Thread Chris Hidden
Hi, I know this an old post but i took your code Tomhog and turned it into a 
small application with TinyXml that makes it a bit easier to setup and bake 
multiple animation into an osgb file.  Hope it helps someone!

https://github.com/CheezeCoder/OSGStuff[/url]

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





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


Re: [osg-users] fbx animation

2014-11-17 Thread Thomas Hogarth
Nice one.

My plan at some point is to integrate this into an all singing all dancing 
middlware tool to prep files for use in OSG (one day anyway), but nice to have 
it somewhere being used and hopefully iron out any bugs in it.

Seem to remember the main problem at the moment is if you don't have a key per 
frame and one of your new frames lands between keys the easing curves won't be 
correct on that frame.

Cheers
Tom

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





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


Re: [osg-users] fbx animation

2011-04-13 Thread Josue Hernandez

tomhog wrote:
 Hi
 
 how I can stop an animation?
 
 
 Cheers
 Tom
 
  --
 Post generated by Mail2Forum


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





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


Re: [osg-users] fbx animation

2011-04-11 Thread Josue Hernandez
Hi, this is the code that i'm using:

#include osg/Node
#include osg/MatrixTransform
#include osg/Group
#include osg/Timer
#include osgGA/TrackBallManipulator
#include osgDB/ReadFile
#include osgDB/WriteFile
#include osgViewer/Viewer
#include iostream 
#include osgViewer/ViewerEventHandlers
#include osgAnimation/BasicAnimationManager
using namespace std;

static osg::Timer_t old_tick,new_tick;
int bandera=0;
static double delta;

class tankControll: public osgGA::GUIEventHandler{
public:
tankControll(){
acc=0;
};
virtual bool handle(const osgGA::GUIEventAdapter 
ea,osgGA::GUIActionAdapter aa){
if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='q' || ea.getKey()=='Q')){
bandera=0;
bandera=1;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='w' || ea.getKey()=='W')){
bandera=0;
bandera=2;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='e' || ea.getKey()=='E')){
bandera=0;  
bandera=3;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='a' || ea.getKey()=='A')){
bandera=0;  
bandera=4;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='s' || ea.getKey()=='S')){
bandera=0;  
bandera=5;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN  
(ea.getKey()=='d' || ea.getKey()=='D')){
bandera=0;  
bandera=6;
return true;
}else{
return false;
}
}
private:
int acc;
};

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

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

void apply(osg::Node node) { 

if (_am.valid()) 
return; 

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

traverse(node); 
} 
}; 


int main()
{
osg::ref_ptrosg::Node escena = osgDB::readNodeFile(Lerpz.osgb);
if (!escena){
coutIĀ“m not readingendl;
//exit(0);
}

AnimationManagerFinder finder; 
escena-accept(finder); 

const osgAnimation::AnimationList animations = 
finder._am-getAnimationList();
tankControll *eh=new tankControll();

osgViewer::Viewer visor;

visor.setSceneData(escena);
visor.addEventHandler(eh);
/*if(bandera==1)
finder._am-playAnimation( animations[1].get() );
else if(bandera==2)
finder._am-playAnimation( animations[2].get() );
else if(bandera==3)
finder._am-playAnimation( animations[3].get() );*/

visor.setCameraManipulator(new osgGA::TrackballManipulator);

visor.realize();
while ( !visor.done()){
//while (bandera!=6){

if (bandera==1)
finder._am-playAnimation( animations[1].get() );
else
if (bandera==2)
finder._am-playAnimation( animations[2].get() );
else
if (bandera==3)
finder._am-playAnimation( animations[3].get() );
else
printf(%i,bandera);

   visor.frame();

}

return visor.run();


}

the problem is the follow: when i press the w after the q, or e, it seems that 
animations are one over the other, why it happens?

... 

Thank you!

Cheers,
Josue

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





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


Re: [osg-users] fbx animation

2011-04-06 Thread Josue Hernandez
well, with this file you can see the animation of your .fbx,

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




Attachments: 
http://forum.openscenegraph.org//files/animacionfbx_575.cpp


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


Re: [osg-users] fbx animation

2011-04-06 Thread Josue Hernandez
thank you, now i can separate the animations, but when i change the 
destinationFile in .fbx file, the animation were not created. why?

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





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


Re: [osg-users] fbx animation

2011-04-06 Thread Thomas Hogarth
Hi

There is no write functionality for the fbx plugin, this is why you need to
use .osgb. Once converted there is no difference to using fbx other then you
can't re open it in 3ds max etc.

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


Re: [osg-users] fbx animation

2011-04-06 Thread Josue Hernandez
i understend, but how i can change that?, because i need do this but the file 
should remain as .fbx

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





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


Re: [osg-users] fbx animation

2011-04-04 Thread Josue Hernandez
ok, now i have osg 2.9.11 and no longer mark error, but where i can specific my 
.fbx file?, i try to find it, but I could not

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





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


Re: [osg-users] fbx animation

2011-04-04 Thread Melanie Presa
I've made a model in 3Ds Max 2011 and animated it. After seeking help I was 
told to re-export the model, cooking the animations into the .fbx file.
My problem now is that I don't know how to access the animations within Visual 
Studio/XNA in order to play them as my character walks/runs..

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





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


Re: [osg-users] fbx animation

2011-04-02 Thread Thomas Hogarth
Hi

I beleive osgDB/XmlPaser is part of osg 2.9.x and higher, the argument passed 
to the spliter class is an xml file, but for some reason this forum blocks 
them. Here is the content of the splitConfig.xml file I use.

?xml version=1.0 encoding=ISO-8859-15?
OsgAnimationTools sourceFile='./Data/BookModel/bookPage.FBX' 
destinationFile='./Data/BookModel/bookPage.osgb' fps='30'
AnimationSplit sourceAnimation='Take 001'
NewAnimation name='IdleClosed' startFrame='0' endFrame='1'/
NewAnimation name='AnimateOpen' startFrame='2' endFrame='30'/
NewAnimation name='IdleRightOpen' startFrame='31' 
endFrame='34'/
NewAnimation name='RightPageTurn' startFrame='36' 
endFrame='49'/
NewAnimation name='IdleLeftOpen' startFrame='50' 
endFrame='53'/
NewAnimation name='LeftPageTurn' startFrame='55' 
endFrame='70'/
NewAnimation name='AnimateClosed' startFrame='71' 
endFrame='104'/
/AnimationSplit
/OsgAnimationTools

Hope that helps
Tom

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





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


Re: [osg-users] fbx animation

2011-04-01 Thread Josue Hernandez
thank you so much for this, but now i have a problem: how I can get the library 
osgDB/XmlParser?

another custion: the argument of AnimationSplitter is my .fbx or is something 
else?

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





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


Re: [osg-users] fbx animation

2011-03-30 Thread Josue Hernandez
good, now i can see my .fbx with animations, but now: how can i separate the 
different animations the model?

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





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


Re: [osg-users] fbx animation

2011-03-30 Thread Thomas Hogarth
Hi Josue

how can i separate the different animations the model?

When you say seperate animations I assume you mean split one long animation
into multiple sub animations. I've written a little tool to help with this.
I've attached the source and an example config.

You can use the config file to specify the input and output file, then
specify sub animations using start and end frames.

It works in most cases, it does however trip over occasionally, the best bet
is to ensure you have a key per frame. If your using 3D Studio you can
collapse trajectories to do this for you. This does create bigger files
though so I plan to improve it at some points

Cheers
Tom
//
//Simple animation split util, will load an xml config file from ./splitConfig.xml and
//use it to specify a source file, output/destination file and a set of new split animations
//key use of this tool is to split one long animatiob from 3ds max into multiple 'takes'
//

#include osgDB/ReadFile
#include osgDB/WriteFile
#include osgDB/FileUtils
#include osgDB/FileNameUtils
#include osgDB/XmlParser

#include osgAnimation/BasicAnimationManager
#include osgAnimation/AnimationManagerBase

//
//finds and returns the fist AnimationManagerBase in the subgraph
struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptrosgAnimation::BasicAnimationManager _am;
AnimationManagerFinder() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Node node) {
if (_am.valid())
return;
if (node.getUpdateCallback()) {
osgAnimation::AnimationManagerBase* b = dynamic_castosgAnimation::AnimationManagerBase*(node.getUpdateCallback());
if (b) {
_am = new osgAnimation::BasicAnimationManager(*b);
node.setUpdateCallback(_am.get());
return;
}
}
traverse(node);
}
};

//
//Finds an Animation by name, returning a pointer to the animation
//and a pointer to the manager it was found in
struct FindOsgAnimationByName : public osg::NodeVisitor
{
	//the name of the source animation we are looking for
	std::string _sourceAnimationName;

	//used to return the animation and the manager it was stored in
	osgAnimation::Animation* p_ani;
	osgAnimation::AnimationManagerBase* p_manager;

	FindOsgAnimationByName(std::string sourceAnimationName) 
		: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
		p_ani(NULL),
		p_manager(NULL),
		_sourceAnimationName(sourceAnimationName)
	{
	}
	void apply(osg::Node node) {

		if (node.getUpdateCallback()) {
			osgAnimation::AnimationManagerBase* b = dynamic_castosgAnimation::AnimationManagerBase*(node.getUpdateCallback());
			if (b) {
//we have found a valid osgAnimation manager, now look for the single long animation inside with the desired name
osgAnimation::AnimationList aniList = b-getAnimationList();
for(unsigned int i=0; ianiList.size(); i++){
	if(aniList[i]-getName() == _sourceAnimationName){
		p_manager = b;
		p_ani = aniList[i].get();
		return;
	}
}
			}
		}
		traverse(node);
	}
};

class AnimationUtils
{
public:

	//returns the index of the keyframe closest to the passed time
	//returns -1 if the time is out of range of the key container
	template typename ContainerType
	static int GetNearestKeyFrameIndex(ContainerType* keyContainer, double time)
	{
		if(!keyContainer){return -1;}

		int closestFrame = -1;
		double closestDiff = 9.99f;

		//loop all the keys
		for(unsigned int i=0; ikeyContainer-size(); i++)
		{
			double diff = fabs(time - (*keyContainer)[i].getTime());
			if( diff  closestDiff){
closestFrame = i;
closestDiff = diff;
			}
		}
		return closestFrame;
	}

	 Helper method for resampling channels
	template typename ChannelType, typename ContainerType
	static osg::ref_ptrChannelType ResampleChannel(ChannelType* sourceChannel, unsigned int startFrame, unsigned int endFrame, int fps)
	{
		osg::ref_ptrChannelType newChannel = NULL;
		if(!sourceChannel){
			return newChannel;
		}

		//get the key frame container from the source channel
		ContainerType* sourceKeyCont  = sourceChannel-getSamplerTyped()-getKeyframeContainerTyped();

		if (sourceKeyCont)
		{
			OSG_INFO  OsgAnimationTools ResampleChannel INFO: Resampling source channel '  sourceChannel-getName() 
	  ', from startFrame '  startFrame  ' to endFrame '  endFrame  . Total frames in source channel '  sourceKeyCont-size()  '.  std::endl;

			//determine the copy direction, i.e. lets see if we can copy frames in reverse as could come in handy
			unsigned int from=startFrame;
			unsigned int to=endFrame;
			if(startFrame  endFrame){
from = endFrame;
to = startFrame;
			}

			//get our frames as a times 
			double fromTime = from == 0 ? 0.0f : (float)from/(float)fps;
			double toTime = to == 0 ? 0.0f : (float)to/(float)fps;

			//needs to be if time is too big
			float firstTime = (*sourceKeyCont)[0].getTime();
			float lastTime = 

Re: [osg-users] fbx animation

2011-03-25 Thread Josue Hernandez
ok, but what means an in the follow line?:

finder._am-playAnimation( animations[an].get() );

and where i can see how can i do this:

   Finally, you can do what ever you want: play the animation on the
   osgViewer, get the Duration, the StartTime, the Name of the animation... 
specify the PlayMode..

PD the fbx load ok
PD2: sorry if my english is not good

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





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


Re: [osg-users] fbx animation

2011-03-25 Thread Josue Hernandez
forget what i say about the an jeje

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





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


Re: [osg-users] fbx animation

2011-03-24 Thread Mr Alji
Hi Josue  Morad,

Here is a newbie explanation :

   - First time, you need to know that the *osgDB *library provides access
   to a lot of 2D and 3D files ( like .fbx ), by managing several *osg *
   plugins.
   - You intend to use an fbx file, so you need to check if the plugin FBX
   reader/writer is correctly installed.
   - In second, the following snippet enable to load the scene graph of an
   fbx file:

osg::ref_ptrosg::Node root = osgDB::readNodeFile( fbxFile )


   - Then, locate the *AnimationManager *you want to use either *Basic *or *
   Timeline*, according to your necessity.

 [image: a02292.png]

   - the best way is to use the design pattern Visitor, already implemented
   in *osg::NodeVisitor*.

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

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

 void apply(osg::Node node) {

 if (_am.valid())
 return;

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

 traverse(node);
 }
 };


   - In the previous code snippet, the *BasicAnimationManager*, if it is
   found, will be stored on the variable* '_am' *located at *finder._am.*
   - in your main function:

AnimationManagerFinder finder;
 root-accept(finder);


   - then you can recuperate the *AnimationList* avalaible in your fbx file
   like this:

const osgAnimation::AnimationList animations =
 finder._am-getAnimationList();


   - Finally, you can do what ever you want: play the animation on the *
   osgViewer*, get the *Duration*, the *StartTime*, the *Name *of the
   animation... specify the *PlayMode*..

finder._am-playAnimation( animations[an].get() );

 ...

std::cout  name animation:   animations[an]-getName()  std::endl;



I hope I helped :) please feel free to respond to this topic to ameliorate
it.

Have a nice day*
--*
*M. ALJI **Mohamed *
a02292.png___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] fbx animation

2011-03-23 Thread Josue Hernandez
Hi, everybody:

anyone know how to activate an animation. fbx?

... 

Thank you!

Cheers,
Josue

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





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


Re: [osg-users] fbx animation

2011-03-23 Thread Mourad Boufarguine
Hi Josue,

take a look at osganimationviewer example.

Mourad


On Wed, Mar 23, 2011 at 5:48 PM, Josue Hernandez osgfo...@tevs.eu wrote:

 Hi, everybody:

 anyone know how to activate an animation. fbx?

 ...

 Thank you!

 Cheers,
 Josue

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





 ___
 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