ARToolKit | Mailing List Archive |
![]() |
From: | "Richard Wetzel" <richard.wetzel@l ..........> | Received: | Sep 2, 2004 |
To | "Mailinglist AR Toolkit" <artoolkit@h ..................> | ||
Subject: | Restarting VRML animation | ||
Hi, I am currently using the ARToolkit and trying to restart a (looped) VRML animation depending on user interaction, e.g. if a user does $something then the animation should be restarted. Anybody got a hint for me? I succeeded in _resetting_ the animation by using arVrml97Reset(id) (where "id" is of course the vrml_id of the object) However the animation will not _restart_ but stay in the starting position instead. I assume I have to give the timer a restart a something, but I am quite stuck atm so I appreciate any help. Best regards, Richard -- Ich war ja früher ein wandelnder Vulkan - und jetzt bin ich das auch noch! Aber ich habe mich im Griff. (Otto Rehhagel) |
From: | sunek@d .......... | Received: | Sep 3, 2004 |
To | Richard Wetzel <rwetzel@t .....>, Richard Wetzel <richard.wetzel@l ..........> | ||
Subject: | Re: Restarting VRML animation | ||
Hi Richard I have not been using the VRML version much but I looked at the simpleVRML example and in the end of the main loop I found these lines: /* update the VRML animation */ arVrml97TimerUpdate(); So if you forget to call the arVrml97TimerUpdate() the animation will stay in the staring position. If this does not solve the problem please write again. Best Regards Sune Kristensen Citat Richard Wetzel <richard.wetzel@l ..........>: > Hi, > > I am currently using the ARToolkit and trying to restart a (looped) VRML > animation depending on user interaction, e.g. if a user does $something > then the animation should be restarted. > > Anybody got a hint for me? > > I succeeded in _resetting_ the animation by using > arVrml97Reset(id) > > (where "id" is of course the vrml_id of the object) > > However the animation will not _restart_ but stay in the starting > position instead. > > I assume I have to give the timer a restart a something, but I am quite > stuck atm so I appreciate any help. > > Best regards, > Richard > > -- > Ich war ja früher ein wandelnder Vulkan - und jetzt bin ich das auch > noch! Aber ich habe mich im Griff. (Otto Rehhagel) > > |
From: | "Richard Wetzel" <richard.wetzel@l ..........> | Received: | Sep 6, 2004 |
To | <sunek@d ..........> | ||
Subject: | Re: Restarting VRML animation | ||
Hi Sune, thanks for your efforts to help, but arVrml97TimerUpdate() is not able to restart the animation (i.e. the timer). It is called in every frame in the main loop, and as far as I understand it, it just increases the timer. arVrml97Reset() seems to do more than to just set the timer to 0 as its name would imply. Here are some code snippets from vrml97.cpp: int arVrml97TimerUpdate() { int i; for( i = 0; i < AR_VRML97_MAX; i++ ) { if( viewer[i] == NULL ) continue; viewer[i]->timerUpdate(); } return 0; } int arVrml97Reset( int id ) { if( viewer[id] == NULL ) return -1; #if 0 delete viewer[id]->vrmlScene; viewer[id]->vrmlScene = new VrmlScene( viewer[id]->filename, viewer[id]->filename ); if( viewer[id]->vrmlScene == NULL ) { viewer[id] = NULL; if( vrID == id ) { vrID = -1; glPopAttrib(); glutSpecialFunc( NULL ); glutMouseFunc( NULL ); glutMotionFunc( NULL ); glutPassiveMotionFunc( NULL ); } return -1; } #endif viewer[id]->vrmlScene->resetTimer(); return 0; } And from VrmlScene.cpp: void VrmlScene::resetTimer( void ) { // Reset each of the timers. VrmlNodeList::iterator i, end = d_timers->end(); for (i = d_timers->begin(); i != end; ++i) { VrmlNodeTimeSensor *t = (*i)->toTimeSensor(); if (t) t->reset(); } return; } And from VrmlNodeTimeSensor.cpp: void VrmlNodeTimeSensor::reset( void ) { double timeStamp = theSystem->time(); d_stopTime.set(timeStamp); d_enabled.set(true), d_startTime.set(timeStamp); d_stopTime.set(timeStamp + 0.001); d_isActive.set(true); d_lastTime = -1.0; } I am trying to do this, because I have some animations that need to be seen by the user from the start. Therefore the timer should start at the very moment the marker is detected for the first time. This alone would be no problem, however as I have several markers that all need this feat, I need to reset the timer for every marker independently. Best regards, Richard -- Die Griechen sind ja natürlich so übertrieben. Wenn wir einmal gewinnen, dann wollen die gleich Europameister werden, und wenn wir zweimal verlieren, wollen sich alle ins Meer stürzen. (Otto Rehhagel) |
From: | "Brandon J. Rickman" <rickman@a ............> | Received: | Sep 8, 2004 |
To | "Richard Wetzel" <rwetzel@t .....> | ||
Subject: | Re: Restarting VRML animation | ||
I've been puzzling over the code for VrmlNodeTimeSensor::reset, I don't see it in the openVRML source, so it must have been added for the artoolkit distribution. The reset code is clobbering whatever values for startTime and stopTime that were originally there. The next time the timer performs an update, it will go to the starting position, and on the next update it will pass stopTime, stopping the animation. Not useful. The reason why arVrml97Reset doesn't restart all the timers is that it doesn't know which timers should be running, some of them might be connected to touch sensors and so on. So in order to restart an animation, you need to know which TimeSensors to talk to. In your VRML file, you could create a node with a time eventOut and wire it to set_startTime for each timer you want to restart. Then you just need to get that event to fire, and it will restart the animation. But I'm not sure how to trigger an event from ARToolkit. The API does give you access to the scene graph, via VrmlScene::getRoot(). And you can queue an event with VrmlScene::queueEvent(double timeStamp, VrmlField *value, VrmlNode *toNode, const char *toEventIn). So, locate the VrmlNode you want, figure out values for timeStamp, value, and toEventIn, and queue the event. (toEventIn is a VRML format string, so "set_foo" will set field foo on the target node.) The hack solution, if you want to restart all of the time sensors at once, is to remove the two d_stopTime.set() lines from VrmlNodeTimeSensor::reset. This will restart all animations, but is the wrong thing to do wrt the API. - Brandon ----- Original Message ----- From: "Richard Wetzel" <richard.wetzel@l ..........> Subject: Re: Restarting VRML animation Hi Sune, thanks for your efforts to help, but arVrml97TimerUpdate() is not able to restart the animation (i.e. the timer). It is called in every frame in the main loop, and as far as I understand it, it just increases the timer. ... And from VrmlNodeTimeSensor.cpp: void VrmlNodeTimeSensor::reset( void ) { double timeStamp = theSystem->time(); d_stopTime.set(timeStamp); d_enabled.set(true), d_startTime.set(timeStamp); d_stopTime.set(timeStamp + 0.001); d_isActive.set(true); d_lastTime = -1.0; } |