Re: [Plib-users] TweenController in plib
Brought to you by:
sjbaker
|
From: <Rol...@t-...> - 2002-07-11 12:28:16
|
On Thursday 11 July 2002 20:03, Steve Baker wrote:
> Rolf Jakob wrote:
> > I try to get a tween controller to work with the current CVS snapshot.
> > What I did :
> > Used exposer to have some animation and saved a tweened model with a bank
> > every second.
> > Load the model using ssgLoadSSG resulting to a hierarchy starting with an
> > ssgEntity. In fact this should be a ssgTweenController.
>
> Well, ssgEntity is an abstract base class in SSG - you can't have a 'pure'
> ssgEntity - it's always some kind of derived class.
>
> > Create a ssgTransform and add the tween controller as a kid to be able to
> > transform the model in the scene.
> > Use the ssgTransform for transformation and the ssgTweenController for
> > the animation (this one has to be casted from ssgEntity).
> > The animation has the default length of 10 seconds, so I should have 10
> > banks.
>
> Sounds reasonable.
>
> > The problem is I cannot see the model moving, it's always in its first
> > position. A debug shows that the bank selecting factor travels from 0.0
> > to somewhere near 10 and restarts at 0.0, so that should be ok.
>
> Indeed.
>
> > I'm quite sure I miss something very simple, but what ?
> > Is the way I got the model into the scene the way it should be ? Is the
> > type of the root node preserved from exposer through a ssgLoadSSG() ?
>
> Yes - it should be.
>
> > Code sniplets:
> > // global
> > ssgTransform *femme=0;
> > ssgEntity *femme_obj;
> >
> > // init
> > femme=new ssgTransform;
> > femme_obj=ssgLoadSSG("player-female_tweened.ssg");
> > femme->addKid(femme_obj);
> > sgCoord fc;
> > sgSetCoord(&fc,1.67,0.126,0,90,0,0);
> > femme->setTransform(&fc);
> > scene->addKid(femme);
> >
> > // redraw
> > float bank=(frameno%140)/14.0;
> > ((ssgTweenController *)femme_obj)->selectBank(bank);
> > cerr << "bank : " << bank << endl;
>
> Well, that *looks* OK.
>
> One of my programs does this:
>
> body_tween = new ssgTweenController () ;
> body_tween -> addKid ( ssgLoad ( "body.ssg" , loader_opts ) ) ;
>
> ..and then...
>
> void update_motion ()
> {
> static int frameno = 0 ;
>
> frameno++ ;
>
> body_tween -> selectBank ( (float)frameno/100.0 ) ;
> }
So, you only have a ssgTweenController.
I tried again and removed the ssgTransform, so that I have :
ssgTweenController *femme_obj;
femme_obj=new ssgTweenController;
femme_obj->addKid(ssgLoadSSG("player-female_tweened.ssg"));
scene->addKid(femme_obj);
float bank=(frameno%140)/14.0;
femme_obj->selectBank(bank);
cerr << femme_obj->getTypeName() << " bank : " << bank << endl;
It's an ssgTweenController now, but it won't move. *sigh*
Before your reply I checked another thing: I used to have a ssgEntity casted
to a ssgTweenController when needed. I turned it around so that I have a
ssgTweenController and the result of ssgLoadSSG is casted once. That showed
the exact same result.
> ..so I think you are basically doing the right thing - you must have
> a bug somewhere. I guess you should do:
>
> cerr << femme->getTypeName() << endl ;
femme is a ssgTransform, femme_obj was a ssgRoot in my first example.
With the modifications above (no ssgTransform) a femme_obj->print() reads:
Current Bank = 0.000000
ssgTweenController: Name=NoName
Userdata = (nil)
Num Parents=0
Num Kids=1
BSphere is Empty.
ssgRoot: Name=NoName
So, there is still this ssgRoot like it was before, only that it has a
ssgTweenController as a parent.
Some more lines:
Userdata = (nil)
Num Parents=1
Num Kids=1
BSphere R=0.360757, C=(-0.00305547,0.0112409,0.284257)
ssgBranch: Name=NoName
Userdata = (nil)
Num Parents=1
Num Kids=1
BSphere R=0.360757, C=(-0.00305547,0.0112409,0.284257)
ssgBranch: Name=NoName
Userdata = (nil)
Num Parents=1
Num Kids=16
BSphere R=0.360757, C=(-0.00305547,0.0112409,0.284257)
ssgBranch: Name=LStiefel
Userdata = (nil)
Num Parents=1
Num Kids=4
BSphere R=0.130889, C=(-0.0273403,0.00357434,0.148229)
ssgBranch: Name=convexhull
Userdata = (nil)
Num Parents=1
Num Kids=4
BSphere R=0.0362996, C=(-0.0276763,-0.0419187,0.13792)
ssgTween: Name=NoName
Down there is the first ssgTween.
Hmmm, I'm supposed to use the file exposer writes directly without any further
modifications, right ?
Again out of ideas,
Rolf
PS: I put the current snapshot of the program and everything needed on my
home page, just in case somebody is interested in it and wants to take a look
at it. It's a beginning of a OLRPG with server and client, multiple scenes
and hopefully some walking characters - somewhen ;-)
--
Rolf Jakob at home (rj...@du...)
WWW : http://www.franken.de/users/duffy1/rjakob (KDE-Utils and CCS)
|